Skip to content

Commit

Permalink
Merge pull request #14 from ridiculous/spec-for-after_exception
Browse files Browse the repository at this point in the history
Add spec for testing exception logging
  • Loading branch information
ridiculous authored Sep 16, 2016
2 parents b8b892e + 1fa4272 commit ad6116e
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 ad6116e

Please sign in to comment.