Use new RSpec stub syntax to fix deprecation warnings
This commit is contained in:
@@ -4,12 +4,16 @@ describe CensusCaller do
|
|||||||
let(:api) { described_class.new }
|
let(:api) { described_class.new }
|
||||||
|
|
||||||
describe '#call' do
|
describe '#call' do
|
||||||
it "returns data from local_census_records if census API is not available" do
|
it 'returns data from local_census_records if census API is not available' do
|
||||||
census_api_response = CensusApi::Response.new(get_habita_datos_response: {get_habita_datos_return: {datos_habitante: {}, datos_vivienda: {}}})
|
census_api_response = CensusApi::Response.new(get_habita_datos_response: {
|
||||||
|
get_habita_datos_return: { datos_habitante: {}, datos_vivienda: {} }
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
local_census_response = LocalCensus::Response.new(create(:local_census_record))
|
local_census_response = LocalCensus::Response.new(create(:local_census_record))
|
||||||
|
|
||||||
CensusApi.any_instance.stub(:call).and_return(census_api_response)
|
expect_any_instance_of(CensusApi).to receive(:call).and_return(census_api_response)
|
||||||
LocalCensus.any_instance.stub(:call).and_return(local_census_response)
|
expect_any_instance_of(LocalCensus).to receive(:call).and_return(local_census_response)
|
||||||
|
|
||||||
allow(CensusApi).to receive(:call).with(1, "12345678A")
|
allow(CensusApi).to receive(:call).with(1, "12345678A")
|
||||||
allow(LocalCensus).to receive(:call).with(1, "12345678A")
|
allow(LocalCensus).to receive(:call).with(1, "12345678A")
|
||||||
@@ -20,11 +24,16 @@ describe CensusCaller do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "returns data from census API if it's available and valid" do
|
it "returns data from census API if it's available and valid" do
|
||||||
census_api_response = CensusApi::Response.new(get_habita_datos_response: {get_habita_datos_return: {datos_habitante: {item: {fecha_nacimiento_string: "1-1-1980"}}}})
|
census_api_response = CensusApi::Response.new(get_habita_datos_response: {
|
||||||
|
get_habita_datos_return: {
|
||||||
|
datos_habitante: { item: { fecha_nacimiento_string: "1-1-1980" } }
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
local_census_response = LocalCensus::Response.new(create(:local_census_record))
|
local_census_response = LocalCensus::Response.new(create(:local_census_record))
|
||||||
|
|
||||||
CensusApi.any_instance.stub(:call).and_return(census_api_response)
|
expect_any_instance_of(CensusApi).to receive(:call).and_return(census_api_response)
|
||||||
LocalCensus.any_instance.stub(:call).and_return(local_census_response)
|
allow_any_instance_of(LocalCensus).to receive(:call).and_return(local_census_response)
|
||||||
|
|
||||||
allow(CensusApi).to receive(:call).with(1, "12345678A")
|
allow(CensusApi).to receive(:call).with(1, "12345678A")
|
||||||
allow(LocalCensus).to receive(:call).with(1, "12345678A")
|
allow(LocalCensus).to receive(:call).with(1, "12345678A")
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ shared_examples "document validations" do |documentable_factory|
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it "is not valid for attachments larger than documentable max_file_size definition" do
|
it 'is not valid for attachments larger than documentable max_file_size definition' do
|
||||||
document.stub(:attachment_file_size).and_return(maxfilesize.megabytes + 1.byte)
|
allow(document).to receive(:attachment_file_size).and_return(maxfilesize.megabytes + 1.byte)
|
||||||
max_size_error_message = "must be in between 0 Bytes and #{maxfilesize} MB"
|
max_size_error_message = "must be in between 0 Bytes and #{maxfilesize} MB"
|
||||||
|
|
||||||
expect(document).not_to be_valid
|
expect(document).not_to be_valid
|
||||||
|
|||||||
Reference in New Issue
Block a user