Fix CLI#evaluate_recipe_file spec:
The spec wasn't covering the case when recipe evaluation raises an unexpected error.
This commit is contained in:
parent
eaccf55581
commit
bd1bdba9cf
@ -80,26 +80,38 @@ module Producer::Core
|
|||||||
let(:stdout) { StringIO.new }
|
let(:stdout) { StringIO.new }
|
||||||
subject(:cli) { CLI.new(arguments, stdout) }
|
subject(:cli) { CLI.new(arguments, stdout) }
|
||||||
|
|
||||||
it 'exits with a return status of 70' do
|
context 'when error is known' do
|
||||||
expect { cli.evaluate_recipe_file }
|
it 'exits with a return status of 70' do
|
||||||
.to raise_error(SystemExit) { |e|
|
expect { cli.evaluate_recipe_file }
|
||||||
expect(e.status).to eq 70
|
.to raise_error(SystemExit) { |e|
|
||||||
}
|
expect(e.status).to eq 70
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'prints the specific error' do
|
||||||
|
trap_exit { cli.evaluate_recipe_file }
|
||||||
|
expect(stdout.string).to match(/
|
||||||
|
\A
|
||||||
|
#{recipe_file}:4:
|
||||||
|
.+
|
||||||
|
invalid\srecipe\skeyword\s`invalid_keyword'
|
||||||
|
/x)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'excludes producer own source code from the error backtrace' do
|
||||||
|
trap_exit { cli.evaluate_recipe_file }
|
||||||
|
expect(stdout.string).to_not match /\/producer-core\//
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'prints the specific error' do
|
context 'when error is unknown (unexpected)' do
|
||||||
trap_exit { cli.evaluate_recipe_file }
|
it 'lets the error be' do
|
||||||
expect(stdout.string).to match(/
|
UnexpectedError = Class.new(StandardError)
|
||||||
\A
|
recipe = double('recipe')
|
||||||
#{recipe_file}:4:
|
allow(Recipe).to receive(:from_file).and_return(recipe)
|
||||||
.+
|
allow(recipe).to receive(:evaluate).and_raise(UnexpectedError)
|
||||||
invalid\srecipe\skeyword\s`invalid_keyword'
|
expect { cli.evaluate_recipe_file }.to raise_error(UnexpectedError)
|
||||||
/x)
|
end
|
||||||
end
|
|
||||||
|
|
||||||
it 'excludes producer own source code from the error backtrace' do
|
|
||||||
trap_exit { cli.evaluate_recipe_file }
|
|
||||||
expect(stdout.string).to_not match /\/producer-core\//
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user