summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortyler-ball <tyleraball@gmail.com>2014-12-10 11:11:40 -0800
committertyler-ball <tyleraball@gmail.com>2014-12-10 11:11:40 -0800
commit5dd7ff3aa4005a5fc98d2ef6c3cfedc325870c17 (patch)
tree550c268f4dead75f4f66ec0f3984053657f543d2
parente7b78812aed1c1958fe1a263f1a448bba203bc3c (diff)
downloadchef-tball/output-integration.tar.gz
Adding simple integration test for audit mode outputtball/output-integration
-rw-r--r--spec/integration/client/client_spec.rb39
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/integration/client/client_spec.rb b/spec/integration/client/client_spec.rb
index f4bb124781..e961b73d0d 100644
--- a/spec/integration/client/client_spec.rb
+++ b/spec/integration/client/client_spec.rb
@@ -239,4 +239,43 @@ EOM
end
end
+
+ when_the_repository "has a cookbook with only an audit recipe" do
+
+ before do
+ file 'config/client.rb', <<EOM
+local_mode true
+cookbook_path "#{path_to('cookbooks')}"
+EOM
+ end
+
+ it "should exit with a zero code when there is not an audit failure" do
+ file 'cookbooks/audit_test/recipes/succeed.rb', <<-RECIPE
+controls "control group without top level control" do
+ it "should succeed" do
+ expect(2 - 2).to eq(0)
+ end
+end
+ RECIPE
+
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::succeed'", :cwd => chef_dir)
+ expect(result.error?).to be_falsey
+ expect(result.stdout).to include("Successfully executed all `controls` blocks and contained examples")
+ end
+
+ it "should exit with a non-zero code when there is an audit failure" do
+ file 'cookbooks/audit_test/recipes/fail.rb', <<-RECIPE
+controls "control group without top level control" do
+ it "should fail" do
+ expect(2 - 2).to eq(1)
+ end
+end
+ RECIPE
+
+ result = shell_out("#{chef_client} -c \"#{path_to('config/client.rb')}\" -o 'audit_test::fail'", :cwd => chef_dir)
+ expect(result.error?).to be_truthy
+ expect(result.stdout).to include("Failure/Error: expect(2 - 2).to eq(1)")
+ end
+ end
+
end