Help with flexmock (please :-)

Hi All

I suspect I am trying to misuse flexmock but I thought that I would ask
anyway.

Given the following 2 (somewhat contrived) test cases why does the
second
produce the error that follows:

require ‘flexmock’

class TestFlexMockPart2 < Test::Unit::TestCase

include FlexMock::TestCase

def test_no_repeats
mag_ocx = flexmock(‘mag_ocx’)
mag_ocx.should_receive(:Reset).ordered
mag_ocx.should_receive(:Adopt).with(‘Company’, ‘Default’).ordered
mag_ocx.should_receive(:Assign).with(‘SumAssured’, ‘250000’).ordered
mag_ocx.should_receive(:Underwrite).with(‘island_one’).ordered.returns
{true}
mag_ocx.Reset()
mag_ocx.Adopt(‘Company’, ‘Default’)
mag_ocx.Assign(‘SumAssured’, ‘250000’)
assert_equal(true, mag_ocx.Underwrite(‘island_one’))
end

def test_repeating_calls
#basically I want to check that Reset, Adopt and Reset are called in
order
mag_ocx = flexmock(‘mag_ocx’)
mag_ocx.should_receive(:Reset).ordered
mag_ocx.should_receive(:Adopt).with(‘Company’, ‘Default’).ordered
mag_ocx.should_receive(:Reset).ordered
mag_ocx.Reset()
mag_ocx.Adopt(‘Company’, ‘Default’)
mag_ocx.Reset()
end

end

Loaded suite C:/Documents and
Settings/TONYDAY/workspace/magnum_test_harness/test_flexmock_part_2
Started
.F
Finished in 0.0 seconds.

  1. Failure:
    test_repeating_calls(TestFlexMockPart2)
    [C:/ruby/lib/ruby/gems/1.8/gems/flexmock-0.3.2/lib/flexmock.rb:212:in
    check' C:/ruby/lib/ruby/gems/1.8/gems/flexmock-0.3.2/lib/flexmock.rb:479:invalidate_order’
    C:/ruby/lib/ruby/gems/1.8/gems/flexmock-0.3.2/lib/flexmock.rb:465:in
    verify_call' C:/ruby/lib/ruby/gems/1.8/gems/flexmock-0.3.2/lib/flexmock.rb:276:incall’
    C:/ruby/lib/ruby/gems/1.8/gems/flexmock-0.3.2/lib/flexmock.rb:104:in
    method_missing' C:/ruby/lib/ruby/gems/1.8/gems/flexmock-0.3.2/lib/flexmock.rb:221:inmock_wrap’
    C:/ruby/lib/ruby/gems/1.8/gems/flexmock-0.3.2/lib/flexmock.rb:101:in
    method_missing' C:/Documents and Settings/TONYDAY/workspace/magnum_test_harness/test_flexmock_part_2.rb:26 :intest_repeating_calls’]:
    in mock ‘mag_ocx’: method Reset(*args) called out of order (expected
    order
    1, was 2)

2 tests, 1 assertions, 1 failures, 0 errors

Is there something simple that I am doing wrong or am I just trying to
paint my ceiling with a goldfish (1).

Thanks

Regards, Tony

(1) - clumsy metaphor to indicate wrong tool for the job !!

Disclaimer
Sanlam Life Insurance Limited Reg no 1998/021121/06 - Licensed Financial
Services Provider
Disclaimer and Directors

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs