Skip to content

Commit

Permalink
Add spec for testing exception logging
Browse files Browse the repository at this point in the history
  • Loading branch information
ridiculous committed Sep 16, 2016
1 parent b8b892e commit 1fa4272
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions spec/integration/lib/grape/middleware/logger_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,22 @@
subject.call!(env)
end

context 'when an exception occurs' do
it 'logs all parts of the request including the error class' do
expect(subject.logger).to receive(:info).with ''
expect(subject.logger).to receive(:info).with %Q(Started POST "/api/1.0/users" at #{subject.start_time})
expect(subject.logger).to receive(:info).with %Q(Processing by TestAPI/users)
expect(subject.logger).to receive(:info).with %Q( Parameters: {"id"=>"101001", "secret"=>"[FILTERED]", "customer"=>[], "name"=>"foo", "password"=>"[FILTERED]"})
expect(subject.logger).to receive(:info).with %Q( ArgumentError: Whoops)
expect(subject.logger).to receive(:info).with /Completed 500 in \d+\.\d+ms/
expect(subject.logger).to receive(:info).with ''
expect(subject.app).to receive(:call).and_raise(ArgumentError, 'Whoops')
expect {
subject.call!(env)
}.to raise_error(ArgumentError)
end
end

describe 'the "processing by" section' do
before { subject.call!(env) }

Expand Down

0 comments on commit 1fa4272

Please sign in to comment.