Skip to content

Instantly share code, notes, and snippets.

@rezzzza
Last active August 22, 2021 13:55
Show Gist options
  • Save rezzzza/b3e22188ee27f3aed2b66e073c0ee59c to your computer and use it in GitHub Desktop.
Save rezzzza/b3e22188ee27f3aed2b66e073c0ee59c to your computer and use it in GitHub Desktop.
Rspec and Savon2: writing test for SOAP Api
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