Module: Spec::Matchers

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

Defined Under Namespace

Classes: MatcherDSL

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(*names, &block) ⇒ Object



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'lib/merb-core/test/test_ext/rspec.rb', line 85

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

Instance Method Details

#failObject



19
20
21
# File 'lib/merb-core/test/test_ext/rspec.rb', line 19

def fail
  raise_error(Spec::Expectations::ExpectationNotMetError)
end

#fail_with(message) ⇒ Object



23
24
25
# File 'lib/merb-core/test/test_ext/rspec.rb', line 23

def fail_with(message)
  raise_error(Spec::Expectations::ExpectationNotMetError, message)
end