Sha256: 915821f9c36222dde10c2ff1251944b7673c2cab004437f110fa0459f3473e34
Contents?: true
Size: 1.02 KB
Versions: 7
Compression:
Stored size: 1.02 KB
Contents
require 'spec_helper' describe Vx::Instrumentation::Rack::HandleExceptionsMiddleware do let(:env) { {} } let(:app) { ->(e){ e.merge(foo: :bar) } } let(:output) { StringIO.new } let(:middleware) { described_class.new(app) } let(:result) { output.rewind c = output.read if c.to_s != "" JSON.parse c end } before do Vx::Instrumentation::Logger.setup output end it "should work when no exceptions raised" do expect(middleware.call(env)).to eq(foo: :bar) expect(result).to be_nil end it "should catch raised exception" do app = ->(_) { raise RuntimeError, "Ignore Me" } mid = described_class.new(app) expect{ mid.call(env) }.to raise_error(RuntimeError, 'Ignore Me') expect(result["@tags"]).to eq ["handle_exception", "rack", "exception"] expect(result["@event"]).to eq 'handle_exception.rack' expect(result['exception']).to eq 'RuntimeError' expect(result['message']).to eq 'Ignore Me' expect(result['backtrace']).to_not be_empty end end
Version data entries
7 entries across 7 versions & 1 rubygems