diff options
author | lamont-granquist <lamont@scriptkiddie.org> | 2014-09-10 17:10:58 -0700 |
---|---|---|
committer | lamont-granquist <lamont@scriptkiddie.org> | 2014-09-10 17:10:58 -0700 |
commit | de47c1d65ffc7dc52a6d63a3b415dd23bdda31ae (patch) | |
tree | 81e5b02e12d4f41d9f8ab57073d3a0acb87287a8 | |
parent | d8fb8b09c7743d069046a6dafc0f46e65e9144c9 (diff) | |
parent | 131d5127a59685037ec1020511a26dd23f451e21 (diff) | |
download | chef-de47c1d65ffc7dc52a6d63a3b415dd23bdda31ae.tar.gz |
Merge pull request #2033 from opscode/lcg/1898
Rebase and ChangeLOG of pr/1898
-rw-r--r-- | CHANGELOG.md | 2 | ||||
-rw-r--r-- | lib/chef/application/apply.rb | 4 | ||||
-rw-r--r-- | spec/unit/application/apply.rb | 12 |
3 files changed, 17 insertions, 1 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 0344d0da83..edc52412e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Unreleased: 12.0.0 +* [**Nolan Davidson**](https://github.com/nsdavidson): + The chef-apply command now prints usage information when called without arguments * [**Kazuki Saito**](https://github.com/sakazuki): CHEF-4933: idempotency fixes for ifconfig provider * [**Kirill Shirinkin**](https://github.com/Fodoj): diff --git a/lib/chef/application/apply.rb b/lib/chef/application/apply.rb index ab35b35389..ea9154c6f2 100644 --- a/lib/chef/application/apply.rb +++ b/lib/chef/application/apply.rb @@ -134,6 +134,10 @@ class Chef::Application::Apply < Chef::Application @recipe_text = STDIN.read temp_recipe_file else + if !ARGV[0] + puts opt_parser + Chef::Application.exit! "No recipe file provided", 1 + end @recipe_filename = ARGV[0] @recipe_text,@recipe_fh = read_recipe_file @recipe_filename end diff --git a/spec/unit/application/apply.rb b/spec/unit/application/apply.rb index 32c98c6ed6..62a53c2a31 100644 --- a/spec/unit/application/apply.rb +++ b/spec/unit/application/apply.rb @@ -20,7 +20,7 @@ require 'spec_helper' describe Chef::Application::Apply do before do - @app = Chef::Application::Recipe.new + @app = Chef::Application::Apply.new @app.stub(:configure_logging).and_return(true) @recipe_text = "package 'nyancat'" Chef::Config[:solo] = true @@ -73,4 +73,14 @@ describe Chef::Application::Apply do @recipe_fh.path.should == @app.instance_variable_get(:@recipe_filename) end end + describe "recipe_file_arg" do + before do + ARGV.clear + end + it "should exit and log message" do + Chef::Log.should_receive(:debug).with(/^No recipe file provided/) + lambda { @app.run }.should raise_error(SystemExit) { |e| e.status.should == 1 } + end + + end end |