class RSpec::Matchers::DSL::Matcher
{RSpec::Matchers::DSL::Macros Macros} methods available.
of the singleton class of an instance, and will have the
`RSpec::Matchers.define` will be evaluated in the context
The class used for custom matchers. The block passed to
def actual_arg_for(block)
def actual_arg_for(block) block.arity.zero? ? [] : [@actual] end
def expected
- See: #expected_as_array -
def expected if expected_as_array.size == 1 expected_as_array[0] else expected_as_array end end
def initialize(name, declarations, matcher_execution_context, *expected, &block_arg)
- Api: - private
def initialize(name, declarations, matcher_execution_context, *expected, &block_arg) @name = name @actual = nil @expected_as_array = expected @matcher_execution_context = matcher_execution_context @chained_method_clauses = [] @block_arg = block_arg klass = class << self # See `Macros#define_user_override` above, for an explanation. include(@user_method_defs = Module.new) self end RSpec::Support::WithKeywordsWhenNeeded.class_exec(klass, *expected, &declarations) end
def inspect
so we can identify an instance of
Adds the name (rather than a cryptic hex number)
def inspect "#<#{self.class.name} #{name}>" end
def method_missing(method, *args, &block)
Rails' test helper methods, but it's also a useful
rspec-rails so that it can define matchers that wrap
running `RSpec::Core::Example`). This is needed by
`@matcher_execution_context` (typically the current
Takes care of forwarding unhandled messages to the
def method_missing(method, *args, &block) if @matcher_execution_context.respond_to?(method) @matcher_execution_context.__send__ method, *args, &block else super(method, *args, &block) end end
def respond_to?(method, include_private=false)
Indicates that this matcher responds to messages
:nocov:
for 1.8.7
def respond_to?(method, include_private=false) super || @matcher_execution_context.respond_to?(method, include_private) end
def respond_to_missing?(method, include_private=false)
from the `@matcher_execution_context` as well.
Indicates that this matcher responds to messages
def respond_to_missing?(method, include_private=false) super || @matcher_execution_context.respond_to?(method, include_private) end