Module: Handoff

Included in:
Test::Unit::TestCase
Defined in:
lib/handoff.rb,
lib/handoff/assertion.rb,
lib/handoff/usage_error.rb,
lib/handoff/argument_normalizer.rb

Overview

require (or require_gem) ‘handoff’ and #assert_handoff can be called from any Test::Unit::TestCase test method to create a new Handoff::Assertion.

After defining Handoff, this file includes it in Test::Unit::TestCase.

Defined Under Namespace

Modules: ArgumentNormalizer Classes: Assertion, UsageError

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



30
31
32
33
34
# File 'lib/handoff.rb', line 30

def self.included(base)
  base.class_eval do
    add_teardown_method :conduct_and_clear_handoffs
  end
end

Instance Method Details

#assert_handoffObject

Creates an Assertion, handing a it a mock named ‘handoff delegate’ on which expectations will be set.



12
13
14
15
16
# File 'lib/handoff.rb', line 12

def assert_handoff
  a = Handoff::Assertion.new(self.mock('handoff delegate'))
  handoff_assertions << a
  a
end

#conduct_and_clear_handoffsObject



22
23
24
25
26
27
28
# File 'lib/handoff.rb', line 22

def conduct_and_clear_handoffs
  begin
    handoff_assertions.each {|a| a.conduct }
  ensure
    handoff_assertions.clear
  end
end

#handoff_assertionsObject



18
19
20
# File 'lib/handoff.rb', line 18

def handoff_assertions
  @handoff_assertions ||= []
end