repo stringlengths 5 92 | file_url stringlengths 80 287 | file_path stringlengths 5 197 | content stringlengths 0 32.8k | language stringclasses 1
value | license stringclasses 7
values | commit_sha stringlengths 40 40 | retrieved_at stringdate 2026-01-04 15:37:27 2026-01-04 17:58:21 | truncated bool 2
classes |
|---|---|---|---|---|---|---|---|---|
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/dsl_helper.rb | lib/aasm/dsl_helper.rb | module AASM
module DslHelper
class Proxy
attr_accessor :options
def initialize(options, valid_keys, source)
@valid_keys = valid_keys
@source = source
@options = options
end
def method_missing(name, *args, &block)
if @valid_keys.include?(name)
o... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/minitest/have_state.rb | lib/aasm/minitest/have_state.rb | module Minitest::Assertions
def assert_have_state(object, state, options = {})
state_machine_name = options.fetch(:on, :default)
assert object.aasm(state_machine_name).current_state == state,
"Expected that :#{object.aasm(state_machine_name).current_state} would be :#{state} (on :#{state_machine_name... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/minitest/allow_event.rb | lib/aasm/minitest/allow_event.rb | module Minitest::Assertions
def assert_event_allowed(object, event, options = {})
state_machine_name = options.fetch(:on, :default)
assert object.aasm(state_machine_name).may_fire_event?(event),
"Expected that the event :#{event} would be allowed (on :#{state_machine_name})"
end
def refute_even... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/minitest/transition_from.rb | lib/aasm/minitest/transition_from.rb | module Minitest::Assertions
def assert_transitions_from(object, from_state, *args)
options = args.first
options[:on] ||= :default
assert _transitions_from?(object, from_state, args, options),
"Expected transition state to :#{options[:to]} from :#{from_state} on event :#{options[:on_event]}, (on ... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/minitest/allow_transition_to.rb | lib/aasm/minitest/allow_transition_to.rb | module Minitest::Assertions
def assert_transition_to_allowed(object, to_state, options = {})
state_machine_name = options.fetch(:on, :default)
assert object.aasm(state_machine_name).states(permitted: true).include?(to_state),
"Expected that the state :#{to_state} would be reachable (on :#{state_mac... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/rspec/have_state.rb | lib/aasm/rspec/have_state.rb | RSpec::Matchers.define :have_state do |state|
match do |obj|
@state_machine_name ||= :default
obj.aasm(@state_machine_name).current_state == state.to_sym
end
chain :on do |state_machine_name|
@state_machine_name = state_machine_name
end
description do
"have state #{expected} (on :#{@state_ma... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/rspec/allow_event.rb | lib/aasm/rspec/allow_event.rb | RSpec::Matchers.define :allow_event do |event|
match do |obj|
@state_machine_name ||= :default
obj.aasm(@state_machine_name).may_fire_event?(event, *@args)
end
chain :on do |state_machine_name|
@state_machine_name = state_machine_name
end
chain :with do |*args|
@args = args
end
descript... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/rspec/transition_from.rb | lib/aasm/rspec/transition_from.rb | RSpec::Matchers.define :transition_from do |from_state|
match do |obj|
@state_machine_name ||= :default
obj.aasm(@state_machine_name).current_state = from_state.to_sym
begin
obj.send(@event, *@args) && obj.aasm(@state_machine_name).current_state == @to_state.to_sym
rescue AASM::InvalidTransition... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/rspec/allow_transition_to.rb | lib/aasm/rspec/allow_transition_to.rb | RSpec::Matchers.define :allow_transition_to do |state|
match do |obj|
@state_machine_name ||= :default
obj.aasm(@state_machine_name).states({:permitted => true}, *@args).include?(state)
end
chain :on do |state_machine_name|
@state_machine_name = state_machine_name
end
chain :with do |*args|
... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/persistence/orm.rb | lib/aasm/persistence/orm.rb | module AASM
module Persistence
# This module adds transactional support for any database that supports it.
# This includes rollback capability and rollback/commit callbacks.
module ORM
# Writes <tt>state</tt> to the state column and persists it to the database
#
# foo = Foo.find(1)
... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/persistence/plain_persistence.rb | lib/aasm/persistence/plain_persistence.rb | module AASM
module Persistence
module PlainPersistence
# may be overwritten by persistence mixins
def aasm_read_state(name=:default)
# all the following lines behave like @current_state ||= aasm(name).enter_initial_state
current = aasm(name).instance_variable_defined?("@current_state_... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/persistence/active_record_persistence.rb | lib/aasm/persistence/active_record_persistence.rb | require 'aasm/persistence/orm'
module AASM
module Persistence
module ActiveRecordPersistence
# This method:
#
# * extends the model with ClassMethods
# * includes InstanceMethods
#
# Adds
#
# after_initialize :aasm_ensure_initial_state
#
# As a result,... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/persistence/base.rb | lib/aasm/persistence/base.rb | module AASM
module Persistence
module Base
def self.included(base) #:nodoc:
base.extend ClassMethods
end
# Returns the value of the aasm.attribute_name - called from <tt>aasm.current_state</tt>
#
# If it's a new record, and the aasm state column is blank it returns the init... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/persistence/dynamoid_persistence.rb | lib/aasm/persistence/dynamoid_persistence.rb | module AASM
module Persistence
module DynamoidPersistence
def self.included(base)
base.send(:include, AASM::Persistence::Base)
base.send(:include, AASM::Persistence::DynamoidPersistence::InstanceMethods)
base.after_initialize :aasm_ensure_initial_state
# Because Dynamoid on... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/persistence/redis_persistence.rb | lib/aasm/persistence/redis_persistence.rb | module AASM
module Persistence
module RedisPersistence
def self.included(base)
base.send(:include, AASM::Persistence::Base)
base.send(:include, AASM::Persistence::RedisPersistence::InstanceMethods)
end
module InstanceMethods
# Initialize with default values
#
... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/persistence/core_data_query_persistence.rb | lib/aasm/persistence/core_data_query_persistence.rb | module AASM
module Persistence
module CoreDataQueryPersistence
# This method:
#
# * extends the model with ClassMethods
# * includes InstanceMethods
#
# Adds
#
# after_initialize :aasm_ensure_initial_state
#
def self.included(base)
base.send(:... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/persistence/mongoid_persistence.rb | lib/aasm/persistence/mongoid_persistence.rb | require 'aasm/persistence/orm'
module AASM
module Persistence
module MongoidPersistence
# This method:
#
# * extends the model with ClassMethods
# * includes InstanceMethods
#
# Adds
#
# before_validation :aasm_ensure_initial_state
#
# As a result, it ... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/persistence/sequel_persistence.rb | lib/aasm/persistence/sequel_persistence.rb | require 'aasm/persistence/orm'
module AASM
module Persistence
module SequelPersistence
def self.included(base)
base.send(:include, AASM::Persistence::Base)
base.send(:include, AASM::Persistence::ORM)
base.send(:include, AASM::Persistence::SequelPersistence::InstanceMethods)
end... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/persistence/no_brainer_persistence.rb | lib/aasm/persistence/no_brainer_persistence.rb | require 'aasm/persistence/orm'
module AASM
module Persistence
module NoBrainerPersistence
# This method:
#
# * extends the model with ClassMethods
# * includes InstanceMethods
#
# Adds
#
# before_validation :aasm_ensure_initial_state
#
# As a result, i... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/core/event.rb | lib/aasm/core/event.rb | # frozen_string_literal: true
module AASM::Core
class Event
include AASM::DslHelper
attr_reader :name, :state_machine, :options, :default_display_name
def initialize(name, state_machine, options = {}, &block)
@name = name
@state_machine = state_machine
@transitions = []
@valid_t... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/core/transition.rb | lib/aasm/core/transition.rb | # frozen_string_literal: true
module AASM::Core
class Transition
include AASM::DslHelper
attr_reader :from, :to, :event, :opts, :failures
alias_method :options, :opts
def initialize(event, opts, &block)
add_options_from_dsl(opts, [:on_transition, :guard, :after, :success], &block) if block
... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/core/state.rb | lib/aasm/core/state.rb | # frozen_string_literal: true
module AASM::Core
class State
attr_reader :name, :state_machine, :options, :default_display_name
def initialize(name, klass, state_machine, options={})
@name = name
@klass = klass
@state_machine = state_machine
@default_display_name = name.to_s.gsub(/_/,... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/core/invoker.rb | lib/aasm/core/invoker.rb | # frozen_string_literal: true
module AASM
module Core
##
# main invoker class which encapsulates the logic
# for invoking literal-based, proc-based, class-based
# and array-based callbacks for different entities.
class Invoker
DEFAULT_RETURN_VALUE = true
##
# Initialize a new i... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/core/invokers/literal_invoker.rb | lib/aasm/core/invokers/literal_invoker.rb | # frozen_string_literal: true
module AASM
module Core
module Invokers
##
# Literal invoker which allows to use strings or symbols to call
# record methods as state/event/transition callbacks.
class LiteralInvoker < BaseInvoker
def may_invoke?
subject.is_a?(String) || sub... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/core/invokers/proc_invoker.rb | lib/aasm/core/invokers/proc_invoker.rb | # frozen_string_literal: true
module AASM
module Core
module Invokers
##
# Proc invoker which allows to use Procs as
# state/event/transition callbacks.
class ProcInvoker < BaseInvoker
def may_invoke?
subject.is_a?(Proc)
end
def log_failure
ret... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/core/invokers/base_invoker.rb | lib/aasm/core/invokers/base_invoker.rb | # frozen_string_literal: true
module AASM
module Core
module Invokers
##
# Base concrete invoker class which contain basic
# invoking and logging definitions
class BaseInvoker
attr_reader :failures, :subject, :record, :args, :result
##
# Initialize a new concrete ... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
aasm/aasm | https://github.com/aasm/aasm/blob/726a578808e0f403bfd24e505f9a45319670a6b7/lib/aasm/core/invokers/class_invoker.rb | lib/aasm/core/invokers/class_invoker.rb | # frozen_string_literal: true
module AASM
module Core
module Invokers
##
# Class invoker which allows to use classes which respond to #call
# to be used as state/event/transition callbacks.
class ClassInvoker < BaseInvoker
def may_invoke?
subject.is_a?(Class) && subject.... | ruby | MIT | 726a578808e0f403bfd24e505f9a45319670a6b7 | 2026-01-04T15:43:55.088186Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/generate_action_mailer_specs.rb | example_app_generator/generate_action_mailer_specs.rb | require 'active_support'
require 'active_support/core_ext/module'
using_source_path(File.expand_path(__dir__)) do
# Comment out the default mailer stuff
comment_lines 'config/environments/development.rb', /action_mailer/
comment_lines 'config/environments/test.rb', /action_mailer/
initializer 'action_mailer.r... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/generate_app.rb | example_app_generator/generate_app.rb | require 'nokogiri'
rspec_rails_repo_path = File.expand_path('..', __dir__)
rspec_dependencies_gemfile = File.join(rspec_rails_repo_path, 'Gemfile-rspec-dependencies')
rails_dependencies_gemfile = File.join(rspec_rails_repo_path, 'Gemfile-rails-dependencies')
bundle_install_path = File.join(rspec_rails_repo_path, '..',... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/run_specs.rb | example_app_generator/run_specs.rb | run('bin/rspec spec -cfdoc') || abort
# Ensure we test the issue in-case this isn't the first spec file loaded
run(
'bin/rspec --backtrace -cfdoc spec/__verify_fixture_load_order_spec.rb'
) || abort
run('bin/rake --backtrace spec') || abort
run('bin/rake --backtrace spec:requests') || abort
run('bin/rake --backtrace ... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/generate_stuff.rb | example_app_generator/generate_stuff.rb | require 'rspec/rails/feature_check'
DEFAULT_SOURCE_PATH = File.expand_path(__dir__)
module ExampleAppHooks
module AR
def source_paths
@__source_paths__ ||= [DEFAULT_SOURCE_PATH]
end
def setup_tasks
# no-op
end
def final_tasks
copy_file 'spec/verify_active_record_spec.rb'
... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/no_active_record/app/models/in_memory/model.rb | example_app_generator/no_active_record/app/models/in_memory/model.rb | raise "ActiveRecord is defined but should not be!" if defined?(::ActiveRecord)
require 'active_model'
module InMemory
module Persistence
def all
@all_records ||= []
end
def count
all.length
end
alias_method :size, :count
alias_method :length, :count
def last
all.last
... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/no_active_record/spec/verify_no_active_record_spec.rb | example_app_generator/no_active_record/spec/verify_no_active_record_spec.rb | require 'rails_helper'
RSpec.describe 'Example App' do
it "does not have ActiveRecord defined" do
expect(defined?(ActiveRecord)).not_to be
end
end
| ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/no_active_record/spec/verify_no_fixture_setup_spec.rb | example_app_generator/no_active_record/spec/verify_no_fixture_setup_spec.rb | # Pretend that ActiveRecord::Rails is defined and this doesn't blow up
# with `config.use_active_record = false`.
# Trick the other spec that checks that ActiveRecord is
# *not* defined by wrapping it in RSpec::Rails namespace
# so that it's reachable from RSpec::Rails::FixtureSupport.
# NOTE: this has to be defined be... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/no_active_record/spec/verify_fixture_file_upload_spec.rb | example_app_generator/no_active_record/spec/verify_fixture_file_upload_spec.rb | require 'rails_helper'
RSpec.describe 'Example App', :use_fixtures, type: :model do
it 'supports fixture file upload' do
file = fixture_file_upload(__FILE__)
expect(file.read).to match(/RSpec\.describe 'Example App'/im)
end
end
| ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/no_active_record/lib/rails/generators/in_memory/model/model_generator.rb | example_app_generator/no_active_record/lib/rails/generators/in_memory/model/model_generator.rb | # Hook into the work already done to support older Rails
require 'generators/rspec'
module InMemory
module Generators
class ModelGenerator < ::Rspec::Generators::Base
source_root File.expand_path('templates', __dir__)
desc "Creates a Fake ActiveRecord acting model"
argument :attributes,
... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/no_active_record/config/initializers/zeitwerk.rb | example_app_generator/no_active_record/config/initializers/zeitwerk.rb | if Rails.autoloaders.respond_to?(:main) && Rails.autoloaders.main.respond_to?(:ignore)
Rails.autoloaders.main.ignore('lib/rails/generators/in_memory/model/model_generator.rb')
end
| ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/spec/verify_fixture_warning_spec.rb | example_app_generator/spec/verify_fixture_warning_spec.rb | require 'rails_helper'
RSpec.describe "Fixture warnings" do
def generate_fixture_example_group(hook_type)
RSpec.describe do
include RSpec::Rails::RailsExampleGroup
fixtures :things
before(hook_type) do
things :a
end
it "" do
end
end
end
it "Warns when a fix... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/spec/verify_active_record_spec.rb | example_app_generator/spec/verify_active_record_spec.rb | require 'rails_helper'
RSpec.describe 'Example App' do
it "has ActiveRecord defined" do
expect(defined?(ActiveRecord)).to be
end
end
| ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/spec/__verify_fixture_load_order_spec.rb | example_app_generator/spec/__verify_fixture_load_order_spec.rb | # This spec needs to be run before `rails_helper` is loaded to check the issue
RSpec.describe "Verify issue rspec/rspec-rails#1355" do
it "passes" do
expect(1).to eq 1
end
end
require 'rails_helper'
| ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/spec/verify_custom_renderers_spec.rb | example_app_generator/spec/verify_custom_renderers_spec.rb | require 'rails_helper'
RSpec.describe "template rendering", type: :controller do
context "without render_views" do
context "with the standard renderers" do
controller do
def index
render template: 'foo', layout: false
end
end
it "renders the 'foo' template" do
... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/spec/verify_mailer_preview_path_spec.rb | example_app_generator/spec/verify_mailer_preview_path_spec.rb | require 'rails_helper'
require 'rspec/rails/feature_check'
RSpec.describe 'Action Mailer railtie hook' do
CaptureExec = Struct.new(:io, :exit_status) do
def ==(str)
io == str
end
end
def as_commandline(ops)
cmd, ops = ops.reverse
ops ||= {}
cmd_parts = ops.map { |k, v| "#{k}=#{v}" } <<... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/spec/verify_view_path_stub_spec.rb | example_app_generator/spec/verify_view_path_stub_spec.rb | require 'rails_helper'
RSpec.describe "verify view path doesn't leak stubs between examples", type: :view, order: :defined do
subject(:html) do
render partial: "example"
rendered
end
it "renders the stub template" do
stub_template("_example.html.erb" => "STUB_HTML")
expect(html).to include("STUB... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/example_app_generator/spec/features/model_mocks_integration_spec.rb | example_app_generator/spec/features/model_mocks_integration_spec.rb | require 'rails_helper'
RSpec.describe "Using rspec-mocks with models" do
it "supports stubbing class methods on models" do
allow(Widget).to receive(:all).and_return(:any_stub)
expect(Widget.all).to be :any_stub
end
it "supports stubbing attribute methods on models" do
a_widget = Widget.new
allow... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/benchmarks/before_block_capture_block_vs_yield.rb | benchmarks/before_block_capture_block_vs_yield.rb | require 'benchmark/ips'
def before_n_times(n, &block)
n.times { instance_exec(&block) }
end
def yield_n_times(n)
before_n_times(n) { yield }
end
def capture_block_and_yield_n_times(n, &block) # rubocop:disable Lint/UnusedMethodArgument
before_n_times(n) { yield }
end
def capture_block_and_call_n_times(n, &blo... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/snippets/include_activesupport_testing_tagged_logger.rb | snippets/include_activesupport_testing_tagged_logger.rb | if __FILE__ =~ /^snippets/
fail "Snippets are supposed to be run from their own directory to avoid side " \
"effects as e.g. the root `Gemfile`, or `spec/spec_helpers.rb` to be " \
"loaded by the root `.rspec`."
end
# We opt-out from using RubyGems, but `bundler/inline` requires it
require 'rubygems'
... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/snippets/avoid_fixture_name_collision.rb | snippets/avoid_fixture_name_collision.rb | if __FILE__ =~ /^snippets/
fail "Snippets are supposed to be run from their own directory to avoid side " \
"effects as e.g. the root `Gemfile`, or `spec/spec_helpers.rb` to be " \
"loaded by the root `.rspec`."
end
# We opt-out from using RubyGems, but `bundler/inline` requires it
require 'rubygems'
... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/snippets/use_active_record_false.rb | snippets/use_active_record_false.rb | if __FILE__ =~ /^snippets/
fail "Snippets are supposed to be run from their own directory to avoid side " \
"effects as e.g. the root `Gemfile`, or `spec/spec_helpers.rb` to be " \
"loaded by the root `.rspec`."
end
# We opt-out from using RubyGems, but `bundler/inline` requires it
require 'rubygems'
... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/yard/template/default/layout/html/setup.rb | yard/template/default/layout/html/setup.rb | # Docs suggest I don't need this, but ...
YARD::Server::Commands::StaticFileCommand::STATIC_PATHS << File.expand_path('../../fulldoc/html', __dir__)
def stylesheets
super + ['css/rspec.css']
end
| ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/features/support/capybara.rb | features/support/capybara.rb | Around "@capybara" do |_scenario, block|
require 'capybara'
block.call
end
| ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/features/support/env.rb | features/support/env.rb | require 'aruba/cucumber'
require 'fileutils'
module ArubaExt
def run_command_and_stop(cmd, opts = {})
exec_cmd = cmd =~ /^rspec/ ? "bin/#{cmd}" : cmd
unset_bundler_env_vars
# Ensure the correct Gemfile and binstubs are found
in_current_directory do
with_unbundled_env do
super(exec_cmd,... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/features/step_definitions/additional_cli_steps.rb | features/step_definitions/additional_cli_steps.rb | begin
require "active_job"
rescue LoadError # rubocop:disable Lint/SuppressedException
end
begin
require "action_cable"
rescue LoadError # rubocop:disable Lint/SuppressedException
end
begin
require "active_storage"
require "action_mailbox"
rescue LoadError # rubocop:disable Lint/SuppressedException
end
require... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/sanity_check_spec.rb | spec/sanity_check_spec.rb | require 'pathname'
RSpec.describe "Verify required rspec dependencies" do
tmp_root = Pathname.new(RSpec::Core::RubyProject.root).join("tmp")
before { FileUtils.mkdir_p tmp_root }
def with_clean_env
if Bundler.respond_to?(:with_unbundled_env)
Bundler.with_unbundled_env { yield }
else
Bundle... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/spec_helper.rb | spec/spec_helper.rb | require 'rails/all'
module RSpecRails
class Application < ::Rails::Application
config.secret_key_base = 'ASecretString'
if defined?(ActionCable)
ActionCable.server.config.cable = { "adapter" => "test" }
ActionCable.server.config.logger =
ActiveSupport::TaggedLogging.new ActiveSupport::Lo... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/support/generators.rb | spec/support/generators.rb | module RSpec
module Rails
module Specs
module Generators
module Macros
# Tell the generator where to put its output (what it thinks of as
# Rails.root)
def set_default_destination
destination File.expand_path('../../tmp', __dir__)
end
de... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/support/shared_examples.rb | spec/support/shared_examples.rb | require 'pathname'
RSpec.shared_examples_for "an rspec-rails example group mixin" do |type, *paths|
let(:mixin) { described_class }
def define_group_in(path, group_definition)
path = Pathname(path)
$_new_group = nil
begin
file = path + "whatever_spec.rb"
Dir.mktmpdir("rspec-rails-app-root... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/support/group_failure_formatter.rb | spec/support/group_failure_formatter.rb | module RSpec::Rails::TestSupport
class FailureReporter
def initialize
@exceptions = []
end
attr_reader :exceptions
def example_failed(example)
@exceptions << example.exception
end
def method_missing(name, *_args, &_block)
end
end
def failure_reporter
@failure_reporte... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/support/null_object.rb | spec/support/null_object.rb | class NullObject
private
def method_missing(method, *args, &blk)
end
end
| ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/support/ar_classes.rb | spec/support/ar_classes.rb | ActiveRecord::Base.establish_connection(
adapter: 'sqlite3',
database: ':memory:'
)
module Connections
def self.extended(host)
fields =
{ host.primary_key => "integer PRIMARY KEY AUTOINCREMENT" }
fields.merge!(host.connection_fields) if host.respond_to?(:connection_fields)
host.connection.exe... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails_spec.rb | spec/rspec/rails_spec.rb | require 'rspec/support/spec/library_wide_checks'
RSpec.describe "RSpec::Rails" do
include RSpec::Support::WhitespaceChecks
# Pasted from rspec-support lib/rspec/support/spec/library_wide_checks.rb:134
# Easier to do that here than to extract it out
RSpec::Matchers.define :be_well_formed do
match do |actua... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/fixture_support_spec.rb | spec/rspec/rails/fixture_support_spec.rb | module RSpec::Rails
RSpec.describe FixtureSupport, :with_isolated_config do
context "with use_transactional_fixtures set to false" do
it "still supports fixture_path/fixture_paths" do
allow(RSpec.configuration).to receive(:use_transactional_fixtures) { false }
group = RSpec::Core::ExampleGro... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/minitest_lifecycle_adapter_spec.rb | spec/rspec/rails/minitest_lifecycle_adapter_spec.rb | RSpec.describe RSpec::Rails::MinitestLifecycleAdapter, :with_isolated_config do
it "invokes minitest lifecycle hooks at the appropriate times" do
invocations = []
example_group = RSpec::Core::ExampleGroup.describe("MinitestHooks") do
include RSpec::Rails::MinitestLifecycleAdapter
define_method(:b... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/assertion_delegator_spec.rb | spec/rspec/rails/assertion_delegator_spec.rb | RSpec.describe RSpec::Rails::AssertionDelegator do
it "provides a module that delegates assertion methods to an isolated class" do
klass = Class.new {
include RSpec::Rails::AssertionDelegator.new(RSpec::Rails::Assertions)
}
expect(klass.new).to respond_to(:assert)
end
it "delegates back to the... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/view_spec_methods_spec.rb | spec/rspec/rails/view_spec_methods_spec.rb | module RSpec::Rails
RSpec.describe ViewSpecMethods do
before do
class ::VCSampleClass; end
end
after do
Object.send(:remove_const, :VCSampleClass)
end
describe ".add_extra_params_accessors_to" do
describe "when accessors are not yet defined" do
it "adds them as instance... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/configuration_spec.rb | spec/rspec/rails/configuration_spec.rb | require 'rspec/support/spec/in_sub_process'
RSpec.describe "Configuration" do
include RSpec::Support::InSubProcess
subject(:config) { RSpec::Core::Configuration.new }
before do
RSpec::Rails.initialize_configuration(config)
end
it "adds 'vendor/' to the backtrace exclusions" do
expect(config.backtr... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/active_record_spec.rb | spec/rspec/rails/active_record_spec.rb | RSpec.describe "ActiveRecord support" do
around do |ex|
old_value = RSpec::Mocks.configuration.verify_partial_doubles?
ex.run
RSpec::Mocks.configuration.verify_partial_doubles = old_value
end
RSpec.shared_examples_for "stubbing ActiveRecord::Base" do
it "allows you to stub `ActiveRecord::Base`" d... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/assertion_adapter_spec.rb | spec/rspec/rails/assertion_adapter_spec.rb | RSpec.describe RSpec::Rails::MinitestAssertionAdapter do
include RSpec::Rails::MinitestAssertionAdapter
RSpec::Rails::Assertions.public_instance_methods.select { |m| m.to_s =~ /^(assert|flunk|refute)/ }.each do |m|
if m.to_s == "assert_equal"
it "exposes #{m} to host examples" do
assert_equal 3, ... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/setup_and_teardown_adapter_spec.rb | spec/rspec/rails/setup_and_teardown_adapter_spec.rb | RSpec.describe RSpec::Rails::SetupAndTeardownAdapter, :with_isolated_config do
describe ".setup" do
it "registers before hooks in the order setup is received" do
group = RSpec::Core::ExampleGroup.describe do
include RSpec::Rails::SetupAndTeardownAdapter
def self.foo; "foo"; end
def s... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/active_model_spec.rb | spec/rspec/rails/active_model_spec.rb | RSpec.describe "ActiveModel support" do
around do |ex|
old_value = RSpec::Mocks.configuration.verify_partial_doubles?
ex.run
RSpec::Mocks.configuration.verify_partial_doubles = old_value
end
RSpec.shared_examples_for "stubbing ActiveModel" do
before do
stub_const 'ActiveRecord' unless defin... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/fixture_file_upload_support_spec.rb | spec/rspec/rails/fixture_file_upload_support_spec.rb | module RSpec::Rails
RSpec.describe FixtureFileUploadSupport, :with_isolated_config do
context 'with fixture paths set in config' do
it 'resolves fixture file' do
RSpec.configuration.fixture_paths = [File.dirname(__FILE__)]
expect_to_pass fixture_file_upload_resolved('fixture_file_upload_supp... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/view_rendering_spec.rb | spec/rspec/rails/view_rendering_spec.rb | module RSpec::Rails
RSpec.describe ViewRendering, :with_isolated_config do
let(:group) do
RSpec::Core::ExampleGroup.describe do
def controller
ActionController::Base.new
end
include ViewRendering
end
end
context "default" do
context "ActionController::B... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/example/view_example_group_spec.rb | spec/rspec/rails/example/view_example_group_spec.rb | require 'support/group_failure_formatter'
module RSpec::Rails
RSpec.describe ViewExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :view,
'./spec/views/', '.\\spec\\views\\'
describe 'automatic inclusion of helpers' do
module ::ThingsHelpe... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/example/system_example_group_spec.rb | spec/rspec/rails/example/system_example_group_spec.rb | module RSpec::Rails
RSpec.describe SystemExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :system,
'./spec/system/', '.\\spec\\system\\'
describe '#method_name' do
it 'converts special characters to underscores' do
group = RSpec::C... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/example/controller_example_group_spec.rb | spec/rspec/rails/example/controller_example_group_spec.rb | class ::ApplicationController
def self.abstract?; false; end
end
module RSpec::Rails
RSpec.describe ControllerExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :controller,
'./spec/controllers/', '.\\spec\\controllers\\'
def group_for(klass)
... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/example/channel_example_group_spec.rb | spec/rspec/rails/example/channel_example_group_spec.rb | require "rspec/rails/feature_check"
module RSpec::Rails
RSpec.describe ChannelExampleGroup, :with_isolated_config do
if RSpec::Rails::FeatureCheck.has_action_cable_testing?
it_behaves_like "an rspec-rails example group mixin", :channel,
'./spec/channels/', '.\\spec\\channels\\'
en... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/example/helper_example_group_spec.rb | spec/rspec/rails/example/helper_example_group_spec.rb | module RSpec::Rails
RSpec.describe HelperExampleGroup, :with_isolated_config do
module ::FoosHelper
class InternalClass
end
end
subject { HelperExampleGroup }
it_behaves_like "an rspec-rails example group mixin", :helper,
'./spec/helpers/', '.\\spec\\helpers\\'
i... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/example/rails_example_group_spec.rb | spec/rspec/rails/example/rails_example_group_spec.rb | module RSpec::Rails
RSpec.describe RailsExampleGroup, :with_isolated_config do
it 'supports tagged_logger' do
expect(described_class.private_instance_methods).to include(:tagged_logger)
end
it 'does not leak context between example groups' do
groups =
[
RSpec::Core::ExampleG... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/example/routing_example_group_spec.rb | spec/rspec/rails/example/routing_example_group_spec.rb | module RSpec::Rails
RSpec.describe RoutingExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :routing,
'./spec/routing/', '.\\spec\\routing\\'
describe "named routes" do
it "delegates them to the route_set" do
group = RSpec::Core::Ex... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/example/job_example_group_spec.rb | spec/rspec/rails/example/job_example_group_spec.rb | module RSpec::Rails
RSpec.describe JobExampleGroup, :with_isolated_config do
if defined?(ActiveJob)
it_behaves_like "an rspec-rails example group mixin", :job,
'./spec/jobs/', '.\\spec\\jobs\\'
end
end
end
| ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/example/model_example_group_spec.rb | spec/rspec/rails/example/model_example_group_spec.rb | module RSpec::Rails
RSpec.describe ModelExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :model,
'./spec/models/', '.\\spec\\models\\'
end
end
| ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/example/mailbox_example_group_spec.rb | spec/rspec/rails/example/mailbox_example_group_spec.rb | require "rspec/rails/feature_check"
class ApplicationMailbox
class << self
attr_accessor :received
def receive(*)
self.received += 1
end
end
self.received = 0
end
module RSpec
module Rails
RSpec.describe MailboxExampleGroup, :with_isolated_config, skip: !RSpec::Rails::FeatureCheck.has_... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/example/request_example_group_spec.rb | spec/rspec/rails/example/request_example_group_spec.rb | module RSpec::Rails
RSpec.describe RequestExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :request,
'./spec/requests/', '.\\spec\\requests\\',
'./spec/integration/', '.\\spec\\integration\\',
'./spec/api/', '.... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/example/mailer_example_group_spec.rb | spec/rspec/rails/example/mailer_example_group_spec.rb | module RSpec::Rails
RSpec.describe MailerExampleGroup, :with_isolated_config do
module ::Rails; end
before do
allow(Rails).to receive_message_chain(:application, :routes, :url_helpers).and_return(Rails)
allow(Rails.application).to receive(:config).and_return(double("Rails.application.config").as_n... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/example/feature_example_group_spec.rb | spec/rspec/rails/example/feature_example_group_spec.rb | module RSpec::Rails
RSpec.describe FeatureExampleGroup, :with_isolated_config do
it_behaves_like "an rspec-rails example group mixin", :feature,
'./spec/features/', '.\\spec\\features\\'
it "includes Rails route helpers" do
with_isolated_stderr do
Rails.application.routes.dr... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/action_mailbox_spec.rb | spec/rspec/rails/matchers/action_mailbox_spec.rb | require "rspec/rails/feature_check"
class ApplicationMailbox
class Router
def match_to_mailbox(*)
Inbox
end
end
def self.router
Router.new
end
end
class Inbox < ApplicationMailbox; end
class Otherbox < ApplicationMailbox; end
RSpec.describe "ActionMailbox matchers", skip: !RSpec::Rails::Fe... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/relation_match_array_spec.rb | spec/rspec/rails/matchers/relation_match_array_spec.rb | RSpec.describe "ActiveSupport::Relation match_array matcher" do
before { MockableModel.delete_all }
let!(:models) { Array.new(3) { MockableModel.create } }
it "verifies that the scope returns the records on the right hand side, regardless of order" do
expect(MockableModel.all).to match_array(models.reverse)... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/has_spec.rb | spec/rspec/rails/matchers/has_spec.rb | class CollectionOwner < ActiveRecord::Base
connection.execute <<-SQL
CREATE TABLE collection_owners (
id integer PRIMARY KEY AUTOINCREMENT
)
SQL
has_many :associated_items do
def has_some_quality?; true end
end
end
class AssociatedItem < ActiveRecord::Base
connection.execute <<-SQL
CREA... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/route_to_spec.rb | spec/rspec/rails/matchers/route_to_spec.rb | RSpec.describe "route_to" do
include RSpec::Rails::Matchers::RoutingMatchers
include RSpec::Rails::Matchers::RoutingMatchers::RouteHelpers
def assert_recognizes(*)
# no-op
end
it "provides a description" do
matcher = route_to("these" => "options")
matcher.matches?(get: "path")
description =... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/be_new_record_spec.rb | spec/rspec/rails/matchers/be_new_record_spec.rb | RSpec.describe "be_new_record" do
context "a new record" do
let(:record) { double('record', new_record?: true) }
it "passes" do
expect(record).to be_new_record
end
it "fails with custom failure message" do
expect {
expect(record).not_to be_new_record
}.to raise_exception(/e... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/have_enqueued_mail_spec.rb | spec/rspec/rails/matchers/have_enqueued_mail_spec.rb | require "rspec/rails/feature_check"
if RSpec::Rails::FeatureCheck.has_active_job?
require "action_mailer"
require "rspec/rails/matchers/have_enqueued_mail"
class GlobalIDArgument
include GlobalID::Identification
def id; 1; end
def to_global_id(options = {}); super(options.merge(app: 'rspec-rails'));... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/be_routable_spec.rb | spec/rspec/rails/matchers/be_routable_spec.rb | RSpec.describe "be_routable" do
include RSpec::Rails::Matchers::RoutingMatchers
attr_reader :routes
before { @routes = double("routes") }
it "provides a description" do
expect(be_routable.description).to eq("be routable")
end
context "with should" do
it "passes if routes recognize the path" do
... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/send_email_spec.rb | spec/rspec/rails/matchers/send_email_spec.rb | RSpec.describe "send_email" do
let(:mailer) do
Class.new(ActionMailer::Base) do
self.delivery_method = :test
def test_email
mail(
from: "from@example.com",
cc: "cc@example.com",
bcc: "bcc@example.com",
to: "to@example.com",
subject: "Test emai... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/be_valid_spec.rb | spec/rspec/rails/matchers/be_valid_spec.rb | require 'rspec/rails/matchers/be_valid'
RSpec.describe "be_valid matcher" do
class Post
include ActiveModel::Validations
attr_accessor :title
validates_presence_of :title
end
class Book
def valid?
false
end
def errors
['the spine is broken', 'the pages are dog-eared']
en... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/have_http_status_spec.rb | spec/rspec/rails/matchers/have_http_status_spec.rb | RSpec.describe "have_http_status" do
def create_response(opts = {})
ActionDispatch::TestResponse.new(opts.fetch(:status)).tap { |x|
x.request = ActionDispatch::Request.new({})
}
end
shared_examples_for "supports different response instances" do
context "given an ActionDispatch::Response" do
... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/be_a_new_spec.rb | spec/rspec/rails/matchers/be_a_new_spec.rb | RSpec.describe "be_a_new matcher" do
context "new record" do
let(:record) do
Class.new do
def new_record?; true; end
end.new
end
context "right class" do
it "passes" do
expect(record).to be_a_new(record.class)
end
end
context "wrong class" do
it "fails... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/active_job_spec.rb | spec/rspec/rails/matchers/active_job_spec.rb | require "rspec/rails/feature_check"
if RSpec::Rails::FeatureCheck.has_active_job?
require "rspec/rails/matchers/active_job"
class GlobalIdModel
include GlobalID::Identification
attr_reader :id
def self.find(id)
new(id)
end
def initialize(id)
@id = id
end
def ==(comparis... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/have_rendered_spec.rb | spec/rspec/rails/matchers/have_rendered_spec.rb | %w[have_rendered render_template].each do |template_expectation|
RSpec.describe template_expectation do
include RSpec::Rails::Matchers::RenderTemplate
let(:response) { ActionDispatch::TestResponse.new }
context "given a hash" do
def assert_template(*); end
it "delegates to assert_template" do... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/redirect_to_spec.rb | spec/rspec/rails/matchers/redirect_to_spec.rb | require "active_support"
require "active_support/test_case"
RSpec.describe "redirect_to" do
include RSpec::Rails::Matchers::RedirectTo
let(:response) { ActionDispatch::TestResponse.new }
context "with should" do
context "when assert_redirected_to passes" do
def assert_redirected_to(*); end
it ... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/action_cable/have_stream_spec.rb | spec/rspec/rails/matchers/action_cable/have_stream_spec.rb | require "rspec/rails/feature_check"
if RSpec::Rails::FeatureCheck.has_action_cable_testing?
class StreamModel < Struct.new(:id)
def to_gid_param
"StreamModel##{id}"
end
end
class StreamChannel < ActionCable::Channel::Base
def self.channel_name
"broadcast"
end
def subscribed
... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
rspec/rspec-rails | https://github.com/rspec/rspec-rails/blob/f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df/spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb | spec/rspec/rails/matchers/action_cable/have_broadcasted_to_spec.rb | require "rspec/rails/feature_check"
if RSpec::Rails::FeatureCheck.has_action_cable_testing?
require "rspec/rails/matchers/action_cable"
class CableGlobalIdModel
include GlobalID::Identification
attr_reader :id
def initialize(id)
@id = id
end
def to_global_id(_options = {})
@glob... | ruby | MIT | f16a1639b5c2af5cde1ad1682b5c7a4af7f7b3df | 2026-01-04T15:43:26.158415Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.