summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAdam Jacob <adam@hjksolutions.com>2008-08-16 23:48:44 -0700
committerAdam Jacob <adam@hjksolutions.com>2008-08-16 23:48:44 -0700
commit1baf929ee98799747cedc275e511bf445792e77a (patch)
treee72487c29940a222a740db1c0b2b62b6d4c15747 /spec
parentcbfa29a274c1defe36c218d12b70b70e640f7069 (diff)
downloadchef-1baf929ee98799747cedc275e511bf445792e77a.tar.gz
Adding remote_file and remote_directory support
Diffstat (limited to 'spec')
-rw-r--r--spec/unit/provider/template_spec.rb8
-rw-r--r--spec/unit/resource/remote_file_spec.rb39
-rw-r--r--spec/unit/resource/template_spec.rb6
3 files changed, 47 insertions, 6 deletions
diff --git a/spec/unit/provider/template_spec.rb b/spec/unit/provider/template_spec.rb
index 773180348c..8b446a73af 100644
--- a/spec/unit/provider/template_spec.rb
+++ b/spec/unit/provider/template_spec.rb
@@ -40,7 +40,8 @@ describe Chef::Provider::Template, "action_create" do
it "should copy the tempfile to the real file if the checksums do not match" do
@provider.stub!(:checksum).and_return("dad86c61eea237932f201009e5431607")
- FileUtils.should_receive(:cp).with(@tempfile.path, @resource.path)
+ FileUtils.should_receive(:cp).once
+ @provider.stub!(:backup).and_return(true)
do_action_create
end
@@ -75,11 +76,12 @@ describe Chef::Provider::Template, "generate_url" do
end
it "should return a raw url if it starts with http" do
- @provider.generate_url('http://foobar').should eql("http://foobar")
+ @provider.generate_url('http://foobar', "templates").should eql("http://foobar")
end
it "should return a composed url if it does not start with http" do
Chef::Platform.stub!(:find_platform_and_version).and_return(["monkey", "1.0"])
- @provider.generate_url('default/something').should eql("cookbooks/daft/templates?id=default/something&platform=monkey&version=1.0")
+ @node.fqdn("monkeynode")
+ @provider.generate_url('default/something', "templates").should eql("cookbooks/daft/templates?id=default/something&platform=monkey&version=1.0&fqdn=monkeynode")
end
end \ No newline at end of file
diff --git a/spec/unit/resource/remote_file_spec.rb b/spec/unit/resource/remote_file_spec.rb
new file mode 100644
index 0000000000..520eb74a48
--- /dev/null
+++ b/spec/unit/resource/remote_file_spec.rb
@@ -0,0 +1,39 @@
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: GNU General Public License version 2 or later
+#
+# This program and entire repository is free software; you can
+# redistribute it and/or modify it under the terms of the GNU
+# General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::RemoteFile do
+
+ before(:each) do
+ @resource = Chef::Resource::RemoteFile.new("fakey_fakerton")
+ end
+
+ it "should create a new Chef::Resource::RemoteFile" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::File)
+ @resource.should be_a_kind_of(Chef::Resource::RemoteFile)
+ end
+
+ it "should accept a string for the remote file source" do
+ @resource.source "something"
+ @resource.source.should eql("something")
+ end
+
+end \ No newline at end of file
diff --git a/spec/unit/resource/template_spec.rb b/spec/unit/resource/template_spec.rb
index 4bf1f1ace9..3734892dd9 100644
--- a/spec/unit/resource/template_spec.rb
+++ b/spec/unit/resource/template_spec.rb
@@ -31,9 +31,9 @@ describe Chef::Resource::Template do
@resource.should be_a_kind_of(Chef::Resource::Template)
end
- it "should accept a string for the template name" do
- @resource.template "something"
- @resource.template.should eql("something")
+ it "should accept a string for the template source" do
+ @resource.source "something"
+ @resource.source.should eql("something")
end
it "should accept a hash for the variable list" do