mirror of
https://github.com/meineerde/rackstash.git
synced 2025-12-19 15:01:12 +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'
|
||||
)
|
||||
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
|
||||
|
||||
context 'with request_tags' do
|
||||
@ -148,6 +164,22 @@ describe Rackstash::Rack::Middleware do
|
||||
|
||||
expect(log.last).to include('tags' => ['foo', 'STUFF'])
|
||||
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
|
||||
|
||||
context 'with response fields' do
|
||||
@ -172,6 +204,22 @@ describe Rackstash::Rack::Middleware do
|
||||
|
||||
expect(log.last).to include 'path' => '/stuff'
|
||||
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
|
||||
|
||||
context 'with response_tags' do
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user