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
|
||||
describe CLI do
|
||||
include ExitHelpers
|
||||
include FixturesHelpers
|
||||
|
||||
let(:recipe_file) { fixture_path_for('recipes/empty.rb') }
|
||||
@ -45,10 +46,7 @@ module Producer::Core
|
||||
end
|
||||
|
||||
it 'prints the usage' do
|
||||
begin
|
||||
cli.check_arguments!
|
||||
rescue SystemExit
|
||||
end
|
||||
trap_exit { cli.check_arguments! }
|
||||
expect(stdout.string).to match /\AUsage: .+/
|
||||
end
|
||||
end
|
||||
@ -89,11 +87,6 @@ module Producer::Core
|
||||
}
|
||||
end
|
||||
|
||||
def trap_exit
|
||||
yield
|
||||
rescue SystemExit
|
||||
end
|
||||
|
||||
it 'prints the specific error' do
|
||||
trap_exit { cli.evaluate_recipe_file }
|
||||
expect(stdout.string).to match(/
|
||||
|
@ -1,3 +1,4 @@
|
||||
require 'producer/core'
|
||||
|
||||
require 'support/exit_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