diff options
Diffstat (limited to 'chef/spec/unit/provider/remote_file_spec.rb')
-rw-r--r-- | chef/spec/unit/provider/remote_file_spec.rb | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/chef/spec/unit/provider/remote_file_spec.rb b/chef/spec/unit/provider/remote_file_spec.rb index 430a2e5916..b05b6a989d 100644 --- a/chef/spec/unit/provider/remote_file_spec.rb +++ b/chef/spec/unit/provider/remote_file_spec.rb @@ -65,10 +65,29 @@ describe Chef::Provider::RemoteFile, "do_remote_file" do end describe "when given a URI source" do - it "should download the file from the remote URL" do - @resource.source("http://opscode.com/seattle.txt") - @rest.should_receive(:get_rest).with("http://opscode.com/seattle.txt", true).and_return(@tempfile) - do_remote_file + describe "and given a checksum" do + it "should not download the file if the checksum matches" do + @resource.checksum("0fd012fdc96e96f8f7cf2046522a54aed0ce470224513e45da6bc1a17a4924aa") + @resource.source("http://opscode.com/seattle.txt") + @rest.should_not_receive(:get_rest).with("http://opscode.com/seattle.txt", true).and_return(@tempfile) + do_remote_file + end + + it "should download the file if the checksum matches" do + @resource.checksum("this hash doesn't match") + @resource.source("http://opscode.com/seattle.txt") + @rest.should_receive(:get_rest).with("http://opscode.com/seattle.txt", true).and_return(@tempfile) + do_remote_file + end + end + + describe "and not given a checksum" do + it "should download the file from the remote URL" do + @resource.checksum(nil) + @resource.source("http://opscode.com/seattle.txt") + @rest.should_receive(:get_rest).with("http://opscode.com/seattle.txt", true).and_return(@tempfile) + do_remote_file + end end end |