Module: RSpec::Matchers::DSL

Defined in:
lib/rspec/matchers/dsl.rb,
lib/rspec/matchers/matcher.rb

Defined Under Namespace

Classes: Matcher

Instance Method Summary (collapse)

Instance Method Details

- (Object) define(name) Also known as: matcher

Defines a custom matcher.

See Also:

6
7
8
9
10
11
12
13
14
# File 'lib/rspec/matchers/dsl.rb', line 6
def define(name, &declarations)
  matcher_template = RSpec::Matchers::DSL::Matcher.new(name, &declarations)
  define_method name do |*expected|
    matcher = matcher_template.for_expected(*expected)
    @matcher_execution_context ||= self
    matcher.instance_variable_set(:@matcher_execution_context, @matcher_execution_context)
    matcher
  end
end