diff --git a/spec/producer/core/cli_spec.rb b/spec/producer/core/cli_spec.rb index e335027..19b813b 100644 --- a/spec/producer/core/cli_spec.rb +++ b/spec/producer/core/cli_spec.rb @@ -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(/ diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 2c06742..95f6163 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,3 +1,4 @@ require 'producer/core' +require 'support/exit_helpers' require 'support/fixtures_helpers' diff --git a/spec/support/exit_helpers.rb b/spec/support/exit_helpers.rb new file mode 100644 index 0000000..138f128 --- /dev/null +++ b/spec/support/exit_helpers.rb @@ -0,0 +1,6 @@ +module ExitHelpers + def trap_exit + yield + rescue SystemExit + end +end