-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
describe UberTask do | ||
before do | ||
described_class.instance_variable_set(:@logger, nil) | ||
end | ||
|
||
describe '.logger' do | ||
it 'memoizes variable' do | ||
initialized_logger = described_class.logger | ||
|
||
expect(described_class.logger.object_id).to eq( | ||
initialized_logger.object_id, | ||
) | ||
end | ||
|
||
context 'when Rails logger is not defined' do | ||
it 'uses stdout logger by default' do | ||
expect do | ||
described_class.logger.info('some message') | ||
end.to output(/some message/).to_stdout | ||
end | ||
end | ||
end | ||
|
||
describe '.logger=' do | ||
it 'changes logger' do | ||
old_logger = described_class.logger | ||
new_logger = Logger.new($stderr) | ||
|
||
described_class.logger = new_logger | ||
|
||
expect(described_class.logger).to eq(new_logger) | ||
expect(described_class.logger).not_to eq(old_logger) | ||
end | ||
end | ||
end |