Sha256: 4b58b72889aeaa3b4b6792cbd8dae9ceb4018993a9294dae24c6653269c795be
Contents?: true
Size: 1.48 KB
Versions: 6
Compression:
Stored size: 1.48 KB
Contents
RSpec.describe Airbrake::Rack::RouteFilter do context "when there's no request object available" do it "doesn't add context/route" do notice = Airbrake.build_notice('oops') subject.call(notice) expect(notice[:context][:route]).to be_nil end end context "when Sinatra route is unavailable" do before { stub_const('Sinatra::Request', Class.new) } let(:notice) do notice = Airbrake.build_notice('oops') request_mock = instance_double(Sinatra::Request) expect(request_mock) .to receive(:instance_of?).with(Sinatra::Request).and_return(true) expect(request_mock).to receive(:env).and_return({}) notice.stash[:rack_request] = request_mock notice end it "doesn't add context/route" do subject.call(notice) expect(notice[:context][:route]).to be_nil end end context "when Sinatra route is available" do before { stub_const('Sinatra::Request', Class.new) } let(:notice) do notice = Airbrake.build_notice('oops') request_mock = instance_double(Sinatra::Request) expect(request_mock) .to receive(:instance_of?).with(Sinatra::Request).and_return(true) expect(request_mock) .to receive(:env).and_return('sinatra.route' => 'GET /test-route') notice.stash[:rack_request] = request_mock notice end it "doesn't add context/route" do subject.call(notice) expect(notice[:context][:route]).to eq('/test-route') end end end
Version data entries
6 entries across 6 versions & 1 rubygems