mirror of
https://github.com/meineerde/rackstash.git
synced 2025-10-17 14:01:01 +00:00
Test sane behavior when trying to set fields or tags causing exception in Rack::Middleware
This commit is contained in:
parent
ce12e26bba
commit
58b58cfe4a
@ -137,6 +137,22 @@ describe Rackstash::Rack::Middleware do
|
|||||||
'method' => 'GET'
|
'method' => 'GET'
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'on merge errors' do
|
||||||
|
it 'raises an error' do
|
||||||
|
args[:request_fields] = ->(_request){ raise 'Oh No!' }
|
||||||
|
|
||||||
|
expect { get('/stuff') }.to raise_error RuntimeError, 'Oh No!'
|
||||||
|
expect(log.last).to include(
|
||||||
|
'path' => '/stuff',
|
||||||
|
'method' => 'GET',
|
||||||
|
'status' => 500,
|
||||||
|
'error' => 'RuntimeError',
|
||||||
|
'error_message' => 'Oh No!',
|
||||||
|
'error_trace' => %r{\A#{__FILE__}:#{__LINE__ - 9}:in}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with request_tags' do
|
context 'with request_tags' do
|
||||||
@ -148,6 +164,22 @@ describe Rackstash::Rack::Middleware do
|
|||||||
|
|
||||||
expect(log.last).to include('tags' => ['foo', 'STUFF'])
|
expect(log.last).to include('tags' => ['foo', 'STUFF'])
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'on merge errors' do
|
||||||
|
it 'raises an error' do
|
||||||
|
args[:request_tags] = ->(_request){ raise 'Oh No!' }
|
||||||
|
|
||||||
|
expect { get('/stuff') }.to raise_error RuntimeError, 'Oh No!'
|
||||||
|
expect(log.last).to include(
|
||||||
|
'path' => '/stuff',
|
||||||
|
'method' => 'GET',
|
||||||
|
'status' => 500,
|
||||||
|
'error' => 'RuntimeError',
|
||||||
|
'error_message' => 'Oh No!',
|
||||||
|
'error_trace' => %r{\A#{__FILE__}:#{__LINE__ - 9}:in}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with response fields' do
|
context 'with response fields' do
|
||||||
@ -172,6 +204,22 @@ describe Rackstash::Rack::Middleware do
|
|||||||
|
|
||||||
expect(log.last).to include 'path' => '/stuff'
|
expect(log.last).to include 'path' => '/stuff'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'on merge errors' do
|
||||||
|
it 'raises an error' do
|
||||||
|
args[:response_fields] = ->(_headers){ raise 'Oh No!' }
|
||||||
|
|
||||||
|
expect { get('/stuff') }.to raise_error RuntimeError, 'Oh No!'
|
||||||
|
expect(log.last).to include(
|
||||||
|
'path' => '/stuff',
|
||||||
|
'method' => 'GET',
|
||||||
|
'status' => 500,
|
||||||
|
'error' => 'RuntimeError',
|
||||||
|
'error_message' => 'Oh No!',
|
||||||
|
'error_trace' => %r{\A#{__FILE__}:#{__LINE__ - 9}:in}
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context 'with response_tags' do
|
context 'with response_tags' do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user