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/lib/shoulda/matchers/integrations/test_frameworks/active_support_test_case.rb | lib/shoulda/matchers/integrations/test_frameworks/active_support_test_case.rb | module Shoulda
module Matchers
module Integrations
module TestFrameworks
# @private
class ActiveSupportTestCase
Integrations.register_test_framework(self, :active_support_test_case)
def validate!
end
def include(*modules, **_options)
test... | 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_4.rb | lib/shoulda/matchers/integrations/test_frameworks/minitest_4.rb | module Shoulda
module Matchers
module Integrations
module TestFrameworks
# @private
class Minitest4
Integrations.register_test_framework(self, :minitest_4)
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/missing_test_framework.rb | lib/shoulda/matchers/integrations/test_frameworks/missing_test_framework.rb | module Shoulda
module Matchers
module Integrations
module TestFrameworks
# @private
class MissingTestFramework
Integrations.register_test_framework(self, :missing_test_framework)
def validate!
raise TestFrameworkNotConfigured, <<-EOT
You need to set a test fr... | 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/rspec.rb | lib/shoulda/matchers/integrations/test_frameworks/rspec.rb | module Shoulda
module Matchers
module Integrations
module TestFrameworks
# @private
class Rspec
Integrations.register_test_framework(self, :rspec)
def validate!
end
def include(*modules, **options)
::RSpec.configure do |config|
... | 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/active_record.rb | lib/shoulda/matchers/integrations/libraries/active_record.rb | module Shoulda
module Matchers
module Integrations
module Libraries
# @private
class ActiveRecord
Integrations.register_library(self, :active_record)
include Integrations::Inclusion
include Integrations::Rails
def integrate_with(test_framework)
... | 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/rails.rb | lib/shoulda/matchers/integrations/libraries/rails.rb | module Shoulda
module Matchers
module Integrations
module Libraries
# @private
class Rails
Integrations.register_library(self, :rails)
include Integrations::Rails
SUB_LIBRARIES = [
:active_model,
:active_record,
:action_cont... | 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/active_model.rb | lib/shoulda/matchers/integrations/libraries/active_model.rb | module Shoulda
module Matchers
module Integrations
module Libraries
# @private
class ActiveModel
Integrations.register_library(self, :active_model)
include Integrations::Inclusion
include Integrations::Rails
def integrate_with(test_framework)
... | 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/routing.rb | lib/shoulda/matchers/integrations/libraries/routing.rb | module Shoulda
module Matchers
module Integrations
module Libraries
# @private
class Routing
Integrations.register_library(self, :routing)
include Integrations::Inclusion
include Integrations::Rails
def integrate_with(test_framework)
test... | 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/missing_library.rb | lib/shoulda/matchers/integrations/libraries/missing_library.rb | module Shoulda
module Matchers
module Integrations
module Libraries
# @private
class MissingLibrary
Integrations.register_library(self, :missing_library)
def integrate_with(test_framework)
end
def rails?
false
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/libraries/action_controller.rb | lib/shoulda/matchers/integrations/libraries/action_controller.rb | module Shoulda
module Matchers
module Integrations
module Libraries
# @private
class ActionController
Integrations.register_library(self, :action_controller)
include Integrations::Inclusion
include Integrations::Rails
def integrate_with(test_framewor... | 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/double_implementation_registry.rb | lib/shoulda/matchers/doublespeak/double_implementation_registry.rb | module Shoulda
module Matchers
module Doublespeak
# @private
module DoubleImplementationRegistry
class << self
def find(type)
find_class!(type).create
end
def register(klass, type)
registry[type] = klass
end
private
... | 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/world.rb | lib/shoulda/matchers/doublespeak/world.rb | module Shoulda
module Matchers
module Doublespeak
# @private
class World
def initialize
@doubles_activated = false
end
def double_collection_for(klass)
double_collections_by_class[klass] ||=
DoubleCollection.new(self, klass)
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/method_call.rb | lib/shoulda/matchers/doublespeak/method_call.rb | module Shoulda
module Matchers
module Doublespeak
# @private
class MethodCall
attr_accessor :return_value
attr_reader :method_name, :args, :caller, :block, :object, :double
def initialize(args)
@method_name = args.fetch(:method_name)
@args = args.fetch(:arg... | 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/double_collection.rb | lib/shoulda/matchers/doublespeak/double_collection.rb | module Shoulda
module Matchers
module Doublespeak
# @private
class DoubleCollection
def initialize(world, klass)
@world = world
@klass = klass
@doubles_by_method_name = {}
end
def register_stub(method_name)
register_double(method_name, :... | 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/proxy_implementation.rb | lib/shoulda/matchers/doublespeak/proxy_implementation.rb | module Shoulda
module Matchers
module Doublespeak
# @private
class ProxyImplementation
extend Forwardable
DoubleImplementationRegistry.register(self, :proxy)
def_delegators :stub_implementation, :returns
def self.create
new(StubImplementation.new)
e... | 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/double.rb | lib/shoulda/matchers/doublespeak/double.rb | module Shoulda
module Matchers
module Doublespeak
# @private
class Double
attr_reader :calls
def initialize(world, klass, method_name, implementation)
@world = world
@klass = klass
@method_name = method_name
@implementation = implementation
... | 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/stub_implementation.rb | lib/shoulda/matchers/doublespeak/stub_implementation.rb | module Shoulda
module Matchers
module Doublespeak
# @private
class StubImplementation
DoubleImplementationRegistry.register(self, :stub)
def self.create
new
end
def initialize
@implementation = proc { nil }
end
def returns(value = ... | 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/object_double.rb | lib/shoulda/matchers/doublespeak/object_double.rb | module Shoulda
module Matchers
module Doublespeak
# @private
class ObjectDouble < BasicObject
attr_reader :calls
def initialize
@calls = []
@calls_by_method_name = {}
end
def calls_to(method_name)
@calls_by_method_name[method_name] || []
... | 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/delegate_method_matcher.rb | lib/shoulda/matchers/independent/delegate_method_matcher.rb | require 'shoulda/matchers/doublespeak'
require 'shoulda/matchers/matcher_context'
module Shoulda
module Matchers
module Independent
# The `delegate_method` matcher tests that an object forwards messages
# to other, internal objects by way of delegation.
#
# In this example, we test that C... | 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/delegate_method_matcher/target_not_defined_error.rb | lib/shoulda/matchers/independent/delegate_method_matcher/target_not_defined_error.rb | module Shoulda
module Matchers
module Independent
class DelegateMethodMatcher
# @private
class DelegateObjectNotSpecified < StandardError
def message
'Delegation needs a target. Use the #to method to define one, e.g.
`post_office.should delegate(:deliver_mai... | 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/qualifiers.rb | lib/shoulda/matchers/active_model/qualifiers.rb | module Shoulda
module Matchers
module ActiveModel
# @private
module Qualifiers
end
end
end
end
require_relative 'qualifiers/allow_nil'
require_relative 'qualifiers/allow_blank'
require_relative 'qualifiers/ignore_interference_by_writer'
require_relative 'qualifiers/ignoring_interference_b... | 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/validate_exclusion_of_matcher.rb | lib/shoulda/matchers/active_model/validate_exclusion_of_matcher.rb | module Shoulda
module Matchers
module ActiveModel
# The `validate_exclusion_of` matcher tests usage of the
# `validates_exclusion_of` validation, asserting that an attribute cannot
# take a blocklist of values, and inversely, can take values outside of
# this list.
#
# If your ... | 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/errors.rb | lib/shoulda/matchers/active_model/errors.rb | module Shoulda
module Matchers
module ActiveModel
# @private
class CouldNotDetermineValueOutsideOfArray < RuntimeError; end
# @private
class NonNullableBooleanError < Shoulda::Matchers::Error
def self.create(attribute)
super(attribute:)
end
attr_accessor... | 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/validate_absence_of_matcher.rb | lib/shoulda/matchers/active_model/validate_absence_of_matcher.rb | module Shoulda
module Matchers
module ActiveModel
# The `validate_absence_of` matcher tests the usage of the
# `validates_absence_of` validation.
#
# class PowerHungryCountry
# include ActiveModel::Model
# attr_accessor :nuclear_weapons
#
# val... | 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/validate_length_of_matcher.rb | lib/shoulda/matchers/active_model/validate_length_of_matcher.rb | module Shoulda
module Matchers
module ActiveModel
# The `validate_length_of` matcher tests usage of the
# `validates_length_of` matcher. Note that this matcher is intended to be
# used against string columns and associations and not integer columns.
#
# #### Qualifiers
#
... | 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/validation_message_finder.rb | lib/shoulda/matchers/active_model/validation_message_finder.rb | module Shoulda
module Matchers
module ActiveModel
# @private
class ValidationMessageFinder
include Helpers
def initialize(instance, attribute, context = nil)
@instance = instance
@attribute = attribute
@context = context
end
def allow_des... | 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/helpers.rb | lib/shoulda/matchers/active_model/helpers.rb | module Shoulda
module Matchers
module ActiveModel
# @private
module Helpers
def pretty_error_messages(object)
format_validation_errors(object.errors)
end
def format_validation_errors(errors)
list_items = errors.to_hash.keys.map do |attribute|
me... | 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/have_secure_password_matcher.rb | lib/shoulda/matchers/active_model/have_secure_password_matcher.rb | module Shoulda
module Matchers
module ActiveModel
# The `have_secure_password` matcher tests usage of the
# `has_secure_password` macro.
#
# #### Example
#
# class User
# include ActiveModel::Model
# include ActiveModel::SecurePassword
# ... | 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/validate_presence_of_matcher.rb | lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb | module Shoulda
module Matchers
module ActiveModel
# The `validate_presence_of` matcher tests usage of the
# `validates_presence_of` validation.
#
# class Robot
# include ActiveModel::Model
# attr_accessor :arms
#
# validates_presence_of :arms
... | 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/allow_value_matcher.rb | lib/shoulda/matchers/active_model/allow_value_matcher.rb | module Shoulda
module Matchers
module ActiveModel
# The `allow_value` matcher (or its alias, `allow_values`) is used to
# ensure that an attribute is valid or invalid if set to one or more
# values.
#
# Take this model for example:
#
# class UserProfile
# ... | 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/validate_comparison_of_matcher.rb | lib/shoulda/matchers/active_model/validate_comparison_of_matcher.rb | module Shoulda
module Matchers
module ActiveModel
# The `validate_comparison_of` matcher tests usage of the
# `validates_comparison_of` validation.
#
# class Person
# include ActiveModel::Model
# attr_accessor :gpa
#
# validates_comparison_of :... | 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/validate_inclusion_of_matcher.rb | lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb | require 'bigdecimal'
require 'date'
module Shoulda
module Matchers
# @private
class ExampleClass; end
module ActiveModel
# The `validate_inclusion_of` matcher tests usage of the
# `validates_inclusion_of` validation, asserting that an attribute can
# take a allowlist of values and cann... | 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/validator.rb | lib/shoulda/matchers/active_model/validator.rb | module Shoulda
module Matchers
module ActiveModel
# @private
class Validator
include Helpers
def initialize(record, attribute, options = {})
@record = record
@attribute = attribute
@context = options[:context]
@expects_strict = options[:expects_... | 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/numericality_matchers.rb | lib/shoulda/matchers/active_model/numericality_matchers.rb | module Shoulda
module Matchers
module ActiveModel
# @private
module NumericalityMatchers
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/active_model/validate_acceptance_of_matcher.rb | lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb | module Shoulda
module Matchers
module ActiveModel
# The `validate_acceptance_of` matcher tests usage of the
# `validates_acceptance_of` validation.
#
# class Registration
# include ActiveModel::Model
# attr_accessor :eula
#
# validates_acceptan... | 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/comparison_matcher.rb | lib/shoulda/matchers/active_model/comparison_matcher.rb | require 'active_support/core_ext/module/delegation'
module Shoulda
module Matchers
module ActiveModel
# @private
class ComparisonMatcher < ValidationMatcher
ERROR_MESSAGES = {
:> => {
label: :greater_than,
assertions: [false, false, true],
},
... | 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/validation_matcher.rb | lib/shoulda/matchers/active_model/validation_matcher.rb | module Shoulda
module Matchers
module ActiveModel
# @private
class ValidationMatcher
include Qualifiers::IgnoringInterferenceByWriter
def initialize(attribute)
super
@attribute = attribute
@options = {}
@expects_strict = false
@subject... | 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/validate_numericality_of_matcher.rb | lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb | module Shoulda
module Matchers
module ActiveModel
# The `validate_numericality_of` matcher tests usage of the
# `validates_numericality_of` validation.
#
# class Person
# include ActiveModel::Model
# attr_accessor :gpa
#
# validates_numericalit... | 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/validate_confirmation_of_matcher.rb | lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb | module Shoulda
module Matchers
module ActiveModel
# The `validate_confirmation_of` matcher tests usage of the
# `validates_confirmation_of` validation.
#
# class User
# include ActiveModel::Model
# attr_accessor :email
#
# validates_confirmatio... | 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/disallow_value_matcher.rb | lib/shoulda/matchers/active_model/disallow_value_matcher.rb | require 'forwardable'
module Shoulda
module Matchers
module ActiveModel
# @private
class DisallowValueMatcher
extend Forwardable
def_delegators(
:allow_matcher,
:_after_setting_value,
:attribute_changed_value_message=,
:attribute_to_set,
... | 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/validation_matcher/build_description.rb | lib/shoulda/matchers/active_model/validation_matcher/build_description.rb | module Shoulda
module Matchers
module ActiveModel
class ValidationMatcher
# @private
class BuildDescription
def self.call(matcher, main_description)
new(matcher, main_description).call
end
def initialize(matcher, main_description)
@match... | 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/allow_value_matcher/successful_check.rb | lib/shoulda/matchers/active_model/allow_value_matcher/successful_check.rb | module Shoulda
module Matchers
module ActiveModel
class AllowValueMatcher
# @private
class SuccessfulCheck
def successful?
true
end
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/active_model/allow_value_matcher/attribute_does_not_exist_error.rb | lib/shoulda/matchers/active_model/allow_value_matcher/attribute_does_not_exist_error.rb | module Shoulda
module Matchers
module ActiveModel
class AllowValueMatcher
# @private
class AttributeDoesNotExistError < Shoulda::Matchers::Error
attr_accessor :model, :attribute_name, :value
def message
Shoulda::Matchers.word_wrap <<-MESSAGE
The matcher attem... | 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/allow_value_matcher/attribute_setter_and_validator.rb | lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setter_and_validator.rb | require 'forwardable'
module Shoulda
module Matchers
module ActiveModel
class AllowValueMatcher
# @private
class AttributeSetterAndValidator
extend Forwardable
def_delegators(
:allow_value_matcher,
:after_setting_value_callback,
:attr... | 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/allow_value_matcher/successful_setting.rb | lib/shoulda/matchers/active_model/allow_value_matcher/successful_setting.rb | module Shoulda
module Matchers
module ActiveModel
class AllowValueMatcher
# @private
class SuccessfulSetting
def successful?
true
end
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/active_model/allow_value_matcher/attribute_changed_value_error.rb | lib/shoulda/matchers/active_model/allow_value_matcher/attribute_changed_value_error.rb | module Shoulda
module Matchers
module ActiveModel
class AllowValueMatcher
# @private
class AttributeChangedValueError < Shoulda::Matchers::Error
attr_accessor :matcher_name, :model, :attribute_name, :value_written,
:value_read
def message
Shoulda:... | 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/allow_value_matcher/attribute_setter.rb | lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setter.rb | module Shoulda
module Matchers
module ActiveModel
class AllowValueMatcher
# @private
class AttributeSetter
def self.set(args)
new(args).set
end
attr_reader(
:attribute_name,
:result_of_checking,
:result_of_setting... | 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/allow_value_matcher/attribute_setters_and_validators.rb | lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters_and_validators.rb | module Shoulda
module Matchers
module ActiveModel
class AllowValueMatcher
# @private
class AttributeSettersAndValidators
include Enumerable
def initialize(allow_value_matcher, values)
@tuples = values.map do |attribute_name, value|
AttributeSett... | 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/allow_value_matcher/attribute_setters.rb | lib/shoulda/matchers/active_model/allow_value_matcher/attribute_setters.rb | module Shoulda
module Matchers
module ActiveModel
class AllowValueMatcher
# @private
class AttributeSetters
include Enumerable
def initialize(allow_value_matcher, values)
@tuples = values.map do |attribute_name, value|
AttributeSetterAndValidato... | 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/numericality_matchers/even_number_matcher.rb | lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb | module Shoulda
module Matchers
module ActiveModel
module NumericalityMatchers
# @private
class EvenNumberMatcher < NumericTypeMatcher
NON_EVEN_NUMBER_VALUE = 1
def simple_description
description = ''
if expects_strict?
description <... | 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/numericality_matchers/submatchers.rb | lib/shoulda/matchers/active_model/numericality_matchers/submatchers.rb | module Shoulda
module Matchers
module ActiveModel
module NumericalityMatchers
# @private
class Submatchers
def initialize(submatchers)
@submatchers = submatchers
end
def matches?(subject)
@subject = subject
failing_submatcher... | 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/numericality_matchers/numeric_type_matcher.rb | lib/shoulda/matchers/active_model/numericality_matchers/numeric_type_matcher.rb | require 'forwardable'
module Shoulda
module Matchers
module ActiveModel
module NumericalityMatchers
# @private
class NumericTypeMatcher
extend Forwardable
def_delegators(
:disallow_value_matcher,
:expects_custom_validation_message?,
:... | 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/numericality_matchers/range_matcher.rb | lib/shoulda/matchers/active_model/numericality_matchers/range_matcher.rb | require 'active_support/core_ext/module/delegation'
module Shoulda
module Matchers
module ActiveModel
module NumericalityMatchers
# @private
class RangeMatcher < ValidationMatcher
OPERATORS = [:>=, :<=].freeze
delegate :failure_message, to: :submatchers
def i... | 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/numericality_matchers/odd_number_matcher.rb | lib/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher.rb | module Shoulda
module Matchers
module ActiveModel
module NumericalityMatchers
# @private
class OddNumberMatcher < NumericTypeMatcher
NON_ODD_NUMBER_VALUE = 2
def simple_description
description = ''
if expects_strict?
description << ... | 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/numericality_matchers/only_integer_matcher.rb | lib/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher.rb | module Shoulda
module Matchers
module ActiveModel
module NumericalityMatchers
# @private
class OnlyIntegerMatcher < NumericTypeMatcher
NON_INTEGER_VALUE = 0.1
def simple_description
description = ''
if expects_strict?
description <<... | 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/qualifiers/ignoring_interference_by_writer.rb | lib/shoulda/matchers/active_model/qualifiers/ignoring_interference_by_writer.rb | module Shoulda
module Matchers
module ActiveModel
module Qualifiers
# @private
module IgnoringInterferenceByWriter
attr_reader :ignore_interference_by_writer
def initialize(*)
@ignore_interference_by_writer = IgnoreInterferenceByWriter.new
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/qualifiers/allow_blank.rb | lib/shoulda/matchers/active_model/qualifiers/allow_blank.rb | module Shoulda
module Matchers
module ActiveModel
module Qualifiers
# @private
module AllowBlank
def initialize(*args)
super
@expects_to_allow_blank = false
end
def allow_blank
@expects_to_allow_blank = true
self
... | 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/qualifiers/allow_nil.rb | lib/shoulda/matchers/active_model/qualifiers/allow_nil.rb | module Shoulda
module Matchers
module ActiveModel
module Qualifiers
# @private
module AllowNil
def initialize(*args)
super
@expects_to_allow_nil = false
end
def allow_nil
@expects_to_allow_nil = true
self
... | 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/qualifiers/ignore_interference_by_writer.rb | lib/shoulda/matchers/active_model/qualifiers/ignore_interference_by_writer.rb | module Shoulda
module Matchers
module ActiveModel
module Qualifiers
# @private
class IgnoreInterferenceByWriter
attr_reader :setting, :condition
def initialize(argument = :always)
set(argument)
@changed = false
end
def set(arg... | 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/render_with_layout_matcher.rb | lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb | module Shoulda
module Matchers
module ActionController
# The `render_with_layout` matcher asserts that an action is rendered with
# a particular layout.
#
# class PostsController < ApplicationController
# def show
# render layout: 'posts'
# 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/action_controller/redirect_to_matcher.rb | lib/shoulda/matchers/action_controller/redirect_to_matcher.rb | module Shoulda
module Matchers
module ActionController
# The `redirect_to` matcher tests that an action redirects to a certain
# location. In a test suite using RSpec, it is very similar to
# rspec-rails's `redirect_to` matcher. In a test suite using Minitest +
# Shoulda, it provides a mor... | 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/render_template_matcher.rb | lib/shoulda/matchers/action_controller/render_template_matcher.rb | module Shoulda
module Matchers
module ActionController
# The `render_template` matcher tests that an action renders a template
# or partial. In RSpec, it is very similar to rspec-rails's
# `render_template` matcher. In a test suite using Minitest + Shoulda, it
# provides a more expressive ... | 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/session_store.rb | lib/shoulda/matchers/action_controller/session_store.rb | module Shoulda
module Matchers
module ActionController
# @private
class SessionStore
attr_accessor :controller
def name
'session'
end
def has_key?(key)
session.key?(key)
end
def has_value?(expected_value)
session.values.a... | 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/set_session_matcher.rb | lib/shoulda/matchers/action_controller/set_session_matcher.rb | require 'forwardable'
module Shoulda
module Matchers
module ActionController
# The `set_session` matcher is used to make assertions about the
# `session` hash.
#
# class PostsController < ApplicationController
# def index
# session[:foo] = 'A candy bar'
... | 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/route_params.rb | lib/shoulda/matchers/action_controller/route_params.rb | module Shoulda
module Matchers
module ActionController
# @private
class RouteParams
PARAMS_TO_SYMBOLIZE = %i{format}.freeze
def initialize(args)
@args = args
end
def normalize
if controller_and_action_given_as_string?
extract_params_fro... | 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/permit_matcher.rb | lib/shoulda/matchers/action_controller/permit_matcher.rb | require 'delegate'
begin
require 'strong_parameters'
rescue LoadError
end
require 'active_support/hash_with_indifferent_access'
module Shoulda
module Matchers
module ActionController
# The `permit` matcher tests that an action in your controller receives a
# allowlist of parameters using Rails' 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/action_controller/callback_matcher.rb | lib/shoulda/matchers/action_controller/callback_matcher.rb | module Shoulda
module Matchers
module ActionController
# The `use_before_action` matcher is used to test that a before_action
# callback is defined within your controller.
#
# class UsersController < ApplicationController
# before_action :authenticate_user!
# 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/action_controller/route_matcher.rb | lib/shoulda/matchers/action_controller/route_matcher.rb | module Shoulda
module Matchers
module ActionController
# The `route` matcher tests that a route resolves to a controller,
# action, and params; and that the controller, action, and params
# generates the same route. For an RSpec suite, this is like using a
# combination of `route_to` and `... | 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/set_flash_matcher.rb | lib/shoulda/matchers/action_controller/set_flash_matcher.rb | require 'forwardable'
module Shoulda
module Matchers
module ActionController
# The `set_flash` matcher is used to make assertions about the
# `flash` hash.
#
# class PostsController < ApplicationController
# def index
# flash[:foo] = 'A candy bar'
# ... | 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/flash_store.rb | lib/shoulda/matchers/action_controller/flash_store.rb | require 'active_support/core_ext/module/delegation'
module Shoulda
module Matchers
module ActionController
# @private
class FlashStore
def self.future
new
end
def self.now
new.use_now!
end
attr_accessor :controller
def initialize
... | 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/rescue_from_matcher.rb | lib/shoulda/matchers/action_controller/rescue_from_matcher.rb | module Shoulda
module Matchers
module ActionController
# The `rescue_from` matcher tests usage of the `rescue_from` macro. It
# asserts that an exception and method are present in the list of
# exception handlers, and that the handler method exists.
#
# class ApplicationControlle... | 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/filter_param_matcher.rb | lib/shoulda/matchers/action_controller/filter_param_matcher.rb | module Shoulda
module Matchers
module ActionController
# The `filter_param` matcher is used to test parameter filtering
# configuration. Specifically, it asserts that the given parameter is
# present in `config.filter_parameters`.
#
# class MyApplication < Rails::Application
... | 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/set_session_or_flash_matcher.rb | lib/shoulda/matchers/action_controller/set_session_or_flash_matcher.rb | module Shoulda
module Matchers
module ActionController
# @private
class SetSessionOrFlashMatcher
def initialize(store)
@store = store
end
def in_context(context)
@context = context
self
end
def [](key)
@key = key
... | 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/respond_with_matcher.rb | lib/shoulda/matchers/action_controller/respond_with_matcher.rb | module Shoulda
module Matchers
module ActionController
# The `respond_with` matcher tests that an action responds with a certain
# status code.
#
# You can specify that the status should be a number:
#
# class PostsController < ApplicationController
# def index
... | 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/have_db_column_matcher.rb | lib/shoulda/matchers/active_record/have_db_column_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
# The `have_db_column` matcher tests that the table that backs your model
# has a specific column.
#
# class CreatePhones < ActiveRecord::Migration
# def change
# create_table :phones do |t|
# ... | 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/association_matchers.rb | lib/shoulda/matchers/active_record/association_matchers.rb | module Shoulda
module Matchers
module ActiveRecord
# @private
module AssociationMatchers
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/active_record/accept_nested_attributes_for_matcher.rb | lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
# The `accept_nested_attributes_for` matcher tests usage of the
# `accepts_nested_attributes_for` macro.
#
# class Car < ActiveRecord::Base
# accepts_nested_attributes_for :doors
# end
#
# # RSpec
... | 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/have_rich_text_matcher.rb | lib/shoulda/matchers/active_record/have_rich_text_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
# The `have_rich_text` matcher tests usage of the
# `has_rich_text` macro.
#
# #### Example
#
# class Post < ActiveRecord
# has_rich_text :content
# end
#
# # RSpec
# RSpec.de... | 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/have_secure_token_matcher.rb | lib/shoulda/matchers/active_record/have_secure_token_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
# The `have_secure_token` matcher tests usage of the
# `has_secure_token` macro.
#
# class User < ActiveRecord
# has_secure_token
# has_secure_token :auth_token
# end
#
# # RSpec
... | 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/normalize_matcher.rb | lib/shoulda/matchers/active_record/normalize_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
# The `normalize` matcher is used to ensure attribute normalizations
# are transforming attribute values as expected.
#
# Take this model for example:
#
# class User < ActiveRecord::Base
# normalizes :email, wit... | 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/association_matcher.rb | lib/shoulda/matchers/active_record/association_matcher.rb | require 'active_support/core_ext/module/delegation'
module Shoulda
module Matchers
module ActiveRecord
# The `belong_to` matcher is used to ensure that a `belong_to` association
# exists on your model.
#
# class Person < ActiveRecord::Base
# belongs_to :organization
... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | true |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb | lib/shoulda/matchers/active_record/validate_uniqueness_of_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
# The `validate_uniqueness_of` matcher tests usage of the
# `validates_uniqueness_of` validation. It first checks for an existing
# instance of your model in the database, creating one if necessary. It
# then takes a new instance of that m... | ruby | MIT | c0b8352200b90642fef2edadfe0c4fb58f6ec0f8 | 2026-01-04T15:50:06.860443Z | true |
thoughtbot/shoulda-matchers | https://github.com/thoughtbot/shoulda-matchers/blob/c0b8352200b90642fef2edadfe0c4fb58f6ec0f8/lib/shoulda/matchers/active_record/have_attached_matcher.rb | lib/shoulda/matchers/active_record/have_attached_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
# The `have_one_attached` matcher tests usage of the
# `has_one_attached` macro.
#
# #### Example
#
# class User < ApplicationRecord
# has_one_attached :avatar
# end
#
# # RSpec
#... | 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/encrypt_matcher.rb | lib/shoulda/matchers/active_record/encrypt_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
# The `encrypt` matcher tests usage of the
# `encrypts` macro (Rails 7+ only).
#
# class Survey < ActiveRecord::Base
# encrypts :access_code
# end
#
# # RSpec
# RSpec.describe Survey, typ... | 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/have_db_index_matcher.rb | lib/shoulda/matchers/active_record/have_db_index_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
# The `have_db_index` matcher tests that the table that backs your model
# has a specific index.
#
# You can specify one column:
#
# class CreateBlogs < ActiveRecord::Migration
# def change
# creat... | 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/define_enum_for_matcher.rb | lib/shoulda/matchers/active_record/define_enum_for_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
# The `define_enum_for` matcher is used to test that the `enum` macro has
# been used to decorate an attribute with enum capabilities.
#
# class Process < ActiveRecord::Base
# enum status: [:running, :stopped, :suspended]
... | 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/serialize_matcher.rb | lib/shoulda/matchers/active_record/serialize_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
# The `serialize` matcher tests usage of the `serialize` macro.
#
# class Product < ActiveRecord::Base
# serialize :customizations
# end
#
# # RSpec
# RSpec.describe Product, type: :model 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/active_record/have_implicit_order_column.rb | lib/shoulda/matchers/active_record/have_implicit_order_column.rb | module Shoulda
module Matchers
module ActiveRecord
# The `have_implicit_order_column` matcher tests that the model has `implicit_order_column`
# assigned to one of the table columns.
#
# class Product < ApplicationRecord
# self.implicit_order_column = :created_at
# ... | 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/uniqueness.rb | lib/shoulda/matchers/active_record/uniqueness.rb | module Shoulda
module Matchers
module ActiveRecord
# @private
module Uniqueness
end
end
end
end
require 'shoulda/matchers/active_record/uniqueness/model'
require 'shoulda/matchers/active_record/uniqueness/namespace'
require 'shoulda/matchers/active_record/uniqueness/test_model_creator'
re... | 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/have_readonly_attribute_matcher.rb | lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
# The `have_readonly_attribute` matcher tests usage of the
# `attr_readonly` macro.
#
# class User < ActiveRecord::Base
# attr_readonly :password
# end
#
# # RSpec
# RSpec.describe User, ... | 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/uniqueness/test_model_creator.rb | lib/shoulda/matchers/active_record/uniqueness/test_model_creator.rb | module Shoulda
module Matchers
module ActiveRecord
# @private
module Uniqueness
# @private
class TestModelCreator
def self.create(model_name, namespace)
Mutex.new.synchronize do
new(model_name, namespace).create
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_record/uniqueness/test_models.rb | lib/shoulda/matchers/active_record/uniqueness/test_models.rb | module Shoulda
module Matchers
module ActiveRecord
# @private
module Uniqueness
# @private
module TestModels
def self.create(model_name)
TestModelCreator.create(model_name, root_namespace)
end
def self.remove_all
root_namespace.cle... | 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/uniqueness/namespace.rb | lib/shoulda/matchers/active_record/uniqueness/namespace.rb | module Shoulda
module Matchers
module ActiveRecord
# @private
module Uniqueness
# @private
class Namespace
def initialize(constant)
@constant = constant
end
def has?(name)
constant.const_defined?(name)
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/active_record/uniqueness/model.rb | lib/shoulda/matchers/active_record/uniqueness/model.rb | module Shoulda
module Matchers
module ActiveRecord
# @private
module Uniqueness
# @private
class Model
def self.next_unique_copy_of(model_name, namespace)
model = new(model_name, namespace)
while model.already_exists?
model = model.next
... | 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/association_matchers/source_matcher.rb | lib/shoulda/matchers/active_record/association_matchers/source_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
module AssociationMatchers
# @private
class SourceMatcher
attr_accessor :missing_option
def initialize(source, name)
@source = source
@name = name
@missing_option = ''
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_record/association_matchers/counter_cache_matcher.rb | lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
module AssociationMatchers
# @private
class CounterCacheMatcher
attr_accessor :missing_option
def initialize(counter_cache, name)
@counter_cache = counter_cache
@name = name
@missing_o... | 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/association_matchers/model_reflector.rb | lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb | module Shoulda
module Matchers
module ActiveRecord
module AssociationMatchers
# @private
class ModelReflector
delegate(
:associated_class,
:association_foreign_key,
:foreign_key,
:foreign_type,
:has_and_belongs_to_many_nam... | 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/association_matchers/join_table_matcher.rb | lib/shoulda/matchers/active_record/association_matchers/join_table_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
module AssociationMatchers
# @private
class JoinTableMatcher
attr_reader :failure_message
alias :missing_option :failure_message
delegate :model_class, :join_table_name, :associated_class, :options,
... | 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/association_matchers/order_matcher.rb | lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb | module Shoulda
module Matchers
module ActiveRecord
module AssociationMatchers
# @private
class OrderMatcher
attr_accessor :missing_option
def initialize(order, name)
@order = order
@name = name
@missing_option = ''
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_record/association_matchers/option_verifier.rb | lib/shoulda/matchers/active_record/association_matchers/option_verifier.rb | module Shoulda
module Matchers
module ActiveRecord
module AssociationMatchers
# @private
class OptionVerifier
delegate :reflection, to: :reflector
DEFAULT_VALUE_OF_OPTIONS = {
has_many: {
validate: true,
},
}.freeze
... | 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.