summaryrefslogtreecommitdiff
path: root/chef/spec/unit/resource
diff options
context:
space:
mode:
Diffstat (limited to 'chef/spec/unit/resource')
-rw-r--r--chef/spec/unit/resource/bash_spec.rb40
-rw-r--r--chef/spec/unit/resource/csh_spec.rb40
-rw-r--r--chef/spec/unit/resource/directory_spec.rb79
-rw-r--r--chef/spec/unit/resource/execute_spec.rb102
-rw-r--r--chef/spec/unit/resource/file_spec.rb92
-rw-r--r--chef/spec/unit/resource/link_spec.rb78
-rw-r--r--chef/spec/unit/resource/package_spec.rb56
-rw-r--r--chef/spec/unit/resource/perl_spec.rb40
-rw-r--r--chef/spec/unit/resource/python_spec.rb40
-rw-r--r--chef/spec/unit/resource/remote_directory_spec.rb71
-rw-r--r--chef/spec/unit/resource/remote_file_spec.rb38
-rw-r--r--chef/spec/unit/resource/ruby_spec.rb40
-rw-r--r--chef/spec/unit/resource/script_spec.rb50
-rw-r--r--chef/spec/unit/resource/service_spec.rb100
-rw-r--r--chef/spec/unit/resource/template_spec.rb43
15 files changed, 909 insertions, 0 deletions
diff --git a/chef/spec/unit/resource/bash_spec.rb b/chef/spec/unit/resource/bash_spec.rb
new file mode 100644
index 0000000000..f86e63d32e
--- /dev/null
+++ b/chef/spec/unit/resource/bash_spec.rb
@@ -0,0 +1,40 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::Bash do
+
+ before(:each) do
+ @resource = Chef::Resource::Bash.new("fakey_fakerton")
+ end
+
+ it "should create a new Chef::Resource::Bash" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::Bash)
+ end
+
+ it "should have a resource name of :bash" do
+ @resource.resource_name.should eql(:bash)
+ end
+
+ it "should have an interpreter of bash" do
+ @resource.interpreter.should eql("bash")
+ end
+
+end \ No newline at end of file
diff --git a/chef/spec/unit/resource/csh_spec.rb b/chef/spec/unit/resource/csh_spec.rb
new file mode 100644
index 0000000000..67ba4499fa
--- /dev/null
+++ b/chef/spec/unit/resource/csh_spec.rb
@@ -0,0 +1,40 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::Csh do
+
+ before(:each) do
+ @resource = Chef::Resource::Csh.new("fakey_fakerton")
+ end
+
+ it "should create a new Chef::Resource::Csh" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::Csh)
+ end
+
+ it "should have a resource name of :csh" do
+ @resource.resource_name.should eql(:csh)
+ end
+
+ it "should have an interpreter of csh" do
+ @resource.interpreter.should eql("csh")
+ end
+
+end \ No newline at end of file
diff --git a/chef/spec/unit/resource/directory_spec.rb b/chef/spec/unit/resource/directory_spec.rb
new file mode 100644
index 0000000000..98cc28fbc6
--- /dev/null
+++ b/chef/spec/unit/resource/directory_spec.rb
@@ -0,0 +1,79 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::Directory do
+
+ before(:each) do
+ @resource = Chef::Resource::Directory.new("fakey_fakerton")
+ end
+
+ it "should create a new Chef::Resource::Directory" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::Directory)
+ end
+
+ it "should have a name" do
+ @resource.name.should eql("fakey_fakerton")
+ end
+
+ it "should have a default action of 'create'" do
+ @resource.action.should eql(:create)
+ end
+
+ it "should accept create or delete for action" do
+ lambda { @resource.action "create" }.should_not raise_error(ArgumentError)
+ lambda { @resource.action "delete" }.should_not raise_error(ArgumentError)
+ lambda { @resource.action "blues" }.should raise_error(ArgumentError)
+ end
+
+ it "should accept a group name or id for group" do
+ lambda { @resource.group "root" }.should_not raise_error(ArgumentError)
+ lambda { @resource.group 123 }.should_not raise_error(ArgumentError)
+ lambda { @resource.group "root*goo" }.should raise_error(ArgumentError)
+ end
+
+ it "should accept a valid unix file mode" do
+ lambda { @resource.mode 0444 }.should_not raise_error(ArgumentError)
+ lambda { @resource.mode 444 }.should_not raise_error(ArgumentError)
+ lambda { @resource.mode 4 }.should raise_error(ArgumentError)
+ end
+
+ it "should accept a user name or id for owner" do
+ lambda { @resource.owner "root" }.should_not raise_error(ArgumentError)
+ lambda { @resource.owner 123 }.should_not raise_error(ArgumentError)
+ lambda { @resource.owner "root*goo" }.should raise_error(ArgumentError)
+ end
+
+ it "should use the object name as the path by default" do
+ @resource.path.should eql("fakey_fakerton")
+ end
+
+ it "should accept a string as the path" do
+ lambda { @resource.path "/tmp" }.should_not raise_error(ArgumentError)
+ lambda { @resource.path Hash.new }.should raise_error(ArgumentError)
+ end
+
+ it "should allow you to have specify whether the action is recursive with true/false" do
+ lambda { @resource.recursive true }.should_not raise_error(ArgumentError)
+ lambda { @resource.recursive false }.should_not raise_error(ArgumentError)
+ lambda { @resource.recursive "monkey" }.should raise_error(ArgumentError)
+ end
+
+end \ No newline at end of file
diff --git a/chef/spec/unit/resource/execute_spec.rb b/chef/spec/unit/resource/execute_spec.rb
new file mode 100644
index 0000000000..94cb3d3d92
--- /dev/null
+++ b/chef/spec/unit/resource/execute_spec.rb
@@ -0,0 +1,102 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::Execute do
+
+ before(:each) do
+ @resource = Chef::Resource::Execute.new("some command")
+ end
+
+ it "should create a new Chef::Resource::Execute" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::Execute)
+ end
+
+ it "should set the command to the first argument to new" do
+ @resource.command.should eql("some command")
+ end
+
+ it "should accept a string for the command to run" do
+ @resource.command "something"
+ @resource.command.should eql("something")
+ end
+
+ it "should accept a string for the cwd" do
+ @resource.cwd "something"
+ @resource.cwd.should eql("something")
+ end
+
+ it "should accept a hash for the environment" do
+ test_hash = { :one => :two }
+ @resource.environment(test_hash)
+ @resource.environment.should eql(test_hash)
+ end
+
+ it "should accept a string for the group" do
+ @resource.group "something"
+ @resource.group.should eql("something")
+ end
+
+ it "should accept an integer for the group" do
+ @resource.group 1
+ @resource.group.should eql(1)
+ end
+
+ it "should accept a string for onlyif" do
+ @resource.onlyif "woot"
+ @resource.onlyif.should eql("woot")
+ end
+
+ it "should accept an array for the execution path" do
+ @resource.path ["woot"]
+ @resource.path.should eql(["woot"])
+ end
+
+ it "should accept an integer for the return code" do
+ @resource.returns 1
+ @resource.returns.should eql(1)
+ end
+
+ it "should accept an integer for the timeout" do
+ @resource.timeout 1
+ @resource.timeout.should eql(1)
+ end
+
+ it "should accept a string for unless" do
+ @resource.unless "woot"
+ @resource.unless.should eql("woot")
+ end
+
+ it "should accept a string for the user" do
+ @resource.user "something"
+ @resource.user.should eql("something")
+ end
+
+ it "should accept an integer for the user" do
+ @resource.user 1
+ @resource.user.should eql(1)
+ end
+
+ it "should accept a string for creates" do
+ @resource.creates "something"
+ @resource.creates.should eql("something")
+ end
+
+end
diff --git a/chef/spec/unit/resource/file_spec.rb b/chef/spec/unit/resource/file_spec.rb
new file mode 100644
index 0000000000..b67598d738
--- /dev/null
+++ b/chef/spec/unit/resource/file_spec.rb
@@ -0,0 +1,92 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::File do
+
+ before(:each) do
+ @resource = Chef::Resource::File.new("fakey_fakerton")
+ end
+
+ it "should create a new Chef::Resource::File" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::File)
+ end
+
+ it "should have a name" do
+ @resource.name.should eql("fakey_fakerton")
+ end
+
+ it "should have a default action of 'create'" do
+ @resource.action.should eql("create")
+ end
+
+ it "should be set to back up 5 files by default" do
+ @resource.backup.should eql(5)
+ end
+
+ it "should only accept false or a number for backup" do
+ lambda { @resource.backup true }.should raise_error(ArgumentError)
+ lambda { @resource.backup false }.should_not raise_error(ArgumentError)
+ lambda { @resource.backup 10 }.should_not raise_error(ArgumentError)
+ lambda { @resource.backup "blues" }.should raise_error(ArgumentError)
+ end
+
+ it "should accept an md5sum for checksum" do
+ lambda { @resource.checksum "bfda9e7a13afb123433667c2c7801d11" }.should_not raise_error(ArgumentError)
+ lambda { @resource.checksum "monkey!" }.should raise_error(ArgumentError)
+ end
+
+ it "should accept create, delete or touch for action" do
+ lambda { @resource.action "create" }.should_not raise_error(ArgumentError)
+ lambda { @resource.action "delete" }.should_not raise_error(ArgumentError)
+ lambda { @resource.action "touch" }.should_not raise_error(ArgumentError)
+ lambda { @resource.action "blues" }.should raise_error(ArgumentError)
+ end
+
+ it "should accept a group name or id for group" do
+ lambda { @resource.group "root" }.should_not raise_error(ArgumentError)
+ lambda { @resource.group 123 }.should_not raise_error(ArgumentError)
+ lambda { @resource.group "root*goo" }.should raise_error(ArgumentError)
+ end
+
+ it "should accept a valid unix file mode" do
+ lambda { @resource.mode 0444 }.should_not raise_error(ArgumentError)
+ @resource.mode.should eql(0444)
+ lambda { @resource.mode 444 }.should_not raise_error(ArgumentError)
+ lambda { @resource.mode 4 }.should raise_error(ArgumentError)
+ end
+
+ it "should accept a user name or id for owner" do
+ lambda { @resource.owner "root" }.should_not raise_error(ArgumentError)
+ lambda { @resource.owner 123 }.should_not raise_error(ArgumentError)
+ lambda { @resource.owner "root*goo" }.should raise_error(ArgumentError)
+ end
+
+ it "should use the object name as the path by default" do
+ @resource.path.should eql("fakey_fakerton")
+ end
+
+ it "should accept a string as the path" do
+ lambda { @resource.path "/tmp" }.should_not raise_error(ArgumentError)
+ @resource.path.should eql("/tmp")
+ lambda { @resource.path Hash.new }.should raise_error(ArgumentError)
+ end
+
+end \ No newline at end of file
diff --git a/chef/spec/unit/resource/link_spec.rb b/chef/spec/unit/resource/link_spec.rb
new file mode 100644
index 0000000000..fa0810cced
--- /dev/null
+++ b/chef/spec/unit/resource/link_spec.rb
@@ -0,0 +1,78 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::Link do
+
+ before(:each) do
+ @resource = Chef::Resource::Link.new("fakey_fakerton")
+ end
+
+ it "should create a new Chef::Resource::Link" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::Link)
+ end
+
+ it "should have a name" do
+ @resource.name.should eql("fakey_fakerton")
+ end
+
+ it "should have a default action of 'create'" do
+ @resource.action.should eql(:create)
+ end
+
+ it "should accept create or delete for action" do
+ lambda { @resource.action "create" }.should_not raise_error(ArgumentError)
+ lambda { @resource.action "delete" }.should_not raise_error(ArgumentError)
+ lambda { @resource.action "blues" }.should raise_error(ArgumentError)
+ end
+
+ it "should use the object name as the source_file by default" do
+ @resource.source_file.should eql("fakey_fakerton")
+ end
+
+ it "should accept a string as the source_file" do
+ lambda { @resource.source_file "/tmp" }.should_not raise_error(ArgumentError)
+ lambda { @resource.source_file Hash.new }.should raise_error(ArgumentError)
+ end
+
+ it "should allow you to set a target_file" do
+ @resource.target_file "/tmp/foo"
+ @resource.target_file.should eql("/tmp/foo")
+ end
+
+ it "should allow you to specify the link type" do
+ @resource.link_type "symbolic"
+ @resource.link_type.should eql(:symbolic)
+ end
+
+ it "should default to a symbolic link" do
+ @resource.link_type.should eql(:symbolic)
+ end
+
+ it "should accept a hard link_type" do
+ @resource.link_type :hard
+ @resource.link_type.should eql(:hard)
+ end
+
+ it "should reject any other link_type but :hard and :symbolic" do
+ lambda { @resource.link_type "x-men" }.should raise_error(ArgumentError)
+ end
+
+end \ No newline at end of file
diff --git a/chef/spec/unit/resource/package_spec.rb b/chef/spec/unit/resource/package_spec.rb
new file mode 100644
index 0000000000..8756e4f603
--- /dev/null
+++ b/chef/spec/unit/resource/package_spec.rb
@@ -0,0 +1,56 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::Package do
+
+ before(:each) do
+ @resource = Chef::Resource::Package.new("emacs")
+ end
+
+ it "should create a new Chef::Resource::Package" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::Package)
+ end
+
+ it "should set the package_name to the first argument to new" do
+ @resource.package_name.should eql("emacs")
+ end
+
+ it "should accept a string for the package name" do
+ @resource.package_name "something"
+ @resource.package_name.should eql("something")
+ end
+
+ it "should accept a string for the version" do
+ @resource.version "something"
+ @resource.version.should eql("something")
+ end
+
+ it "should accept a string for the response file" do
+ @resource.response_file "something"
+ @resource.response_file.should eql("something")
+ end
+
+ it "should accept a string for the source" do
+ @resource.source "something"
+ @resource.source.should eql("something")
+ end
+
+end
diff --git a/chef/spec/unit/resource/perl_spec.rb b/chef/spec/unit/resource/perl_spec.rb
new file mode 100644
index 0000000000..528bcef08c
--- /dev/null
+++ b/chef/spec/unit/resource/perl_spec.rb
@@ -0,0 +1,40 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::Perl do
+
+ before(:each) do
+ @resource = Chef::Resource::Perl.new("fakey_fakerton")
+ end
+
+ it "should create a new Chef::Resource::Perl" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::Perl)
+ end
+
+ it "should have a resource name of :perl" do
+ @resource.resource_name.should eql(:perl)
+ end
+
+ it "should have an interpreter of perl" do
+ @resource.interpreter.should eql("perl")
+ end
+
+end \ No newline at end of file
diff --git a/chef/spec/unit/resource/python_spec.rb b/chef/spec/unit/resource/python_spec.rb
new file mode 100644
index 0000000000..11c5b84d04
--- /dev/null
+++ b/chef/spec/unit/resource/python_spec.rb
@@ -0,0 +1,40 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::Python do
+
+ before(:each) do
+ @resource = Chef::Resource::Python.new("fakey_fakerton")
+ end
+
+ it "should create a new Chef::Resource::Python" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::Python)
+ end
+
+ it "should have a resource name of :python" do
+ @resource.resource_name.should eql(:python)
+ end
+
+ it "should have an interpreter of python" do
+ @resource.interpreter.should eql("python")
+ end
+
+end \ No newline at end of file
diff --git a/chef/spec/unit/resource/remote_directory_spec.rb b/chef/spec/unit/resource/remote_directory_spec.rb
new file mode 100644
index 0000000000..2d9ce122af
--- /dev/null
+++ b/chef/spec/unit/resource/remote_directory_spec.rb
@@ -0,0 +1,71 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::RemoteDirectory do
+
+ before(:each) do
+ @resource = Chef::Resource::RemoteDirectory.new("/etc/dunk")
+ end
+
+ it "should create a new Chef::Resource::RemoteDirectory" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::RemoteDirectory)
+ end
+
+ it "should set the path to the first argument to new" do
+ @resource.path.should eql("/etc/dunk")
+ end
+
+ it "should accept a string for the remote directory source" do
+ @resource.source "foo"
+ @resource.source.should eql("foo")
+ end
+
+ it "should accept a number for the remote files backup" do
+ @resource.files_backup 1
+ @resource.files_backup.should eql(1)
+ end
+
+ it "should accept false for the remote files backup" do
+ @resource.files_backup false
+ @resource.files_backup.should eql(false)
+ end
+
+ it "should accept 3 or 4 digets for the files_mode" do
+ @resource.files_mode 100
+ @resource.files_mode.should eql(100)
+ @resource.files_mode 1000
+ @resource.files_mode.should eql(1000)
+ end
+
+ it "should accept a string or number for the files group" do
+ @resource.files_group "heart"
+ @resource.files_group.should eql("heart")
+ @resource.files_group 1000
+ @resource.files_group.should eql(1000)
+ end
+
+ it "should accept a string or number for the files owner" do
+ @resource.files_owner "heart"
+ @resource.files_owner.should eql("heart")
+ @resource.files_owner 1000
+ @resource.files_owner.should eql(1000)
+ end
+end
diff --git a/chef/spec/unit/resource/remote_file_spec.rb b/chef/spec/unit/resource/remote_file_spec.rb
new file mode 100644
index 0000000000..4c052e0260
--- /dev/null
+++ b/chef/spec/unit/resource/remote_file_spec.rb
@@ -0,0 +1,38 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+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/chef/spec/unit/resource/ruby_spec.rb b/chef/spec/unit/resource/ruby_spec.rb
new file mode 100644
index 0000000000..5351462154
--- /dev/null
+++ b/chef/spec/unit/resource/ruby_spec.rb
@@ -0,0 +1,40 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::Ruby do
+
+ before(:each) do
+ @resource = Chef::Resource::Ruby.new("fakey_fakerton")
+ end
+
+ it "should create a new Chef::Resource::Ruby" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::Ruby)
+ end
+
+ it "should have a resource name of :ruby" do
+ @resource.resource_name.should eql(:ruby)
+ end
+
+ it "should have an interpreter of ruby" do
+ @resource.interpreter.should eql("ruby")
+ end
+
+end \ No newline at end of file
diff --git a/chef/spec/unit/resource/script_spec.rb b/chef/spec/unit/resource/script_spec.rb
new file mode 100644
index 0000000000..f003028fd6
--- /dev/null
+++ b/chef/spec/unit/resource/script_spec.rb
@@ -0,0 +1,50 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::Script do
+
+ before(:each) do
+ @resource = Chef::Resource::Script.new("fakey_fakerton")
+ end
+
+ it "should create a new Chef::Resource::Script" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::Script)
+ end
+
+ it "should have a resource name of :script" do
+ @resource.resource_name.should eql(:script)
+ end
+
+ it "should set command to the argument provided to new" do
+ @resource.command.should eql("fakey_fakerton")
+ end
+
+ it "should accept a string for the code" do
+ @resource.code "hey jude"
+ @resource.code.should eql("hey jude")
+ end
+
+ it "should accept a string for the interpreter" do
+ @resource.interpreter "naaaaNaNaNaaNaaNaaNaa"
+ @resource.interpreter.should eql("naaaaNaNaNaaNaaNaaNaa")
+ end
+
+end \ No newline at end of file
diff --git a/chef/spec/unit/resource/service_spec.rb b/chef/spec/unit/resource/service_spec.rb
new file mode 100644
index 0000000000..f5941f89ae
--- /dev/null
+++ b/chef/spec/unit/resource/service_spec.rb
@@ -0,0 +1,100 @@
+#
+# Author:: AJ Christensen (<aj@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::Service do
+
+ before(:each) do
+ @resource = Chef::Resource::Service.new("chef")
+ end
+
+ it "should create a new Chef::Resource::Service" do
+ @resource.should be_a_kind_of(Chef::Resource)
+ @resource.should be_a_kind_of(Chef::Resource::Service)
+ end
+
+ it "should set the service_name to the first argument to new" do
+ @resource.service_name.should eql("chef")
+ end
+
+ it "should set the pattern to be the service name by default" do
+ @resource.pattern.should eql("chef")
+ end
+
+ it "should accept a string for the service name" do
+ @resource.service_name "something"
+ @resource.service_name.should eql("something")
+ end
+
+ it "should accept a string for the service pattern" do
+ @resource.pattern ".*"
+ @resource.pattern.should eql(".*")
+ end
+
+ it "should not accept a regexp for the service pattern" do
+ lambda {
+ @resource.pattern /.*/
+ }.should raise_error(ArgumentError)
+ end
+
+ it "should accept a string for the service start command" do
+ @resource.start_command "/etc/init.d/chef start"
+ @resource.start_command.should eql("/etc/init.d/chef start")
+ end
+
+ it "should not accept a regexp for the service start command" do
+ lambda {
+ @resource.start_command /.*/
+ }.should raise_error(ArgumentError)
+ end
+
+ it "should accept a string for the service stop command" do
+ @resource.stop_command "/etc/init.d/chef stop"
+ @resource.stop_command.should eql("/etc/init.d/chef stop")
+ end
+
+ it "should not accept a regexp for the service stop command" do
+ lambda {
+ @resource.stop_command /.*/
+ }.should raise_error(ArgumentError)
+ end
+
+ it "should accept a string for the service status command" do
+ @resource.status_command "/etc/init.d/chef status"
+ @resource.status_command.should eql("/etc/init.d/chef status")
+ end
+
+ it "should not accept a regexp for the service status command" do
+ lambda {
+ @resource.status_command /.*/
+ }.should raise_error(ArgumentError)
+ end
+
+ it "should accept a string for the service restart command" do
+ @resource.restart_command "/etc/init.d/chef restart"
+ @resource.restart_command.should eql("/etc/init.d/chef restart")
+ end
+
+ it "should not accept a regexp for the service restart command" do
+ lambda {
+ @resource.restart_command /.*/
+ }.should raise_error(ArgumentError)
+ end
+
+end
diff --git a/chef/spec/unit/resource/template_spec.rb b/chef/spec/unit/resource/template_spec.rb
new file mode 100644
index 0000000000..106fe77bda
--- /dev/null
+++ b/chef/spec/unit/resource/template_spec.rb
@@ -0,0 +1,43 @@
+#
+# Author:: Adam Jacob (<adam@hjksolutions.com>)
+# Copyright:: Copyright (c) 2008 HJK Solutions, LLC
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
+
+describe Chef::Resource::Template do
+
+ before(:each) do
+ @resource = Chef::Resource::Template.new("fakey_fakerton")
+ end
+
+ it "should create a new Chef::Resource::Template" 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::Template)
+ end
+
+ 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
+ @resource.variables({ :reluctance => :awkward })
+ @resource.variables.should == { :reluctance => :awkward }
+ end
+
+end \ No newline at end of file