Created
March 4, 2020 18:24
-
-
Save zben/bb04d7900114cd84da5027cc33431bb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe ExampleController, type: :controller do | |
describe '#show' do | |
context 'third party API returns 404' do | |
before do | |
stub_request(:get, "www.example.com"). | |
to_return(body: {error: "record not found"}.to_json, status: 404) | |
get :show | |
end | |
it 'returns 200' do | |
expect(response.status).to eq(200) | |
end | |
it 'returns correct error message' do | |
expect(JSON.parse(response.body)).to eq({"error" => "record_not_found"}) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment