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 |
|---|---|---|---|---|---|---|---|---|
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/shared_examples/numerical_submatcher.rb | spec/support/unit/shared_examples/numerical_submatcher.rb | shared_examples 'a numerical submatcher' do
it 'implements the with_message method' do
expect(subject).to respond_to(:with_message).with(1).arguments
end
it 'implements the matches? method' do
expect(subject).to respond_to(:matches?).with(1).arguments
end
it 'implements the failure_message method' d... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/shared_examples/set_session_or_flash.rb | spec/support/unit/shared_examples/set_session_or_flash.rb | shared_examples_for 'set session or flash matcher' do
context 'without any qualifiers' do
it 'produces the right description' do
expected_description = "should set any key in #{store_name}"
matcher = set_store
expect(matcher.description).to eq expected_description
end
context 'in the p... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/model_creators/active_record.rb | spec/support/unit/model_creators/active_record.rb | require_relative '../model_creators'
require 'forwardable'
module UnitTests
module ModelCreators
class ActiveRecord
def self.call(args)
new(args).call
end
extend Forwardable
def_delegators(
:arguments,
:attribute_default_values_by_name,
:attribute_name,
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/model_creators/active_model.rb | spec/support/unit/model_creators/active_model.rb | require_relative '../model_creators'
require 'forwardable'
module UnitTests
module ModelCreators
class ActiveModel
def self.call(args)
new(args).call
end
extend Forwardable
def_delegators(
:arguments,
:attribute_name,
:attribute_default_values_by_name,
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/model_creators/basic.rb | spec/support/unit/model_creators/basic.rb | require 'forwardable'
module UnitTests
module ModelCreators
class Basic
def self.call(args)
new(args).call
end
extend Forwardable
def_delegators :arguments, :attribute_name, :model_name
def_delegators :model_creator, :customize_model
def initialize(arguments)
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/model_creators/active_record/has_and_belongs_to_many.rb | spec/support/unit/model_creators/active_record/has_and_belongs_to_many.rb | require_relative '../../model_creators'
require 'forwardable'
module UnitTests
module ModelCreators
class ActiveRecord
class HasAndBelongsToMany
def self.call(args)
new(args).call
end
extend Forwardable
def_delegators(
:arguments,
:attribute_n... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/model_creators/active_record/has_many.rb | spec/support/unit/model_creators/active_record/has_many.rb | require_relative '../../model_creators'
require 'forwardable'
module UnitTests
module ModelCreators
class ActiveRecord
class HasMany
def self.call(args)
new(args).call
end
extend Forwardable
def_delegators(
:arguments,
:attribute_name,
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/model_creators/active_record/uniqueness_matcher.rb | spec/support/unit/model_creators/active_record/uniqueness_matcher.rb | require_relative '../../model_creators'
require 'forwardable'
module UnitTests
module ModelCreators
class ActiveRecord
class UniquenessMatcher
def self.call(args)
new(args).call
end
extend Forwardable
def_delegators(
:arguments,
:attribute_nam... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/matchers/fail_with_message_including_matcher.rb | spec/support/unit/matchers/fail_with_message_including_matcher.rb | module UnitTests
module Matchers
extend RSpec::Matchers::DSL
matcher :fail_with_message_including do |expected|
def supports_block_expectations?
true
end
match do |block|
@actual = nil
begin
block.call
rescue RSpec::Expectations::ExpectationNotMet... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/matchers/fail_with_message_matcher.rb | spec/support/unit/matchers/fail_with_message_matcher.rb | module UnitTests
module Matchers
extend RSpec::Matchers::DSL
matcher :fail_with_message do |raw_expected, wrap: false|
expected =
if wrap
Shoulda::Matchers.word_wrap(raw_expected)
else
raw_expected
end
def supports_block_expectations?
true
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/matchers/match_against.rb | spec/support/unit/matchers/match_against.rb | module UnitTests
module Matchers
def match_against(object)
MatchAgainstMatcher.new(object)
end
class MatchAgainstMatcher
DIVIDER = ('-' * Shoulda::Matchers::WordWrap::TERMINAL_WIDTH).freeze
attr_reader :failure_message, :failure_message_when_negated
def initialize(object)
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/matchers/print_warning_including.rb | spec/support/unit/matchers/print_warning_including.rb | module UnitTests
module Matchers
def print_warning_including(expected_warning)
PrintWarningIncludingMatcher.new(expected_warning)
end
class PrintWarningIncludingMatcher
def initialize(expected_warning)
@expected_warning = collapse_whitespace(expected_warning)
end
def matc... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/matchers/deprecate.rb | spec/support/unit/matchers/deprecate.rb | module UnitTests
module Matchers
def deprecate(old_method, new_method)
DeprecateMatcher.new(old_method, new_method)
end
class DeprecateMatcher
def initialize(old_method, new_method)
@old_method = old_method
@new_method = new_method
end
def matches?(block)
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/active_record/create_table.rb | spec/support/unit/active_record/create_table.rb | require_relative '../helpers/active_record_versions'
require_relative '../helpers/database_helpers'
module UnitTests
module ActiveRecord
class CreateTable
def self.call(
table_name:,
columns:,
connection: ::ActiveRecord::Base.connection,
&block
)
new(
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/create_model_arguments/basic.rb | spec/support/unit/create_model_arguments/basic.rb | require 'forwardable'
module UnitTests
module CreateModelArguments
class Basic
DEFAULT_MODEL_NAME = 'Example'.freeze
DEFAULT_ATTRIBUTE_NAME = :attr
DEFAULT_COLUMN_TYPE = :string
def self.wrap(args)
if args.is_a?(self)
args
else
new(args)
end
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/create_model_arguments/has_many.rb | spec/support/unit/create_model_arguments/has_many.rb | module UnitTests
module CreateModelArguments
class HasMany < Basic
def columns
super.except(attribute_name)
end
private
def default_attribute_name
:children
end
end
end
end
| ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/support/unit/create_model_arguments/uniqueness_matcher.rb | spec/support/unit/create_model_arguments/uniqueness_matcher.rb | module UnitTests
module CreateModelArguments
class UniquenessMatcher < Basic
def self.normalize_attribute(attribute)
if attribute.is_a?(Hash)
Attribute.new(attribute)
else
Attribute.new(name: attribute)
end
end
def self.normalize_attributes(attributes... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/acceptance/active_record_integration_spec.rb | spec/acceptance/active_record_integration_spec.rb | require 'acceptance_spec_helper'
describe 'shoulda-matchers integrates with active record' do
before do
create_active_record_project
write_file 'Rakefile', <<-FILE
require 'active_record'
require 'sqlite3'
namespace :db do
desc 'Create the database'
task :create do
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/acceptance/active_model_integration_spec.rb | spec/acceptance/active_model_integration_spec.rb | require 'acceptance_spec_helper'
describe 'shoulda-matchers integrates with an ActiveModel project' do
before do
create_active_model_project
write_file 'lib/user.rb', <<-FILE
require 'active_model'
class User
include ActiveModel::Validations
attr_accessor :gender
valida... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/acceptance/rails_integration_spec.rb | spec/acceptance/rails_integration_spec.rb | require 'acceptance_spec_helper'
describe 'shoulda-matchers integrates with Rails' do
before do
create_rails_application
write_file 'db/migrate/1_create_defaults.rb', <<-FILE
class CreateDefaults < #{migration_class_name}
def self.up
create_table :action_text_rich_texts
cre... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/acceptance/independent_matchers_spec.rb | spec/acceptance/independent_matchers_spec.rb | require 'acceptance_spec_helper'
describe 'shoulda-matchers has independent matchers, specifically delegate_method' do
specify 'and integrates with a Ruby application that uses the default test framework' do
create_generic_bundler_project
updating_bundle do
add_minitest_to_project
add_shoulda_co... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/acceptance/multiple_libraries_integration_spec.rb | spec/acceptance/multiple_libraries_integration_spec.rb | require 'acceptance_spec_helper'
describe 'shoulda-matchers integrates with multiple libraries' do
before do
create_rails_application
write_file 'db/migrate/1_create_users.rb', <<-FILE
class CreateUsers < #{migration_class_name}
def self.up
create_table :users do |t|
t.st... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/doublespeak_spec.rb | spec/unit/shoulda/matchers/doublespeak_spec.rb | require 'doublespeak_spec_helper'
module Shoulda::Matchers
describe Doublespeak do
describe '.double_collection_for' do
it 'delegates to its world' do
allow(Doublespeak.world).to receive(:double_collection_for)
described_class.double_collection_for(:klass)
expect(Doublespeak.world... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/util/word_wrap_spec.rb | spec/unit/shoulda/matchers/util/word_wrap_spec.rb | require 'spec_helper'
require 'shoulda/matchers/util/word_wrap'
describe Shoulda::Matchers, '.word_wrap' do
it 'can wrap a simple paragraph' do
wrapped_message = described_class.word_wrap(<<-MESSAGE.rstrip)
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean luctus, ipsum sit amet efficitur feugiat
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/routing/route_matcher_spec.rb | spec/unit/shoulda/matchers/routing/route_matcher_spec.rb | require 'unit_spec_helper'
describe 'Shoulda::Matchers::Routing::RouteMatcher', type: :routing do
shared_examples_for 'core tests' do
context 'when the given method, path, controller, and action match an existing route' do
it 'accepts' do
define_controller_and_routes(
method: :get,
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/doublespeak/object_double_spec.rb | spec/unit/shoulda/matchers/doublespeak/object_double_spec.rb | require 'doublespeak_spec_helper'
module Shoulda::Matchers::Doublespeak
describe ObjectDouble do
it 'responds to any method' do
double = described_class.new
expect(double.respond_to?(:foo)).to be true
expect(double.respond_to?(:bar)).to be true
expect(double.respond_to?(:baz)).to be true... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/doublespeak/proxy_implementation_spec.rb | spec/unit/shoulda/matchers/doublespeak/proxy_implementation_spec.rb | require 'doublespeak_spec_helper'
module Shoulda::Matchers::Doublespeak
describe ProxyImplementation do
describe '#returns' do
it 'delegates to its stub_implementation' do
stub_implementation = build_stub_implementation
implementation = described_class.new(stub_implementation)
imple... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/doublespeak/double_spec.rb | spec/unit/shoulda/matchers/doublespeak/double_spec.rb | require 'doublespeak_spec_helper'
module Shoulda::Matchers::Doublespeak
describe Double do
describe 'initializer' do
context 'if doubles are currently activated on the world level' do
it 'immediately activates the new Double' do
world = build_world(doubles_activated?: true)
klas... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/doublespeak/stub_implementation_spec.rb | spec/unit/shoulda/matchers/doublespeak/stub_implementation_spec.rb | require 'doublespeak_spec_helper'
module Shoulda::Matchers::Doublespeak
describe StubImplementation do
describe '#call' do
it 'calls #record_call on the double' do
implementation = described_class.new
double = build_double
call = build_call(double:)
allow(double).to receive... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/doublespeak/double_collection_spec.rb | spec/unit/shoulda/matchers/doublespeak/double_collection_spec.rb | require 'doublespeak_spec_helper'
module Shoulda::Matchers::Doublespeak
describe DoubleCollection do
describe '#register_stub' do
it 'calls DoubleImplementationRegistry.find correctly' do
allow(DoubleImplementationRegistry).to receive(:find)
double_collection = described_class.new(build_wor... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/doublespeak/world_spec.rb | spec/unit/shoulda/matchers/doublespeak/world_spec.rb | require 'doublespeak_spec_helper'
module Shoulda::Matchers::Doublespeak
describe World do
describe '#double_collection_for' do
it 'calls DoubleCollection.new once with the given class' do
allow(DoubleCollection).to receive(:new).and_return(:klass)
world = described_class.new
world.... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/doublespeak/double_implementation_registry_spec.rb | spec/unit/shoulda/matchers/doublespeak/double_implementation_registry_spec.rb | require 'doublespeak_spec_helper'
module Shoulda::Matchers::Doublespeak
describe DoubleImplementationRegistry do
describe '.find' do
it 'returns an instance of StubImplementation if given :stub' do
expect(described_class.find(:stub)).to be_a(StubImplementation)
end
it 'returns ProxyImp... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/independent/delegate_method_matcher_spec.rb | spec/unit/shoulda/matchers/independent/delegate_method_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::Independent::DelegateMethodMatcher do
describe '#description' do
context 'when the subject is an instance' do
subject { Object.new }
context 'without any qualifiers' do
it 'states that it should delegate method to the right object' do
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb | spec/unit/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidateAbsenceOfMatcher, type: :model do
def self.available_column_types
[
:string,
:text,
:integer,
:float,
:decimal,
:datetime,
:timestamp,
:time,
:date,
:binary,
:uuid,
]
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb | spec/unit/shoulda/matchers/active_model/allow_value_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel, type: :model do
describe '#allow_values' do
it 'is aliased to #allow_value' do
expect(method(:allow_values)).to eq(method(:allow_value))
end
end
end
describe Shoulda::Matchers::ActiveModel::AllowValueMatcher, type: :model do
conte... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_model/validate_length_of_matcher_spec.rb | spec/unit/shoulda/matchers/active_model/validate_length_of_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidateLengthOfMatcher, type: :model do
context 'an attribute with a non-zero minimum length validation' do
it 'accepts ensuring the correct minimum length' do
expect(validating_length(minimum: 4)).
to validate_length_of(:attr).is... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | true |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb | spec/unit/shoulda/matchers/active_model/validate_exclusion_of_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidateExclusionOfMatcher, type: :model do
context 'an attribute which must be excluded from a range' do
it 'accepts ensuring the correct range' do
expect(validating_exclusion(in: 2..5)).
to validate_exclusion_of(:attr).in_range(2... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb | spec/unit/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidateAcceptanceOfMatcher, type: :model do
context 'a model with an acceptance validation' do
it 'accepts when the attributes match' do
expect(record_validating_acceptance).to matcher
end
it 'does not overwrite the default messa... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb | spec/unit/shoulda/matchers/active_model/validate_inclusion_of_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :model do
shared_context 'for a generic attribute' do
context 'against an integer attribute' do
it_behaves_like 'it supports in_array',
possible_values: (1..5).to_a,
zero: 0,
reserv... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | true |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb | spec/unit/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidateConfirmationOfMatcher, type: :model do
include UnitTests::ConfirmationMatcherHelpers
context '#description' do
it 'states that the confirmation must match its base attribute' do
builder = builder_for_record_validating_confirmati... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb | spec/unit/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidatePresenceOfMatcher, type: :model do
include UnitTests::ApplicationConfigurationHelpers
context 'a model with a presence validation' do
it 'accepts' do
expect(validating_presence).to matcher
end
it 'does not override the ... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | true |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_model/disallow_value_matcher_spec.rb | spec/unit/shoulda/matchers/active_model/disallow_value_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::DisallowValueMatcher, type: :model do
context 'an attribute with a format validation' do
it 'does not match if the value is allowed' do
expect(validating_format(with: /abc/)).not_to matcher('abcde').for(:attr)
end
it 'matches if t... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb | spec/unit/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidateNumericalityOfMatcher, type: :model do
class << self
def all_qualifiers # rubocop:disable Metrics/MethodLength
[
{
category: :comparison,
name: :is_greater_than,
argument: 1,
validati... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | true |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_model/helpers_spec.rb | spec/unit/shoulda/matchers/active_model/helpers_spec.rb | # encoding: UTF-8
require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::Helpers do
include Shoulda::Matchers::ActiveModel
after { I18n.backend.reload! }
describe 'default_error_message' do
context 'if the translation for the model attribute’s error exists' do
it 'provides the right erro... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_model/validate_comparison_of_matcher_spec.rb | spec/unit/shoulda/matchers/active_model/validate_comparison_of_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::ValidateComparisonOfMatcher, type: :model do
context 'with combinations of qualifiers together' do
context 'when the qualifiers do not match the validation options' do
specify 'such as validating greater_than_or_equal_to but testing that g... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | true |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_model/have_secure_password_matcher_spec.rb | spec/unit/shoulda/matchers/active_model/have_secure_password_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveModel::HaveSecurePasswordMatcher, type: :model do
context 'with no arguments passed to has_secure_password' do
it 'matches when the subject configures has_secure_password with default options' do
working_model = define_model(:example, password_di... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb | spec/unit/shoulda/matchers/action_controller/filter_param_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::FilterParamMatcher, type: :controller do
it 'accepts filtering a filtered parameter' do
filter(:secret)
expect(nil).to filter_param(:secret)
end
it 'accepts filtering a parameter matching a filtered regex' do
filter(/(?!tip)pi... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb | spec/unit/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RenderWithLayoutMatcher, type: :controller do
include ActionController::TemplateAssertions
context 'a controller that renders with a layout' do
it 'accepts rendering with any layout' do
expect(controller_with_wide_layout).to render... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb | spec/unit/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RedirectToMatcher, type: :controller do
context 'a controller that redirects' do
it 'accepts redirecting to that url' do
expect(controller_redirecting_to('/some/url')).to redirect_to('/some/url')
end
it 'rejects redirecting t... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb | spec/unit/shoulda/matchers/action_controller/respond_with_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RespondWithMatcher, type: :controller do
statuses = { success: 200, redirect: 301, missing: 404, error: 500,
not_implemented: 501, }
statuses.each do |human_name, numeric_code|
context "a controller responding with #{human... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/action_controller/set_session_or_flash_matcher_spec.rb | spec/unit/shoulda/matchers/action_controller/set_session_or_flash_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::SetSessionOrFlashMatcher do
context 'without any qualifiers' do
it 'produces the right description' do
store = build_store(name: 'flash')
matcher = described_class.new(store)
expected_description = 'should set any key in f... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/action_controller/set_session_matcher_spec.rb | spec/unit/shoulda/matchers/action_controller/set_session_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::SetSessionMatcher, type: :controller do
it_behaves_like 'set session or flash matcher' do
def store_name
'session'
end
def set_store
set_session
end
def store_within(controller)
controller.session
end... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/action_controller/permit_matcher_spec.rb | spec/unit/shoulda/matchers/action_controller/permit_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::PermitMatcher, type: :controller do
shared_examples 'basic tests' do
it 'accepts a subset of the permitted attributes' do
define_controller_with_strong_parameters(action: :create) do |ctrl|
params_with_conditional_require(ctrl... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/action_controller/route_matcher_spec.rb | spec/unit/shoulda/matchers/action_controller/route_matcher_spec.rb | require 'unit_spec_helper'
describe 'Shoulda::Matchers::ActionController::RouteMatcher', type: :controller do
shared_examples_for 'tests involving expected route parts' do |args|
include_controller_in_expected_route_options =
args.fetch(:include_controller_in_expected_route_options)
context 'when all ... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/action_controller/render_template_matcher_spec.rb | spec/unit/shoulda/matchers/action_controller/render_template_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RenderTemplateMatcher, type: :controller do
context 'a controller that renders a template' do
it 'accepts rendering that template' do
expect(controller_with_show).to render_template(:show)
end
it 'rejects rendering a differen... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/action_controller/set_flash_matcher_spec.rb | spec/unit/shoulda/matchers/action_controller/set_flash_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::SetFlashMatcher, type: :controller do
it_behaves_like 'set session or flash matcher' do
def store_name
'flash'
end
def set_store
set_flash
end
def store_within(controller)
controller.flash
end
end
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb | spec/unit/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RescueFromMatcher, type: :controller do
context 'a controller that rescues from RuntimeError' do
it 'asserts controller is setup with rescue_from' do
expect(controller_with_rescue_from).to rescue_from RuntimeError
end
context... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/action_controller/route_params_spec.rb | spec/unit/shoulda/matchers/action_controller/route_params_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::RouteParams, type: :controller do
describe '#normalize' do
context 'when the route parameters is a hash' do
it 'stringifies the values in the hash' do
expect(build_route_params(controller: :examples, action: 'example', id: '1'... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/action_controller/callback_matcher_spec.rb | spec/unit/shoulda/matchers/action_controller/callback_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActionController::CallbackMatcher, type: :controller do
shared_examples 'CallbackMatcher' do |kind, callback_type|
let(:kind) { kind }
let(:callback_type) { callback_type }
let(:method_name) { :authenticate_user! }
let(:matcher) { described_class... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/have_secure_token_matcher_spec.rb | spec/unit/shoulda/matchers/active_record/have_secure_token_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::HaveSecureTokenMatcher,
type: :model do
describe '#description' do
it 'returns the message including the name of the default column' do
matcher = have_secure_token
expect(matcher.description).
to eq('have :token as a secur... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/have_db_column_matcher_spec.rb | spec/unit/shoulda/matchers/active_record/have_db_column_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::HaveDbColumnMatcher, type: :model do
it 'accepts an existing database column' do
expect(model(nickname: :string)).to have_db_column(:nickname)
end
it 'rejects a nonexistent database column' do
expect(define_model(:employee).new).not_to... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/define_enum_for_matcher_spec.rb | spec/unit/shoulda/matchers/active_record/define_enum_for_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::DefineEnumForMatcher, type: :model do
context 'if the attribute is given in plural form accidentally' do
it 'rejects with an appropriate failure message' do
record = build_record_with_array_values(
model_name: 'Example',
a... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | true |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/have_attached_matcher_spec.rb | spec/unit/shoulda/matchers/active_record/have_attached_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::HaveAttachedMatcher, type: :model do
describe 'have_one_attached' do
describe '#description' do
it 'returns the message with the name of the association' do
matcher = have_one_attached(:avatar)
expect(matcher.description).... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/have_rich_text_matcher_spec.rb | spec/unit/shoulda/matchers/active_record/have_rich_text_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::HaveRichTextMatcher, type: :model do
def self.rich_text_is_defined?
defined?(ActionText::RichText)
end
def self.encrypted_rich_text_is_defined?
defined?(ActionText::EncryptedRichText)
end
context '#description' do
it 'returns ... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/encrypt_matcher_spec.rb | spec/unit/shoulda/matchers/active_record/encrypt_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::EncryptMatcher, type: :model do
context 'a encrypt attribute' do
it 'accepts' do
expect(with_encrypt_attr).to encrypt(:attr)
end
it 'rejects when used in the negative' do
assertion = lambda do
expect(with_encrypt_at... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb | spec/unit/shoulda/matchers/active_record/association_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::AssociationMatcher, type: :model do
include UnitTests::ApplicationConfigurationHelpers
context 'belong_to' do
it 'accepts a good association with the default foreign key' do
expect(belonging_to_parent).to belong_to(:parent)
end
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | true |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/serialize_matcher_spec.rb | spec/unit/shoulda/matchers/active_record/serialize_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::SerializeMatcher, type: :model do
it 'accepts when the attribute is serialized' do
expect(with_serialized_attr).to serialize(:attr)
end
context 'when attribute is not serialized' do
it 'rejects' do
expect(unserialized_model).not_... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb | spec/unit/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::AcceptNestedAttributesForMatcher, type: :model do
it 'accepts an existing declaration' do
expect(accepting_children).to accept_nested_attributes_for(:children)
end
it 'rejects a missing declaration' do
matcher = children_matcher
e... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb | spec/unit/shoulda/matchers/active_record/validate_uniqueness_of_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::ValidateUniquenessOfMatcher, type: :model do
shared_context 'it supports scoped attributes of a certain type' do |options = {}|
column_type = options.fetch(:column_type)
value_type = options.fetch(:value_type, column_type)
array = optio... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | true |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb | spec/unit/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::HaveReadonlyAttributeMatcher, type: :model do
context 'a read-only attribute' do
it 'accepts' do
expect(with_readonly_attr).to have_readonly_attribute(:attr)
end
end
context 'an attribute that is not part of the read-only set' do... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/have_db_index_matcher_spec.rb | spec/unit/shoulda/matchers/active_record/have_db_index_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::HaveDbIndexMatcher, type: :model do
describe 'the matcher' do
shared_examples 'for when the matcher is qualified' do |
index:,
other_index:,
unique:,
qualifier_args:,
columns: { index => :string }
|
if un... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/normalize_matcher_spec.rb | spec/unit/shoulda/matchers/active_record/normalize_matcher_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::NormalizeMatcher, type: :model do
if rails_version >= 7.1
describe '#description' do
it 'returns the message including the attribute names, from value and to value' do
matcher = normalize(:name, :email).from("jane doe\n").to('Jane... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/have_implicit_order_column_spec.rb | spec/unit/shoulda/matchers/active_record/have_implicit_order_column_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::HaveImplicitOrderColumnMatcher, type: :model do
context 'when the given column exists' do
context 'when an implicit_order_column is set on the model' do
context 'and it matches the given column name' do
context 'and the column nam... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/spec/unit/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb | spec/unit/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb | require 'unit_spec_helper'
describe Shoulda::Matchers::ActiveRecord::AssociationMatchers::ModelReflection do
it 'delegates other methods to the given Reflection object' do
define_model(:country)
person_model = define_model(:person, country_id: :integer) do
belongs_to :country
end
delegate_refle... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda-matchers.rb | lib/shoulda-matchers.rb | require 'shoulda/matchers'
| ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers.rb | lib/shoulda/matchers.rb | require 'shoulda/matchers/configuration'
require 'shoulda/matchers/doublespeak'
require 'shoulda/matchers/error'
require 'shoulda/matchers/independent'
require 'shoulda/matchers/integrations'
require 'shoulda/matchers/matcher_context'
require 'shoulda/matchers/rails_shim'
require 'shoulda/matchers/util'
require 'should... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/active_record.rb | lib/shoulda/matchers/active_record.rb | require 'shoulda/matchers/active_record/association_matcher'
require 'shoulda/matchers/active_record/association_matchers'
require 'shoulda/matchers/active_record/association_matchers/counter_cache_matcher'
require 'shoulda/matchers/active_record/association_matchers/inverse_of_matcher'
require 'shoulda/matchers/active... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/version.rb | lib/shoulda/matchers/version.rb | module Shoulda
module Matchers
# @private
VERSION = '7.0.1'.freeze
end
end
| ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/active_model.rb | lib/shoulda/matchers/active_model.rb | require 'shoulda/matchers/active_model/helpers'
require 'shoulda/matchers/active_model/qualifiers'
require 'shoulda/matchers/active_model/validation_matcher'
require 'shoulda/matchers/active_model/validation_matcher/build_description'
require 'shoulda/matchers/active_model/validator'
require 'shoulda/matchers/active_mo... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/routing.rb | lib/shoulda/matchers/routing.rb | module Shoulda
module Matchers
# @private
module Routing
def route(method, path, port: nil)
ActionController::RouteMatcher.new(self, method, path, port:)
end
end
end
end
| ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/doublespeak.rb | lib/shoulda/matchers/doublespeak.rb | require 'forwardable'
module Shoulda
module Matchers
# @private
module Doublespeak
class << self
extend Forwardable
def_delegators :world, :double_collection_for,
:with_doubles_activated
def world
@_world ||= World.new
end
def debugging_ena... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/independent.rb | lib/shoulda/matchers/independent.rb | require 'shoulda/matchers/independent/delegate_method_matcher'
require 'shoulda/matchers/independent/delegate_method_matcher/target_not_defined_error'
module Shoulda
module Matchers
# This module provides matchers that are used to test behavior outside of
# Rails-specific classes.
module Independent
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/integrations.rb | lib/shoulda/matchers/integrations.rb | module Shoulda
module Matchers
# @private
module Integrations
class << self
def register_library(klass, name)
library_registry.register(klass, name)
end
def find_library!(name)
library_registry.find!(name)
end
def register_test_framework(klas... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/configuration.rb | lib/shoulda/matchers/configuration.rb | module Shoulda
module Matchers
# @private
def self.configure
yield configuration
end
# @private
def self.integrations
configuration.integrations
end
# @private
def self.configuration
@_configuration ||= Configuration.new
end
# @private
class Configurati... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/action_controller.rb | lib/shoulda/matchers/action_controller.rb | require 'shoulda/matchers/action_controller/filter_param_matcher'
require 'shoulda/matchers/action_controller/route_params'
require 'shoulda/matchers/action_controller/set_flash_matcher'
require 'shoulda/matchers/action_controller/render_with_layout_matcher'
require 'shoulda/matchers/action_controller/respond_with_matc... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/error.rb | lib/shoulda/matchers/error.rb | module Shoulda
module Matchers
# @private
class Error < StandardError
def self.create(attributes)
allocate.tap do |error|
attributes.each do |name, value|
error.__send__("#{name}=", value)
end
error.__send__(:initialize)
end
end
def... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/warn.rb | lib/shoulda/matchers/warn.rb | module Shoulda
module Matchers
# @private
TERMINAL_MAX_WIDTH = 72
# @private
def self.warn(message)
header = 'Warning from shoulda-matchers:'
divider = '*' * TERMINAL_MAX_WIDTH
wrapped_message = word_wrap(message)
full_message = [
divider,
[header, wrapped_mess... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/matcher_context.rb | lib/shoulda/matchers/matcher_context.rb | module Shoulda
module Matchers
# @private
class MatcherContext
def initialize(context)
@context = context
end
def subject_is_a_class?
if inside_a_shoulda_context_project? && outside_a_should_block?
assume_that_subject_is_not_a_class
else
context.s... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/rails_shim.rb | lib/shoulda/matchers/rails_shim.rb | module Shoulda
module Matchers
# @private
module RailsShim
class << self
def action_pack_version
Gem::Version.new(::ActionPack::VERSION::STRING)
rescue NameError
Gem::Version.new('0')
end
def active_record_version
Gem::Version.new(::ActiveRe... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/util.rb | lib/shoulda/matchers/util.rb | require 'shoulda/matchers/util/word_wrap'
module Shoulda
module Matchers
# @private
module Util
MAXIMUM_LENGTH_OF_VALUE_TO_DISPLAY = 500
def self.deconstantize(path)
if defined?(ActiveSupport::Inflector) &&
ActiveSupport::Inflector.respond_to?(:deconstantize)
Active... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/util/word_wrap.rb | lib/shoulda/matchers/util/word_wrap.rb | module Shoulda
module Matchers
# @private
module WordWrap
TERMINAL_WIDTH = 72
def word_wrap(document, options = {})
Document.new(document, **options).wrap
end
end
extend WordWrap
# @private
class Document
def initialize(document, indent: 0)
@document ... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/integrations/rails.rb | lib/shoulda/matchers/integrations/rails.rb | module Shoulda
module Matchers
module Integrations
# @private
module Rails
def rails?
true
end
end
end
end
end
| ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/integrations/configuration_error.rb | lib/shoulda/matchers/integrations/configuration_error.rb | module Shoulda
module Matchers
module Integrations
# @private
class ConfigurationError < StandardError
end
end
end
end
| ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/integrations/registry.rb | lib/shoulda/matchers/integrations/registry.rb | module Shoulda
module Matchers
module Integrations
# @private
class Registry
def register(klass, name)
registry[name] = klass
end
def find!(name)
find_class!(name).new
end
private
def registry
@_registry ||= {}
en... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/integrations/libraries.rb | lib/shoulda/matchers/integrations/libraries.rb | require 'shoulda/matchers/integrations/libraries/action_controller'
require 'shoulda/matchers/integrations/libraries/active_model'
require 'shoulda/matchers/integrations/libraries/active_record'
require 'shoulda/matchers/integrations/libraries/missing_library'
require 'shoulda/matchers/integrations/libraries/rails'
req... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/integrations/configuration.rb | lib/shoulda/matchers/integrations/configuration.rb | module Shoulda
module Matchers
module Integrations
# @private
class Configuration
def self.apply(&block)
new(&block).apply
end
attr_reader :test_frameworks
def initialize(&block)
@test_frameworks = Set.new
@libraries = Set.new
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/integrations/inclusion.rb | lib/shoulda/matchers/integrations/inclusion.rb | module Shoulda
module Matchers
module Integrations
# @private
module Inclusion
def include_into(mod, *other_mods, &block)
mods_to_include = other_mods.dup
mods_to_extend = other_mods.dup
if block
mods_to_include << Module.new(&block)
end
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/integrations/test_frameworks.rb | lib/shoulda/matchers/integrations/test_frameworks.rb | require 'shoulda/matchers/integrations/test_frameworks/active_support_test_case'
require 'shoulda/matchers/integrations/test_frameworks/minitest_4'
require 'shoulda/matchers/integrations/test_frameworks/minitest_5'
require 'shoulda/matchers/integrations/test_frameworks/missing_test_framework'
require 'shoulda/matchers/... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/integrations/test_frameworks/test_unit.rb | lib/shoulda/matchers/integrations/test_frameworks/test_unit.rb | module Shoulda
module Matchers
module Integrations
module TestFrameworks
# @private
class TestUnit
Integrations.register_test_framework(self, :test_unit)
def validate!
end
def include(*modules, **_options)
test_case_class.class_eval do
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/integrations/test_frameworks/minitest_5.rb | lib/shoulda/matchers/integrations/test_frameworks/minitest_5.rb | module Shoulda
module Matchers
module Integrations
module TestFrameworks
# @private
class Minitest5
Integrations.register_test_framework(self, :minitest_5)
Integrations.register_test_framework(self, :minitest)
def validate!
end
def include(... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.