Sha256: 39369ee671453909aad927ab4270c2c2b9976c145ff06a404eb7ae819db2f12b
Contents?: true
Size: 1.72 KB
Versions: 2
Compression:
Stored size: 1.72 KB
Contents
require 'spec_helper' require 'captivus/rack_capturer' describe Captivus::RackCapturer do describe "call" do before do @app = double 'app' @rack_capturer = Captivus::RackCapturer.new @app end def env_double(hash = {}) {'rack.input' => StringIO.new, 'QUERY_STRING' => ''}.merge(hash) end it "calls the app with the given env" do env = env_double result = double 'result' @app.stub(:call).with(env) { result } expect(@rack_capturer.call(env)).to eq result end context "when calling the app raises an error" do before { @app.stub(:call) { raise Exception, 'Error raised' } } context "when the env contains a query string" do it "tells Captivus to notify" do Captivus.should_receive(:notify).with kind_of(Exception), :context => {:params => {'username' => 'austin', 'password' => 'secret'}} begin @rack_capturer.call(env_double('QUERY_STRING' => 'username=austin&password=secret')) rescue Exception end end end context "when the env doesn't contain a query string" do it "tells Captivus to notify" do Captivus.should_receive(:notify).with kind_of(Exception), :context => {:params => {}} begin @rack_capturer.call(env_double) rescue Exception end end end it "raises the error" do expect { @rack_capturer.call(env_double) }.to raise_error Exception, "Error raised" end end it "does not notify the Captivus API when calling the app does not raise an error" do @app.stub :call @rack_capturer.call env_double expect(captivus_api.requests.size).to eq 0 end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
captivus-0.0.6 | spec/captivus/rack_capturer_spec.rb |
captivus-0.0.5 | spec/captivus/rack_capturer_spec.rb |