By using real XML responses developers will be able to understand better how the integration works (the data flow), and the correspondency between `remote_census` settings and their place at a real XML response. As `stubbed_responses` methods were removed from the model layer now the stubbing part should be managed from the test environment code so also added a new helper module `RemoteCensusSetup` that can be used anywhere where we need to call the web service. Co-Authored-By: Javi Martín <javim@elretirao.net>
31 lines
897 B
Ruby
31 lines
897 B
Ruby
require "savon/mock/spec_helper"
|
|
|
|
module RemoteCensusMock
|
|
include Savon::SpecHelper
|
|
include DocumentParser
|
|
|
|
def mock_valid_remote_census_response
|
|
mock_remote_census_response(File.read("spec/fixtures/files/remote_census_api/valid.xml"))
|
|
end
|
|
|
|
def mock_invalid_remote_census_response
|
|
mock_remote_census_response(File.read("spec/fixtures/files/remote_census_api/invalid.xml"))
|
|
end
|
|
|
|
def mock_invalid_signature_sheet_remote_census_response
|
|
xml = File.read("spec/fixtures/files/remote_census_api/invalid.xml")
|
|
|
|
Signature.new.document_types.each do |document_type|
|
|
get_document_number_variants(document_type, "12345678Z").each do
|
|
mock_remote_census_response(xml)
|
|
end
|
|
end
|
|
end
|
|
|
|
def mock_remote_census_response(xml)
|
|
savon.expects(Setting["remote_census.request.method_name"].to_sym)
|
|
.with(message: :any)
|
|
.returns(xml)
|
|
end
|
|
end
|