Skip to content

Instantly share code, notes, and snippets.

@corroded
Created March 4, 2018 20:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save corroded/0927a86ba7744c931825acf8c2bfde95 to your computer and use it in GitHub Desktop.
Save corroded/0927a86ba7744c931825acf8c2bfde95 to your computer and use it in GitHub Desktop.
RSpec.describe ApiCaller do
describe '#run' do
let(:route_builder_mock) { instance_double(RouteBuilder }
before do
allow(RouteBuilder).to receive(:new).and_return(route_builder_mock)
end
context 'route builder threw an error' do
before do
allow(route_builder_mock).to receive(:run).and_raise('some error')
end
# Do something
...
end
context 'route builder returned a proper url' do
before do
allow(route_builder_mock).to receive(:run).and_return('http://some.url.com')
end
# Do a different thing
...
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment