Connect to the service only when remote census endpoint is defined

Also return an invalid response when the endpoint is not defined.

This will allow to test remote web services on development environments.
This commit is contained in:
Senén Rodero Rodríguez
2020-10-30 12:25:30 +01:00
committed by Javi Martín
parent ac6260a2ef
commit 265f8dbf01
3 changed files with 12 additions and 3 deletions

View File

@@ -90,5 +90,13 @@ describe RemoteCensusApi do
api.call("1", "12345678Z", Date.parse("31/12/1980"), "28013")
end
end
it "returns an invalid response when endpoint is not defined" do
allow_any_instance_of(RemoteCensusApi).to receive(:end_point_defined?).and_return(false)
response = api.call("1", "12345678Z", Date.parse("01/01/1983"), "28013")
expect(response).not_to be_valid
end
end
end