Module: TestBelt::Should

Defined in:
lib/test_belt/should.rb

Instance Method Summary collapse

Instance Method Details

#should(matchers_or_desc, &block) ⇒ Object

Usage: class SomeTest < Test::Unit::TestCase

extend TestBelt::Should

end



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/test_belt/should.rb', line 14

def should(matchers_or_desc, &block)
  tests = should_tests(matchers_or_desc, &block)
  context = should_context

  each_should(context, tests) do |name, code|
    define_method(name) do
      begin
        self.class._testbelt_setups.each {|sb| instance_eval(&sb)}
        instance_eval(&code)
      ensure
        self.class._testbelt_teardowns.reverse.each {|tb| instance_eval(&tb)}
      end
    end
  end
end

#should_eventually(matchers_or_desc, &block) ⇒ Object

This method is identical to the should version, however this one does nothing but skip any tests described or matched on



32
33
34
35
36
37
38
39
# File 'lib/test_belt/should.rb', line 32

def should_eventually(matchers_or_desc, &block)
  tests = should_tests(matchers_or_desc, &block)
  context = should_context

  each_should(context, tests) do |name, code|
    define_method(name) { skip }
  end
end