Module: Test::Unit::RR::Adapter

Includes:
RR::Adapters::RRMethods, RR::DSL
Included in:
TestCase
Defined in:
lib/test/unit/rr.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.resetObject



58
59
60
61
# File 'lib/test/unit/rr.rb', line 58

def reset
  ::RR.reset
  ::RR.trim_backtrace = true
end

Instance Method Details

#assert_received(subject, &block) ⇒ Object



64
65
66
# File 'lib/test/unit/rr.rb', line 64

def assert_received(subject, &block)
  block.call(received(subject)).call
end

#assert_rr { ... } ⇒ Object

Verify double declarations by RR in block. It is useful to clear your double declarations scope.

Examples:

Success case

subject = Object.new
assert_rr do
  mock(subject).should_be_called
  subject.should_be_called
end

Failure case

subject = Object.new
assert_rr do
  mock(subject).should_be_called
  # subject.should_be_called
end

Yields:

  • declares your doubles and uses the doubles in the block. The doubles are verified before and after the block is called.



88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/test/unit/rr.rb', line 88

def assert_rr
  begin
    ::RR.verify
  ensure
    ::Test::Unit::RR::Adapter.reset
  end
  result = yield
  begin
    ::RR.verify
  ensure
    ::Test::Unit::RR::Adapter.reset
  end
  result
end