Files
grecia/spec/support/common_actions/remote_census_mock.rb
Javi Martín 4f232c3a25 Use the file_fixture helper in tests
This way we don't have to write `"spec/fixtures/files"` every time.

Note this method isn't included in factories. We could include it like
so:

```
FactoryBot::SyntaxRunner.class_eval do
  include ActiveSupport::Testing::FileFixtures
  self.file_fixture_path = RSpec.configuration.file_fixture_path
end
```

However, I'm not sure about the possible side effects, and since we only
use attachments in a few factories, there isn't much gain in applying
the monkey-patch.
2022-02-23 18:43:48 +01:00

31 lines
879 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(file_fixture("remote_census_api/valid.xml")))
end
def mock_invalid_remote_census_response
mock_remote_census_response(File.read(file_fixture("remote_census_api/invalid.xml")))
end
def mock_invalid_signature_sheet_remote_census_response
xml = File.read(file_fixture("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