dchelimsky at gmail.com
Sun Mar 14 16:11:30 EDT 2010
On Mar 14, 2010, at 2:20 PM, barunio wrote:
> I'm trying to use RSpec to test some screen-scraping code. Because I
> don't want to hit external websites for my tests, I'm stubbing out the
> html I expect to receive, and trying to focus my tests on making sure
> the code is parsing the html correctly, and submitting the correct
> values when requesting external pages.
> However, I'm running into a problem. The following code causes RSpec
> to raise a "Spec::Mocks::AmbiguousReturnError" exception:
> @agent.should_receive(:submit) do |form, form_button|
> form.class.should == Mechanize::Form
> form.username.should == 'username'
> form.password.should == 'password'
When you pass a block to should_receive or stub, rspec wants to return the value returned by the block:
@agent.should_receive(:submit) do |form, form_button|
form.class.should == Mechanize::Form
form.username.should == 'username'
form.password.should == 'password'
> Am I doing something incorrectly here, or is the problem just that
> RSpec doesn't like for explicit return values to be specified when a
> block is supplied to the message expectation? If it is the latter,
> what would be the recommendation for how to appropriately write this
More information about the rspec-users