Refactor trap_exit spec helper usages

This commit is contained in:
Thibault Jouan 2013-08-01 22:51:41 +00:00
parent c4fc9828db
commit c3737e738e
3 changed files with 9 additions and 9 deletions

View File

@ -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(/

View File

@ -1,3 +1,4 @@
require 'producer/core' require 'producer/core'
require 'support/exit_helpers'
require 'support/fixtures_helpers' require 'support/fixtures_helpers'

View File

@ -0,0 +1,6 @@
module ExitHelpers
def trap_exit
yield
rescue SystemExit
end
end