summaryrefslogtreecommitdiff
path: root/spec/unit/application
diff options
context:
space:
mode:
authorDavid Workman <workmad3@gmail.com>2014-09-03 23:49:36 +0100
committerDavid Workman <workmad3@gmail.com>2014-09-03 23:49:36 +0100
commit10621b23c26cd813cc8559d61105bf8be20e0c37 (patch)
treed98bd7f87d1e00ee4702ca01fba2342f1b038682 /spec/unit/application
parentf1de2a538ba8b89bdcb24de168db0b99cb0cc8fb (diff)
downloadchef-10621b23c26cd813cc8559d61105bf8be20e0c37.tar.gz
Fixing case of a nil recipe file with chef apply
Raising the error 'No recipe file was provided' with a fatal! call when the recipe_name is nil. This case occurs when chef-apply is called without a recipe name argument. Also renamed the apply spec file to apply_spec so it is picked up by an rspec test run. Fixed a typo in the file where it was creating a 'Chef::Application::Recipe' for @app instead of 'Chef::Application::Apply'
Diffstat (limited to 'spec/unit/application')
-rw-r--r--spec/unit/application/apply_spec.rb (renamed from spec/unit/application/apply.rb)13
1 files changed, 10 insertions, 3 deletions
diff --git a/spec/unit/application/apply.rb b/spec/unit/application/apply_spec.rb
index 32c98c6ed6..3f7fb851c2 100644
--- a/spec/unit/application/apply.rb
+++ b/spec/unit/application/apply_spec.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
@@ -41,18 +41,25 @@ describe Chef::Application::Apply do
File.stub(:exist?).with("foo.rb").and_return(true)
Chef::Application.stub(:fatal!).and_return(true)
end
+
it "should read text properly" do
@app.read_recipe_file(@recipe_file_name)[0].should == @recipe_text
end
it "should return a file_handle" do
@app.read_recipe_file(@recipe_file_name)[1].should be_instance_of(RSpec::Mocks::Mock)
end
+ describe "when recipe is nil" do
+ it "should raise a fatal with the missing filename message" do
+ Chef::Application.should_receive(:fatal!).with("No recipe file was provided", 1)
+ @app.read_recipe_file(nil)
+ end
+ end
describe "when recipe doesn't exist" do
before do
File.stub(:exist?).with(@recipe_file_name).and_return(false)
end
- it "should raise a fatal" do
- Chef::Application.should_receive(:fatal!)
+ it "should raise a fatal with the file doesn't exist message" do
+ Chef::Application.should_receive(:fatal!).with(/^No file exists at/, 1)
@app.read_recipe_file(@recipe_file_name)
end
end