diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-04-30 13:05:50 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-05-01 11:09:49 -0700 |
commit | dfce5a31c40b2710dd96cc86990b085ad9fa2a04 (patch) | |
tree | f2d320701e87adb081b61e3704be8c2a2e3d0892 | |
parent | f4b7c395a59c9093c90d8f9219522d5940845bb6 (diff) | |
download | chef-dfce5a31c40b2710dd96cc86990b085ad9fa2a04.tar.gz |
break up spec examples
-rw-r--r-- | spec/support/shared/unit/provider/file.rb | 26 |
1 files changed, 23 insertions, 3 deletions
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb index c62bb420ba..018be0a015 100644 --- a/spec/support/shared/unit/provider/file.rb +++ b/spec/support/shared/unit/provider/file.rb @@ -537,19 +537,39 @@ shared_examples_for Chef::Provider::File do end context "when the file was created" do before { expect(provider).to receive(:needs_creating?).at_least(:once).and_return(true) } - it "does not backup the file and does not produce a diff for reporting" do + it "does not backup the file" do expect(provider).not_to receive(:do_backup) provider.send(:do_contents_changes) + end + + it "does not produce a diff for reporting" do + provider.send(:do_contents_changes) expect(resource.diff).to be_nil + end + + it "renders the final checksum correctly for reporting" do + provider.send(:do_contents_changes) expect(resource.state_for_resource_reporter[:checksum]).to eql(tempfile_sha256) end end context "when the file was not created" do - before { expect(provider).to receive(:needs_creating?).at_least(:once).and_return(false) } - it "backs up the file and produces a diff for reporting" do + before do + allow(provider).to receive(:do_backup) # stub do_backup + expect(provider).to receive(:needs_creating?).at_least(:once).and_return(false) + end + + it "backs up the file" do expect(provider).to receive(:do_backup) provider.send(:do_contents_changes) + end + + it "produces a diff for reporting" do + provider.send(:do_contents_changes) expect(resource.diff).to eq(diff_for_reporting) + end + + it "renders the final checksum correctly for reporting" do + provider.send(:do_contents_changes) expect(resource.state_for_resource_reporter[:checksum]).to eql(tempfile_sha256) end end |