[rspec-users] AmbiguousReturnError

barunio barunio at gmail.com
Sun Mar 14 15:20:31 EDT 2010


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'
end.and_return(@bad_login_page)

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
spec?

Thanks.


More information about the rspec-users mailing list