-
Notifications
You must be signed in to change notification settings - Fork 614
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using Savon mocks, cannot stub a request without a message. #402
Comments
thanks. i'll test that. |
i was a little confused by this as well, but as it turns out, there's actually a spec for it. |
I agree, I don't think you should always have to specify the message. In my use case, I don't care what's in the message, I care about the return. Other stubbing frameworks I've used stub the method but don't care about the message unless it's specified. My preference would be: # Message required and must match. (existing functionality.)
savon.expects(:find_user).with(:message => some_message).returns("<fixture/>")
# Message is ignored whether it exists or not
savon.expects(:find_user).returns("<fixture/>") But, maybe a way to fix it without breaking people's existing tests is something like this: # Message required and must match. (existing functionality.)
savon.expects(:find_user).with(:message => some_message).returns("<fixture/>")
# No message expected (existing functionality.)
savon.expects(:find_user).returns("<fixture/>")
# Some message required, but contents don't matter
savon.expects(:find_user).with(:message => :any).returns("<fixture/>") |
thanks for following up. that would certainly be an easy fix. i think i'm ok with that. |
Sure, but I'm not clear which fix you like, the (:message => :any) or changing the existing behavior so that the lack of a message will not result in an exception. |
oh sorry, i would go with the |
@jessegoodnoe any updates on this one? |
Previously, there was no way to create a mock without expectation of the specific message to be sent to the SOAP action. Contrary to the documentation, leaving out the `with` method would result in an expectation that the action be called without a message. This change adds a special case to `#with` so that calling `#with(message: :any)` ends up setting an expectation that the SOAP action be called, but without caring about the actual message sent to the action. This way the following will pass: savon.expects(:authenticate).with(message: :any) client.call(:authenticate) client.call(:authenticate, message: { username: "luke", password: "secret" })
Allow Savon mocks to receive any message. Closes #402
Per the documentation, I'd expect that I could stub a request without a message and with a return. But when there's an actual request that has a message, the expectation fails.
I would have thought that stubbing the request without a message would allow any message on the actual request.
From: http://savonrb.com/version2.html#options
Example
Here's an rspec example that illustrates what I'm trying to do. It can be put into spec/savon/mock_spec.rb.
The text was updated successfully, but these errors were encountered: