Last active
August 22, 2021 13:55
-
-
Save rezzzza/b3e22188ee27f3aed2b66e073c0ee59c to your computer and use it in GitHub Desktop.
Rspec and Savon2: writing test for SOAP Api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "spec_helper" | |
# require the helper module | |
require "savon/mock/spec_helper" | |
describe AuthenticationService do | |
# include the helper module | |
include Savon::SpecHelper | |
# set Savon in and out of mock mode | |
before(:all) { savon.mock! } | |
after(:all) { savon.unmock! } | |
describe "#authenticate" do | |
it "authenticates the user with the service" do | |
message = { username: "luke", password: "secret" } | |
fixture = File.read("spec/fixtures/authentication_service/authenticate.xml") | |
# set up an expectation | |
savon.expects(:authenticate).with(message: message).returns(fixture) | |
# call the service | |
service = AuthenticationService.new | |
response = service.authenticate(message) | |
expect(response).to be_successful | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment