Sha256: 1b6bd89460fe47a671bef0dcd419c54ee17c9aa0021af0266014335fe10a1b28

Contents?: true

Size: 710 Bytes

Versions: 4

Compression:

Stored size: 710 Bytes

Contents

module RSpec
  module Matchers
    module DSL
      # Defines a custom matcher.
      # @see RSpec::Matchers
      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

      alias_method :matcher, :define

      if RSpec.respond_to?(:configure)
        RSpec.configure {|c| c.extend self}
      end
    end
  end
end

RSpec::Matchers.extend RSpec::Matchers::DSL

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rspec-expectations-2.99.2 lib/rspec/matchers/dsl.rb
rspec-expectations-2.99.1 lib/rspec/matchers/dsl.rb
rspec-expectations-2.99.0 lib/rspec/matchers/dsl.rb
rspec-expectations-2.99.0.rc1 lib/rspec/matchers/dsl.rb