# Help with flexmock (please :-)

**URL:** <https://www.ruby-forum.com/t/help-with-flexmock-please/100712>\
**Category:** Ruby\
**Created:** [July 31, 2006, 4:18pm UTC](https://www.ruby-forum.com/t/help-with-flexmock-please/100712 "2006-07-31T16:18:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [July 31, 2006, 4:18pm UTC](https://www.ruby-forum.com/t/help-with-flexmock-please/100712/1 "2006-07-31T16:18:54Z")

</div>

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
