Skip to content

Commit

Permalink
Stubbed the calls to set the logger on Delayed::Worker module.
Browse files Browse the repository at this point in the history
The class variable was leaking into other tests.
  • Loading branch information
bethesque committed Feb 13, 2015
1 parent fec3706 commit bc04b96
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions spec/delayed/command_spec.rb
Expand Up @@ -12,7 +12,8 @@
allow(Dir).to receive(:chdir)
allow(Logger).to receive(:new).and_return(logger)
allow_any_instance_of(Delayed::Worker).to receive(:start)
Delayed::Worker.logger = nil
allow(Delayed::Worker).to receive(:logger=)
allow(Delayed::Worker).to receive(:logger).and_return(nil, logger)
end

shared_examples_for 'uses --log-dir option' do
Expand All @@ -28,8 +29,8 @@

describe 'run' do
it 'sets the Delayed::Worker logger' do
expect(Delayed::Worker).to receive(:logger=).with(logger)
subject.run
expect(Delayed::Worker.logger).to be logger
end

context 'when Rails root is defined' do
Expand Down Expand Up @@ -67,11 +68,6 @@
subject.run
end

it 'sets the Delayed::Worker logger' do
subject.run
expect(Delayed::Worker.logger).to be logger
end

context 'when --log-dir is not specified' do
it 'creates the delayed_job.log in $PWD/log' do
expect(Logger).to receive(:new).with("#{Delayed::Command::DIR_PWD}/log/delayed_job.log")
Expand Down

0 comments on commit bc04b96

Please sign in to comment.