diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-12-10 18:42:27 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-12-14 12:51:58 -0800 |
commit | 2a07b31a618ba3155f07eaf9453d642426f58d51 (patch) | |
tree | 5004ac15a95c8ac49331f5a54b4684a4cf7fd3e0 /spec/support | |
parent | 27cb74bc5983b31ddbc9de46c8e020122251abe7 (diff) | |
download | chef-2a07b31a618ba3155f07eaf9453d642426f58d51.tar.gz |
implement verifications as a property
the unit tests on this one did some excessive stubbing/mocking, i just
let them create a real verification object which the 'true' or 'false'
then failed (for real).
Diffstat (limited to 'spec/support')
-rw-r--r-- | spec/support/shared/unit/provider/file.rb | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/spec/support/shared/unit/provider/file.rb b/spec/support/shared/unit/provider/file.rb index ff9e271a0a..4d1bdb8022 100644 --- a/spec/support/shared/unit/provider/file.rb +++ b/spec/support/shared/unit/provider/file.rb @@ -1,6 +1,6 @@ # # Author:: Lamont Granquist (<lamont@opscode.com>) -# Copyright:: Copyright (c) 2013 Opscode, Inc. +# Copyright:: Copyright (c) 2013-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -465,28 +465,26 @@ shared_examples_for Chef::Provider::File do t } - let(:verification) { instance_double(Chef::Resource::File::Verification) } - let(:verification_fail) { instance_double(Chef::Resource::File::Verification) } - context "with user-supplied verifications" do it "calls #verify on each verification with tempfile path" do - allow(Chef::Resource::File::Verification).to( - receive(:new).with(anything(), "true", anything()).and_return(verification)) + #verification = instance_double(Chef::Resource::File::Verification) + #verification_fail = instance_double(Chef::Resource::File::Verification) + #allow(Chef::Resource::File::Verification).to( + # receive(:new).with(anything(), "true", anything()).and_return(verification)) provider.new_resource.verify "true" provider.new_resource.verify "true" - expect(verification).to receive(:verify).with(tempfile.path).twice.and_return(true) provider.send(:do_validate_content) end it "raises an exception if any verification fails" do - allow(Chef::Resource::File::Verification).to( - receive(:new).with(anything(), "true", anything()).and_return(verification)) - allow(Chef::Resource::File::Verification).to( - receive(:new).with(anything(), "false", anything()).and_return(verification_fail)) + #verification = instance_double(Chef::Resource::File::Verification) + #verification_fail = instance_double(Chef::Resource::File::Verification) + #allow(Chef::Resource::File::Verification).to( + # receive(:new).with(anything(), "true", anything()).and_return(verification)) + #allow(Chef::Resource::File::Verification).to( + # receive(:new).with(anything(), "false", anything()).and_return(verification_fail)) provider.new_resource.verify "true" provider.new_resource.verify "false" - expect(verification).to receive(:verify).with(tempfile.path).and_return(true) - expect(verification_fail).to receive(:verify).with(tempfile.path).and_return(false) expect{provider.send(:do_validate_content)}.to raise_error(Chef::Exceptions::ValidationFailed) end end |