From: Tony.Day@... Date: 2006-07-31T23:16:36+09:00 Subject: help with flexmock (please :-) --=_alternative 004E6576422571BC_= Content-Type: text/plain; charset="US-ASCII" 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:in `validate_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:in `call' 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:in `mock_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 :in `test_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 --=_alternative 004E6576422571BC_=--