Print a warning when in dry run mode
This commit is contained in:
@@ -113,8 +113,8 @@ module Producer::Core
|
||||
expect(output.string).to include 'some message'
|
||||
end
|
||||
|
||||
it 'has a log level of ERROR' do
|
||||
expect(env.logger.level).to eq Logger::ERROR
|
||||
it 'has a log level of WARN' do
|
||||
expect(env.logger.level).to eq Logger::WARN
|
||||
end
|
||||
|
||||
it 'uses our formatter' do
|
||||
@@ -135,6 +135,13 @@ module Producer::Core
|
||||
expect(env.logger).to receive(:info).with 'message'
|
||||
env.log 'message'
|
||||
end
|
||||
|
||||
context 'when second argument is :warn' do
|
||||
it 'logs a warning message through the assigned logger' do
|
||||
expect(env.logger).to receive(:warn).with 'message'
|
||||
env.log 'message', :warn
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#verbose?' do
|
||||
|
@@ -13,6 +13,14 @@ module Producer::Core
|
||||
it 'returns the given message with a line separator' do
|
||||
expect(subject).to eq "#{message}\n"
|
||||
end
|
||||
|
||||
context 'when severity is WARN' do
|
||||
let(:severity) { 'WARN' }
|
||||
|
||||
it 'prefix the message with `Warning:\'' do
|
||||
expect(subject).to match /\AWarning: #{message}/
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@@ -10,6 +10,18 @@ module Producer::Core
|
||||
expect(worker).to receive(:process_task).with(:some_task)
|
||||
worker.process [:some_task]
|
||||
end
|
||||
|
||||
context 'when dry run is enabled' do
|
||||
before { allow(env).to receive(:dry_run?) { true } }
|
||||
|
||||
it 'warns dry run is enabled' do
|
||||
expect(env).to receive(:log).with(
|
||||
/\Arunning in dry run mode, actions will NOT be applied\z/,
|
||||
:warn
|
||||
)
|
||||
worker.process []
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#process_task' do
|
||||
|
Reference in New Issue
Block a user