Add specs to log overrider
This commit is contained in:
parent
434a4dab67
commit
e09b544f26
1 changed files with 40 additions and 5 deletions
|
|
@ -31,14 +31,49 @@ describe HomeController do
|
||||||
before do
|
before do
|
||||||
logger = FakeLogger.new
|
logger = FakeLogger.new
|
||||||
Rails.stub(:logger).and_return(FakeLogger.new)
|
Rails.stub(:logger).and_return(FakeLogger.new)
|
||||||
get :show
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'logs the routing of a request' do
|
context 'routing' do
|
||||||
Rails.logger.infos.first.include?('event=request_routed').should be_true
|
before do
|
||||||
|
get :show, :lasers => 'green'
|
||||||
|
@line = Rails.logger.infos.first
|
||||||
|
end
|
||||||
|
it 'logs the routing of a request' do
|
||||||
|
@line.include?('event=request_routed').should be_true
|
||||||
|
end
|
||||||
|
it 'logs the controller' do
|
||||||
|
@line.include?('controller=HomeController').should be_true
|
||||||
|
end
|
||||||
|
it 'logs the action' do
|
||||||
|
@line.include?('action=show').should be_true
|
||||||
|
end
|
||||||
|
it 'logs params' do
|
||||||
|
@line.include?("params='{\"lasers\"=>\"green\"}'").should be_true
|
||||||
|
end
|
||||||
end
|
end
|
||||||
it 'logs the completion of a request' do
|
context 'completion' do
|
||||||
Rails.logger.infos.last.include?('event=request_completed').should be_true
|
context 'ok' do
|
||||||
|
before do
|
||||||
|
get :show, :lasers => 'green'
|
||||||
|
@line = Rails.logger.infos.last
|
||||||
|
end
|
||||||
|
it 'logs the completion of a request' do
|
||||||
|
@line.include?('event=request_completed').should be_true
|
||||||
|
end
|
||||||
|
it 'logs an ok' do
|
||||||
|
@line.include?('status=200').should be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
context 'redirected' do
|
||||||
|
before do
|
||||||
|
sign_in @user
|
||||||
|
get :show, :lasers => 'green'
|
||||||
|
@line = Rails.logger.infos.last
|
||||||
|
end
|
||||||
|
it 'logs a redirect' do
|
||||||
|
@line.include?('status=302').should be_true
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class FakeLogger
|
class FakeLogger
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue