Module: Spec::Matchers

Defined in:
merb-core/lib/merb-core/test/test_ext/rspec.rb

Defined Under Namespace

Classes: MatcherDSL

Class Method Summary (collapse)

Class Method Details

+ (Object) create(*names, &block)



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'merb-core/lib/merb-core/test/test_ext/rspec.rb', line 43

def self.create(*names, &block)
  @guid ||= 0
  Merb::Test::Matchers.module_eval do
    klass = Class.new(MatcherDSL) do
      def initialize(expected_value)
        @expected_value = expected_value
      end
    end
    klass.class_eval(&block)

    names.each do |name|
      define_method(name) do |*expected_value|
        # Avoid a warning for the form should foo.
        klass.new(expected_value && expected_value[0])
      end
    end
  end
end