Refactor trap_exit spec helper usages
This commit is contained in:
parent
c4fc9828db
commit
c3737e738e
@ -2,6 +2,7 @@ require 'spec_helper'
|
|||||||
|
|
||||||
module Producer::Core
|
module Producer::Core
|
||||||
describe CLI do
|
describe CLI do
|
||||||
|
include ExitHelpers
|
||||||
include FixturesHelpers
|
include FixturesHelpers
|
||||||
|
|
||||||
let(:recipe_file) { fixture_path_for('recipes/empty.rb') }
|
let(:recipe_file) { fixture_path_for('recipes/empty.rb') }
|
||||||
@ -45,10 +46,7 @@ module Producer::Core
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'prints the usage' do
|
it 'prints the usage' do
|
||||||
begin
|
trap_exit { cli.check_arguments! }
|
||||||
cli.check_arguments!
|
|
||||||
rescue SystemExit
|
|
||||||
end
|
|
||||||
expect(stdout.string).to match /\AUsage: .+/
|
expect(stdout.string).to match /\AUsage: .+/
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -89,11 +87,6 @@ module Producer::Core
|
|||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def trap_exit
|
|
||||||
yield
|
|
||||||
rescue SystemExit
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'prints the specific error' do
|
it 'prints the specific error' do
|
||||||
trap_exit { cli.evaluate_recipe_file }
|
trap_exit { cli.evaluate_recipe_file }
|
||||||
expect(stdout.string).to match(/
|
expect(stdout.string).to match(/
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
require 'producer/core'
|
require 'producer/core'
|
||||||
|
|
||||||
|
require 'support/exit_helpers'
|
||||||
require 'support/fixtures_helpers'
|
require 'support/fixtures_helpers'
|
||||||
|
6
spec/support/exit_helpers.rb
Normal file
6
spec/support/exit_helpers.rb
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
module ExitHelpers
|
||||||
|
def trap_exit
|
||||||
|
yield
|
||||||
|
rescue SystemExit
|
||||||
|
end
|
||||||
|
end
|
Loading…
x
Reference in New Issue
Block a user