spec/plaza/request_spec.rb in plaza-0.1.0 vs spec/plaza/request_spec.rb in plaza-0.1.1

- old
+ new

@@ -25,21 +25,31 @@ context 'when Thread.current[:x_user_id] is not set' do %i(get post put delete).each do |method| it "##{method} should now add X-User-Id to headers" do stub_request(method, "http://example.com/foobar"). - with(:headers => { - 'Accept'=>'application/json', - 'User-Agent'=>'Faraday v0.9.0'}). + with(:headers => {'Accept'=>'application/json'}). to_return(:status => 200, :body => "", :headers => {}) Request.new.send(method, '/foobar') end end end - context "when trucker service is down" do + context "when service is down" do + let(:request){ + exception = Faraday::Adapter::Test::Stubs.new do |stub| + %i(get put post delete).each do |method| + stub.send(method, '/failblog') {raise Faraday::Error::ConnectionFailed.new('Connection Failed')} + end + end + request = Request.new do |conn| + conn.adapter :test, exception + end + request + } + %i(get put post delete).each do |method| describe "#{method}" do before do stub_request(method, "http://example.com/failblog"). to_raise(Faraday::Error::ConnectionFailed.new('Connection Failed'))