Class: FlexMock::TestUnitFrameworkAdapter

Inherits:
Object
  • Object
show all
Includes:
Test::Unit::Assertions
Defined in:
lib/flexmock/test_unit_integration.rb

Overview

Adapter for adapting FlexMock to the Test::Unit framework.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTestUnitFrameworkAdapter

Returns a new instance of TestUnitFrameworkAdapter.



50
51
52
# File 'lib/flexmock/test_unit_integration.rb', line 50

def initialize
    @assertions = 0
end

Instance Attribute Details

#assertionsObject

Returns the value of attribute assertions.



48
49
50
# File 'lib/flexmock/test_unit_integration.rb', line 48

def assertions
  @assertions
end

Instance Method Details

#assertion_failed_errorObject



68
69
70
71
72
# File 'lib/flexmock/test_unit_integration.rb', line 68

def assertion_failed_error
  defined?(Test::Unit::AssertionFailedError) ?
    Test::Unit::AssertionFailedError :
    Minitest::Assertion
end

#check(msg, &block) ⇒ Object



64
65
66
# File 'lib/flexmock/test_unit_integration.rb', line 64

def check(msg, &block)
  make_assertion(msg, &block)
end

#check_failed_errorObject



74
75
76
# File 'lib/flexmock/test_unit_integration.rb', line 74

def check_failed_error
  assertion_failed_error
end

#make_assertion(msg, backtrace = caller, &block) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/flexmock/test_unit_integration.rb', line 54

def make_assertion(msg, backtrace = caller, &block)
  unless yield
    msg = msg.call if msg.is_a?(Proc)
    assert(false, msg)
  end
rescue assertion_failed_error => ex
  ex.message.sub!(/Expected block to return true value./,'')
  raise ex
end