Sha256: d45e50c8fe49977bb65398fe142679e84bd123ac8d0b00178bdc50cf7c62b564
Contents?: true
Size: 1.98 KB
Versions: 5
Compression:
Stored size: 1.98 KB
Contents
require 'spec_helper' module Justlogging class IgnoreMeError < StandardError end end class AppWithError def self.call(env) raise Justlogging::IgnoreMeError, 'the roof' end end describe Justlogging::Middleware do describe '#call' do let(:app) { stub(:call => true) } let(:env) { {'action_dispatch.request_id' => '1'} } let(:middleware) { Justlogging::Middleware.new(app, {})} let(:current) { stub(:complete! => true, :add_exception => true) } before { Justlogging::Transaction.stub(:current => current) } describe 'around call' do it 'should call justlogging transaction' do Justlogging::Transaction.should_receive(:create).with('1', env) end it 'should call complete! after the call' do current.should_receive(:complete!) end after { middleware.call(env) } end describe 'with exception' do let(:app) { AppWithError } it 'should re-raise the exception' do expect { middleware.call(env) }.to raise_error end it 'should catch the exception and notify the transaction of it' do Justlogging::ExceptionNotification.should_receive(:new) current.should_receive(:add_exception) middleware.call(env) rescue nil end context 'when ignoring exception' do before { Justlogging.stub(:config => {:ignore_exceptions => 'Justlogging::IgnoreMeError'})} it 'should re-raise the exception' do expect { middleware.call(env) }.to raise_error end it 'should ignore the error' do Justlogging::ExceptionNotification.should_not_receive(:new) current.should_not_receive(:add_exception) middleware.call(env) rescue nil end end describe 'after an error' do it 'should call complete! after the call' do current.should_receive(:complete!) end after { middleware.call(env) rescue nil } end end end end
Version data entries
5 entries across 5 versions & 1 rubygems