[rspec-devel] confusion with rspec mocks
Dan North
dan at tastapod.com
Wed Aug 15 15:36:16 EDT 2007
Hi folks.
I'm nearly there with the initial cut of Spec::Story. I have one example
failing with an odd error from the rspec mock framework.
I moved #with from MessageExpectation into BaseExpectation so I could
stub!(:something).with(args). I have:
story_runner.stub!(:add_listener).with(an_instance_of(Reporter::PlainTextReporter))
...
story_runner.should_receive(:add_listener).with(an_instance_of(Documenter::PlainTextDocumenter))
The example fails with:
Mock 'scenario runner' expected :add_listener with (no args) but
received it with (#<Spec::Story::Reporter::PlainTextReporter:0xb777a83c
@pending=[], @succeeded=0, @failed=[], @out=#<IO:0xb77823c0>>)
./spec/spec/story/runner_spec.rb:61:
If I change the stub!(...) to should_receive(...) it fails with:
Mock 'story runner' expected :add_listener with (no args) once, but
received it 0 times
./spec/spec/story/runner_spec.rb:57:
In both cases it seems the args checking is being lost somewhere.
Can anyone shed any light?
Thanks,
Dan
More information about the rspec-devel
mailing list