diff options
Diffstat (limited to 'spec/unit/resource')
48 files changed, 313 insertions, 314 deletions
diff --git a/spec/unit/resource/apt_package_spec.rb b/spec/unit/resource/apt_package_spec.rb index 795ffc6fc4..58b007c327 100644 --- a/spec/unit/resource/apt_package_spec.rb +++ b/spec/unit/resource/apt_package_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,19 +19,19 @@ require 'spec_helper' describe Chef::Resource::AptPackage, "initialize" do - + before(:each) do @resource = Chef::Resource::AptPackage.new("foo") end - + it "should return a Chef::Resource::AptPackage" do @resource.should be_a_kind_of(Chef::Resource::AptPackage) end - + it "should set the resource_name to :apt_package" do @resource.resource_name.should eql(:apt_package) end - + it "should set the provider to Chef::Provider::Package::Apt" do @resource.provider.should eql(Chef::Provider::Package::Apt) end diff --git a/spec/unit/resource/bash_spec.rb b/spec/unit/resource/bash_spec.rb index c7f31e1de6..d729db6977 100644 --- a/spec/unit/resource/bash_spec.rb +++ b/spec/unit/resource/bash_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -22,17 +22,17 @@ describe Chef::Resource::Bash do before(:each) do @resource = Chef::Resource::Bash.new("fakey_fakerton") - end + 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 diff --git a/spec/unit/resource/batch_spec.rb b/spec/unit/resource/batch_spec.rb index 91b840908e..b74c7d24a7 100644 --- a/spec/unit/resource/batch_spec.rb +++ b/spec/unit/resource/batch_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -27,22 +27,22 @@ describe Chef::Resource::Batch do node.default["kernel"][:machine] = :x86_64.to_s run_context = Chef::RunContext.new(node, nil, nil) - + @resource = Chef::Resource::Batch.new("batch_unit_test", run_context) - end + end it "should create a new Chef::Resource::Batch" do @resource.should be_a_kind_of(Chef::Resource::Batch) end - + context "windows script" do let(:resource_instance) { @resource } let(:resource_instance_name ) { @resource.command } let(:resource_name) { :batch } let(:interpreter_file_name) { 'cmd.exe' } - it_should_behave_like "a Windows script resource" + it_should_behave_like "a Windows script resource" end - + end diff --git a/spec/unit/resource/breakpoint_spec.rb b/spec/unit/resource/breakpoint_spec.rb index 8eaabb546d..412211a038 100644 --- a/spec/unit/resource/breakpoint_spec.rb +++ b/spec/unit/resource/breakpoint_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,25 +19,25 @@ require 'spec_helper' describe Chef::Resource::Breakpoint do - + before do @breakpoint = Chef::Resource::Breakpoint.new end - + it "allows the action :break" do @breakpoint.allowed_actions.should include(:break) end - + it "defaults to the break action" do @breakpoint.action.should == "break" end - + it "names itself after the line number of the file where it's created" do @breakpoint.name.should match(/breakpoint_spec\.rb\:[\d]{2}\:in \`new\'$/) end - + it "uses the breakpoint provider" do @breakpoint.provider.should == Chef::Provider::Breakpoint end - + end diff --git a/spec/unit/resource/chef_gem_spec.rb b/spec/unit/resource/chef_gem_spec.rb index 54def9a49d..1d7ca8a81e 100644 --- a/spec/unit/resource/chef_gem_spec.rb +++ b/spec/unit/resource/chef_gem_spec.rb @@ -7,9 +7,9 @@ # 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. @@ -20,19 +20,19 @@ require 'spec_helper' describe Chef::Resource::ChefGem, "initialize" do - + before(:each) do @resource = Chef::Resource::ChefGem.new("foo") end - + it "should return a Chef::Resource::ChefGem" do @resource.should be_a_kind_of(Chef::Resource::ChefGem) end - + it "should set the resource_name to :chef_gem" do @resource.resource_name.should eql(:chef_gem) end - + it "should set the provider to Chef::Provider::Package::Rubygems" do @resource.provider.should eql(Chef::Provider::Package::Rubygems) end diff --git a/spec/unit/resource/cookbook_file_spec.rb b/spec/unit/resource/cookbook_file_spec.rb index d0408c251a..6c55c8035a 100644 --- a/spec/unit/resource/cookbook_file_spec.rb +++ b/spec/unit/resource/cookbook_file_spec.rb @@ -7,9 +7,9 @@ # 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. @@ -23,29 +23,29 @@ describe Chef::Resource::CookbookFile do before do @cookbook_file = Chef::Resource::CookbookFile.new('sourcecode_tarball.tgz') end - + it "uses the name parameter for the source parameter" do @cookbook_file.name.should == 'sourcecode_tarball.tgz' end - + it "has a source parameter" do @cookbook_file.name('config_file.conf') @cookbook_file.name.should == 'config_file.conf' end - + it "defaults to a nil cookbook parameter (current cookbook will be used)" do @cookbook_file.cookbook.should be_nil end - + it "has a cookbook parameter" do @cookbook_file.cookbook("munin") @cookbook_file.cookbook.should == 'munin' end - + it "sets the provider to Chef::Provider::CookbookFile" do @cookbook_file.provider.should == Chef::Provider::CookbookFile end - + describe "when it has a backup number, group, mode, owner, source, checksum, and cookbook on nix or path, rights, deny_rights, checksum on windows" do before do if Chef::Platform.windows? @@ -63,21 +63,21 @@ describe Chef::Resource::CookbookFile do @cookbook_file.checksum("1" * 64) end - + it "describes the state" do state = @cookbook_file.state if Chef::Platform.windows? puts state state[:rights].should == [{:permissions => :read, :principals => "Everyone"}] state[:deny_rights].should == [{:permissions => :full_control, :principals => "Clumsy_Sam"}] - else + else state[:group].should == "wheel" state[:mode].should == "0664" state[:owner].should == "root" end state[:checksum].should == "1" * 64 end - + it "returns the path as its identity" do if Chef::Platform.windows? @cookbook_file.identity.should == "C:/temp/origin/file.txt" diff --git a/spec/unit/resource/cron_spec.rb b/spec/unit/resource/cron_spec.rb index 403ffb009b..7f294fae11 100644 --- a/spec/unit/resource/cron_spec.rb +++ b/spec/unit/resource/cron_spec.rb @@ -7,9 +7,9 @@ # 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. @@ -23,21 +23,21 @@ describe Chef::Resource::Cron do before(:each) do @resource = Chef::Resource::Cron.new("cronify") - end + end it "should create a new Chef::Resource::Cron" do @resource.should be_a_kind_of(Chef::Resource) @resource.should be_a_kind_of(Chef::Resource::Cron) end - + it "should have a name" do @resource.name.should eql("cronify") 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) @@ -63,7 +63,7 @@ describe Chef::Resource::Cron do @resource.hour "6" @resource.hour.should eql("6") end - + it "should allow you to specify the day" do @resource.day "10" @resource.day.should eql("10") @@ -110,7 +110,7 @@ describe Chef::Resource::Cron do @resource.send(x, "*").should eql("*") end end - + it "should allow ranges for all time and date values" do [ "minute", "hour", "day", "month", "weekday" ].each do |x| @resource.send(x, "1-2,5").should eql("1-2,5") @@ -130,31 +130,31 @@ describe Chef::Resource::Cron do it "should reject any minute over 59" do lambda { @resource.minute "60" }.should raise_error(RangeError) end - + it "should reject any hour over 23" do lambda { @resource.hour "24" }.should raise_error(RangeError) end - + it "should reject any day over 31" do lambda { @resource.day "32" }.should raise_error(RangeError) end - + it "should reject any month over 12" do lambda { @resource.month "13" }.should raise_error(RangeError) end - + it "should reject any weekday over 7" do lambda { @resource.weekday "8" }.should raise_error(RangeError) end - + it "should convert integer schedule values to a string" do [ "minute", "hour", "day", "month", "weekday" ].each do |x| @resource.send(x, 5).should eql("5") end end - + describe "when it has a time (minute, hour, day, month, weeekend) and user" do - before do + before do @resource.command("tackle") @resource.minute("1") @resource.hour("2") diff --git a/spec/unit/resource/csh_spec.rb b/spec/unit/resource/csh_spec.rb index 291c6ea745..e1534a8f5f 100644 --- a/spec/unit/resource/csh_spec.rb +++ b/spec/unit/resource/csh_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -22,17 +22,17 @@ describe Chef::Resource::Csh do before(:each) do @resource = Chef::Resource::Csh.new("fakey_fakerton") - end + 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 diff --git a/spec/unit/resource/deploy_revision_spec.rb b/spec/unit/resource/deploy_revision_spec.rb index 671ba9a1f6..1f509992aa 100644 --- a/spec/unit/resource/deploy_revision_spec.rb +++ b/spec/unit/resource/deploy_revision_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,7 +19,7 @@ require 'spec_helper' describe Chef::Resource::DeployRevision do - + it "defaults to the revision deploy provider" do @resource = Chef::Resource::DeployRevision.new("deploy _this_!") @resource.provider.should == Chef::Provider::Deploy::Revision @@ -29,11 +29,11 @@ describe Chef::Resource::DeployRevision do @resource = Chef::Resource::DeployRevision.new("deploy _this_!") @resource.resource_name.should == :deploy_revision end - + end describe Chef::Resource::DeployBranch do - + it "defaults to the revision deploy provider" do @resource = Chef::Resource::DeployBranch.new("deploy _this_!") @resource.provider.should == Chef::Provider::Deploy::Revision @@ -43,5 +43,5 @@ describe Chef::Resource::DeployBranch do @resource = Chef::Resource::DeployBranch.new("deploy _this_!") @resource.resource_name.should == :deploy_branch end - + end diff --git a/spec/unit/resource/deploy_spec.rb b/spec/unit/resource/deploy_spec.rb index f2f6893654..7cc25ed41c 100644 --- a/spec/unit/resource/deploy_spec.rb +++ b/spec/unit/resource/deploy_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,7 +19,7 @@ require 'spec_helper' describe Chef::Resource::Deploy do - + class << self def resource_has_a_string_attribute(attr_name) it "has a String attribute for #{attr_name.to_s}" do @@ -28,7 +28,7 @@ describe Chef::Resource::Deploy do lambda {@resource.send(attr_name, 8675309)}.should raise_error(ArgumentError) end end - + def resource_has_a_boolean_attribute(attr_name, opts={:defaults_to=>false}) it "has a Boolean attribute for #{attr_name.to_s}" do @resource.send(attr_name).should eql(opts[:defaults_to]) @@ -36,7 +36,7 @@ describe Chef::Resource::Deploy do @resource.send(attr_name).should eql( !opts[:defaults_to] ) end end - + def resource_has_a_callback_attribute(attr_name) it "has a Callback attribute #{attr_name}" do callback_block = lambda { :noop } @@ -49,11 +49,11 @@ describe Chef::Resource::Deploy do end end end - + before do @resource = Chef::Resource::Deploy.new("/my/deploy/dir") end - + resource_has_a_string_attribute(:repo) resource_has_a_string_attribute(:deploy_to) resource_has_a_string_attribute(:role) @@ -70,15 +70,15 @@ describe Chef::Resource::Deploy do resource_has_a_string_attribute(:svn_password) resource_has_a_string_attribute(:svn_arguments) resource_has_a_string_attribute(:svn_info_args) - + resource_has_a_boolean_attribute(:migrate, :defaults_to=>false) resource_has_a_boolean_attribute(:enable_submodules, :defaults_to=>false) resource_has_a_boolean_attribute(:shallow_clone, :defaults_to=>false) - + it "uses the first argument as the deploy directory" do @resource.deploy_to.should eql("/my/deploy/dir") end - + # For git, any revision, branch, tag, whatever is resolved to a SHA1 ref. # For svn, the branch is included in the repo URL. # Therefore, revision and branch ARE NOT SEPARATE THINGS @@ -86,19 +86,19 @@ describe Chef::Resource::Deploy do @resource.branch "stable" @resource.revision.should eql("stable") end - + it "takes the SCM resource to use as a constant, and defaults to git" do @resource.scm_provider.should eql(Chef::Provider::Git) @resource.scm_provider Chef::Provider::Subversion @resource.scm_provider.should eql(Chef::Provider::Subversion) end - + it "allows scm providers to be set via symbol" do @resource.scm_provider.should == Chef::Provider::Git @resource.scm_provider :subversion @resource.scm_provider.should == Chef::Provider::Subversion end - + it "allows scm providers to be set via string" do @resource.scm_provider.should == Chef::Provider::Git @resource.scm_provider "subversion" @@ -111,105 +111,105 @@ describe Chef::Resource::Deploy do @resource.svn_force_export.should be_true lambda {@resource.svn_force_export(10053)}.should raise_error(ArgumentError) end - + it "takes arbitrary environment variables in a hash" do @resource.environment "RAILS_ENV" => "production" @resource.environment.should == {"RAILS_ENV" => "production"} end - + it "takes string arguments to environment for backwards compat, setting RAILS_ENV, RACK_ENV, and MERB_ENV" do @resource.environment "production" @resource.environment.should == {"RAILS_ENV"=>"production", "RACK_ENV"=>"production","MERB_ENV"=>"production"} end - + it "sets destination to $deploy_to/shared/$repository_cache" do @resource.destination.should eql("/my/deploy/dir/shared/cached-copy") end - + it "sets shared_path to $deploy_to/shared" do @resource.shared_path.should eql("/my/deploy/dir/shared") end - + it "sets current_path to $deploy_to/current" do @resource.current_path.should eql("/my/deploy/dir/current") end - + it "gets the current_path correct even if the shared_path is set (regression test)" do @resource.shared_path @resource.current_path.should eql("/my/deploy/dir/current") end - + it "gives #depth as 5 if shallow clone is true, nil otherwise" do @resource.depth.should be_nil @resource.shallow_clone true @resource.depth.should eql("5") end - + it "aliases repo as repository" do @resource.repository "git@github.com/opcode/cookbooks.git" @resource.repo.should eql("git@github.com/opcode/cookbooks.git") end - + it "aliases git_ssh_wrapper as ssh_wrapper" do @resource.ssh_wrapper "git_my_repo.sh" @resource.git_ssh_wrapper.should eql("git_my_repo.sh") end - + it "has an Array attribute purge_before_symlink, default: log, tmp/pids, public/system" do @resource.purge_before_symlink.should == %w{ log tmp/pids public/system } @resource.purge_before_symlink %w{foo bar baz} @resource.purge_before_symlink.should == %w{foo bar baz} end - + it "has an Array attribute create_dirs_before_symlink, default: tmp, public, config" do @resource.create_dirs_before_symlink.should == %w{tmp public config} @resource.create_dirs_before_symlink %w{foo bar baz} @resource.create_dirs_before_symlink.should == %w{foo bar baz} end - + it 'has a Hash attribute symlinks, default: {"system" => "public/system", "pids" => "tmp/pids", "log" => "log"}' do default = { "system" => "public/system", "pids" => "tmp/pids", "log" => "log"} @resource.symlinks.should == default @resource.symlinks "foo" => "bar/baz" @resource.symlinks.should == {"foo" => "bar/baz"} end - + it 'has a Hash attribute symlink_before_migrate, default "config/database.yml" => "config/database.yml"' do @resource.symlink_before_migrate.should == {"config/database.yml" => "config/database.yml"} @resource.symlink_before_migrate "wtf?" => "wtf is going on" @resource.symlink_before_migrate.should == {"wtf?" => "wtf is going on"} end - + resource_has_a_callback_attribute :before_migrate resource_has_a_callback_attribute :before_symlink resource_has_a_callback_attribute :before_restart resource_has_a_callback_attribute :after_restart - + it "aliases restart_command as restart" do @resource.restart "foobaz" @resource.restart_command.should == "foobaz" end - + it "takes a block for the restart parameter" do restart_like_this = lambda {p :noop} @resource.restart(&restart_like_this) @resource.restart.should == restart_like_this end - + it "defaults to using the Deploy::Timestamped provider" do @resource.provider.should == Chef::Provider::Deploy::Timestamped end - + it "allows providers to be set with a full class name" do @resource.provider Chef::Provider::Deploy::Timestamped @resource.provider.should == Chef::Provider::Deploy::Timestamped end - + it "allows deploy providers to be set via symbol" do @resource.provider :revision @resource.provider.should == Chef::Provider::Deploy::Revision end - + it "allows deploy providers to be set via string" do @resource.provider "revision" @resource.provider.should == Chef::Provider::Deploy::Revision @@ -245,7 +245,7 @@ describe Chef::Resource::Deploy do describe "when it has meta application root, revision, user, group, scm provider, repository cache, environment, simlinks and migrate" do - before do + before do @resource.repository("http://uri.org") @resource.deploy_to("/") @resource.revision("1.2.3") @@ -256,7 +256,7 @@ describe Chef::Resource::Deploy do @resource.environment({"SUDO" => "TRUE"}) @resource.symlinks({"system" => "public/system"}) @resource.migrate(false) - + end it "describes its state" do @@ -269,5 +269,5 @@ describe Chef::Resource::Deploy do @resource.identity.should == "http://uri.org" end end - + end diff --git a/spec/unit/resource/directory_spec.rb b/spec/unit/resource/directory_spec.rb index 9b0c8242e6..dc042c5a77 100644 --- a/spec/unit/resource/directory_spec.rb +++ b/spec/unit/resource/directory_spec.rb @@ -61,7 +61,7 @@ describe Chef::Resource::Directory do end describe "when it has group, mode, and owner" do - before do + before do @resource.path("/tmp/foo/bar/") @resource.group("wheel") @resource.mode("0664") diff --git a/spec/unit/resource/dpkg_package_spec.rb b/spec/unit/resource/dpkg_package_spec.rb index 000908712f..9ef498a577 100644 --- a/spec/unit/resource/dpkg_package_spec.rb +++ b/spec/unit/resource/dpkg_package_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,19 +19,19 @@ require 'spec_helper' describe Chef::Resource::DpkgPackage, "initialize" do - + before(:each) do @resource = Chef::Resource::DpkgPackage.new("foo") end - + it "should return a Chef::Resource::DpkgPackage" do @resource.should be_a_kind_of(Chef::Resource::DpkgPackage) end - + it "should set the resource_name to :dpkg_package" do @resource.resource_name.should eql(:dpkg_package) end - + it "should set the provider to Chef::Provider::Package::Dpkg" do @resource.provider.should eql(Chef::Provider::Package::Dpkg) end diff --git a/spec/unit/resource/env_spec.rb b/spec/unit/resource/env_spec.rb index 6862c669b2..b53cbe478f 100644 --- a/spec/unit/resource/env_spec.rb +++ b/spec/unit/resource/env_spec.rb @@ -66,7 +66,7 @@ describe Chef::Resource::Env do end describe "when it has key name and value" do - before do + before do @resource.key_name("charmander") @resource.value("level7") @resource.delim("hi") diff --git a/spec/unit/resource/erl_call_spec.rb b/spec/unit/resource/erl_call_spec.rb index ccad371723..49df9639d1 100644 --- a/spec/unit/resource/erl_call_spec.rb +++ b/spec/unit/resource/erl_call_spec.rb @@ -68,7 +68,7 @@ describe Chef::Resource::ErlCall do end describe "when it has cookie and node_name" do - before do + before do @resource.code("erl-call:function()") @resource.cookie("cookie") @resource.node_name("raster") diff --git a/spec/unit/resource/freebsd_package_spec.rb b/spec/unit/resource/freebsd_package_spec.rb index 697f5fff06..b80a94f98d 100644 --- a/spec/unit/resource/freebsd_package_spec.rb +++ b/spec/unit/resource/freebsd_package_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,19 +19,19 @@ require 'spec_helper' describe Chef::Resource::FreebsdPackage, "initialize" do - + before(:each) do @resource = Chef::Resource::FreebsdPackage.new("foo") end - + it "should return a Chef::Resource::FreebsdPackage" do @resource.should be_a_kind_of(Chef::Resource::FreebsdPackage) end - + it "should set the resource_name to :freebsd_package" do @resource.resource_name.should eql(:freebsd_package) end - + it "should set the provider to Chef::Provider::Package::freebsd" do @resource.provider.should eql(Chef::Provider::Package::Freebsd) end diff --git a/spec/unit/resource/gem_package_spec.rb b/spec/unit/resource/gem_package_spec.rb index 2404afa03a..98703455de 100644 --- a/spec/unit/resource/gem_package_spec.rb +++ b/spec/unit/resource/gem_package_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,19 +19,19 @@ require 'spec_helper' describe Chef::Resource::GemPackage, "initialize" do - + before(:each) do @resource = Chef::Resource::GemPackage.new("foo") end - + it "should return a Chef::Resource::GemPackage" do @resource.should be_a_kind_of(Chef::Resource::GemPackage) end - + it "should set the resource_name to :gem_package" do @resource.resource_name.should eql(:gem_package) end - + it "should set the provider to Chef::Provider::Package::Rubygems" do @resource.provider.should eql(Chef::Provider::Package::Rubygems) end diff --git a/spec/unit/resource/git_spec.rb b/spec/unit/resource/git_spec.rb index 69b40ffd42..95a30c28a4 100644 --- a/spec/unit/resource/git_spec.rb +++ b/spec/unit/resource/git_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,28 +19,28 @@ require 'spec_helper' describe Chef::Resource::Git do - + before(:each) do @git = Chef::Resource::Git.new("my awesome webapp") end - + it "is a kind of Scm Resource" do @git.should be_a_kind_of(Chef::Resource::Scm) @git.should be_an_instance_of(Chef::Resource::Git) end - + it "uses the git provider" do @git.provider.should eql(Chef::Provider::Git) end - + it "uses aliases revision as branch" do @git.branch "HEAD" @git.revision.should eql("HEAD") end - + it "aliases revision as reference" do @git.reference "v1.0 tag" @git.revision.should eql("v1.0 tag") end - + end diff --git a/spec/unit/resource/group_spec.rb b/spec/unit/resource/group_spec.rb index 4e6828ca30..df68c5691f 100644 --- a/spec/unit/resource/group_spec.rb +++ b/spec/unit/resource/group_spec.rb @@ -7,9 +7,9 @@ # 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. @@ -22,7 +22,7 @@ require 'spec_helper' describe Chef::Resource::Group, "initialize" do before(:each) do @resource = Chef::Resource::Group.new("admin") - end + end it "should create a new Chef::Resource::Group" do @resource.should be_a_kind_of(Chef::Resource) @@ -32,7 +32,7 @@ describe Chef::Resource::Group, "initialize" do it "should set the resource_name to :group" do @resource.resource_name.should eql(:group) end - + it "should set the group_name equal to the argument to initialize" do @resource.group_name.should eql("admin") end @@ -40,7 +40,7 @@ describe Chef::Resource::Group, "initialize" do it "should default gid to nil" do @resource.gid.should eql(nil) end - + it "should default members to an empty array" do @resource.members.should eql([]) end @@ -48,11 +48,11 @@ describe Chef::Resource::Group, "initialize" do it "should alias users to members, also an empty array" do @resource.users.should eql([]) end - + it "should set action to :create" do @resource.action.should eql(:create) end - + %w{create remove modify manage}.each do |action| it "should allow action #{action}" do @resource.allowed_actions.detect { |a| a == action.to_sym }.should eql(action.to_sym) @@ -125,11 +125,11 @@ describe Chef::Resource::Group, "append" do before(:each) do @resource = Chef::Resource::Group.new("admin") end - + it "should default to false" do @resource.append.should eql(false) end - + it "should allow a boolean" do @resource.append true @resource.append.should eql(true) @@ -138,9 +138,9 @@ describe Chef::Resource::Group, "append" do it "should not allow a hash" do lambda { @resource.send(:gid, { :aj => "is freakin awesome" }) }.should raise_error(ArgumentError) end - + describe "when it has members" do - before do + before do @resource.group_name("pokemon") @resource.members(["blastoise", "pikachu"]) end diff --git a/spec/unit/resource/http_request_spec.rb b/spec/unit/resource/http_request_spec.rb index 924cf66fc2..b636ca9994 100644 --- a/spec/unit/resource/http_request_spec.rb +++ b/spec/unit/resource/http_request_spec.rb @@ -7,9 +7,9 @@ # 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. @@ -23,7 +23,7 @@ describe Chef::Resource::HttpRequest do before(:each) do @resource = Chef::Resource::HttpRequest.new("fakey_fakerton") - end + end it "should create a new Chef::Resource::HttpRequest" do @resource.should be_a_kind_of(Chef::Resource) @@ -34,18 +34,18 @@ describe Chef::Resource::HttpRequest do @resource.url "http://slashdot.org" @resource.url.should eql("http://slashdot.org") end - + it "should set the message to the name by default" do @resource.message.should eql("fakey_fakerton") end - + it "should set message to a string" do @resource.message "monkeybars" @resource.message.should eql("monkeybars") end describe "when it has a message and headers" do - before do + before do @resource.url("http://www.trololol.net") @resource.message("Get sum post brah.") @resource.headers({"head" => "tail"}) @@ -55,5 +55,5 @@ describe Chef::Resource::HttpRequest do @resource.identity.should == "http://www.trololol.net" end end - + end diff --git a/spec/unit/resource/ifconfig_spec.rb b/spec/unit/resource/ifconfig_spec.rb index 58869d5107..10a4d09982 100644 --- a/spec/unit/resource/ifconfig_spec.rb +++ b/spec/unit/resource/ifconfig_spec.rb @@ -28,7 +28,7 @@ describe Chef::Resource::Ifconfig do end describe "when it has target, hardware address, inet address, and a mask" do - before do + before do @resource.device("charmander") @resource.target("team_rocket") @resource.hwaddr("11.2223.223") diff --git a/spec/unit/resource/ips_package_spec.rb b/spec/unit/resource/ips_package_spec.rb index 92e62606de..61661922fa 100644 --- a/spec/unit/resource/ips_package_spec.rb +++ b/spec/unit/resource/ips_package_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,19 +19,19 @@ require 'spec_helper' describe Chef::Resource::IpsPackage, "initialize" do - + before(:each) do @resource = Chef::Resource::IpsPackage.new("crypto/gnupg") end - + it "should return a Chef::Resource::IpsPackage" do @resource.should be_a_kind_of(Chef::Resource::IpsPackage) end - + it "should set the resource_name to :ips_package" do @resource.resource_name.should eql(:ips_package) end - + it "should set the provider to Chef::Provider::Package::Ips" do @resource.provider.should eql(Chef::Provider::Package::Ips) end diff --git a/spec/unit/resource/link_spec.rb b/spec/unit/resource/link_spec.rb index bf01bce766..fc3f7ff41c 100644 --- a/spec/unit/resource/link_spec.rb +++ b/spec/unit/resource/link_spec.rb @@ -97,7 +97,7 @@ describe Chef::Resource::Link do end describe "when it has to, link_type, owner, and group" do - before do + before do @resource.target_file("/var/target.tar") @resource.to("/to/dir/file.tar") @resource.link_type(:symbolic) diff --git a/spec/unit/resource/log_spec.rb b/spec/unit/resource/log_spec.rb index 4c6b2c122d..4e439f5c5f 100644 --- a/spec/unit/resource/log_spec.rb +++ b/spec/unit/resource/log_spec.rb @@ -7,9 +7,9 @@ # 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. @@ -24,8 +24,8 @@ describe Chef::Resource::Log do before(:each) do @log_str = "this is my string to log" @resource = Chef::Resource::Log.new(@log_str) - end - + end + it "should create a new Chef::Resource::Log" do @resource.should be_a_kind_of(Chef::Resource) @resource.should be_a_kind_of(Chef::Resource::Log) @@ -47,7 +47,7 @@ describe Chef::Resource::Log do @resource.message "this is different" @resource.message.should == "this is different" end - + it "should accept a vaild level option" do @resource.level :debug @resource.level :info @@ -58,7 +58,7 @@ describe Chef::Resource::Log do end describe "when the identity is defined" do - before do + before do @resource = Chef::Resource::Log.new("ery day I'm loggin-in") end @@ -67,4 +67,3 @@ describe Chef::Resource::Log do end end end - diff --git a/spec/unit/resource/macports_package_spec.rb b/spec/unit/resource/macports_package_spec.rb index 7420fafeb5..7e2e200487 100644 --- a/spec/unit/resource/macports_package_spec.rb +++ b/spec/unit/resource/macports_package_spec.rb @@ -6,9 +6,9 @@ # 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. diff --git a/spec/unit/resource/mdadm_spec.rb b/spec/unit/resource/mdadm_spec.rb index c4e6704ceb..310f420659 100644 --- a/spec/unit/resource/mdadm_spec.rb +++ b/spec/unit/resource/mdadm_spec.rb @@ -80,13 +80,13 @@ describe Chef::Resource::Mdadm do end describe "when it has devices, level, and chunk" do - before do + before do @resource.raid_device("raider") @resource.devices(["device1", "device2"]) @resource.level(1) @resource.chunk(42) end - + it "describes its state" do state = @resource.state state[:devices].should eql(["device1", "device2"]) @@ -98,5 +98,5 @@ describe Chef::Resource::Mdadm do @resource.identity.should == "raider" end end - + end diff --git a/spec/unit/resource/mount_spec.rb b/spec/unit/resource/mount_spec.rb index 9f9a534a4e..fb414018ba 100644 --- a/spec/unit/resource/mount_spec.rb +++ b/spec/unit/resource/mount_spec.rb @@ -7,9 +7,9 @@ # 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. @@ -23,7 +23,7 @@ describe Chef::Resource::Mount do before(:each) do @resource = Chef::Resource::Mount.new("filesystem") end - + it "should create a new Chef::Resource::Mount" do @resource.should be_a_kind_of(Chef::Resource) @resource.should be_a_kind_of(Chef::Resource::Mount) @@ -36,18 +36,18 @@ describe Chef::Resource::Mount do it "should set mount_point to the name" do @resource.mount_point.should eql("filesystem") end - + it "should have a default action of mount" do @resource.action.should eql(:mount) end - + it "should accept mount, umount and remount as actions" do lambda { @resource.action :mount }.should_not raise_error(ArgumentError) lambda { @resource.action :umount }.should_not raise_error(ArgumentError) lambda { @resource.action :remount }.should_not raise_error(ArgumentError) lambda { @resource.action :brooklyn }.should raise_error(ArgumentError) end - + it "should allow you to set the device attribute" do @resource.device "/dev/sdb3" @resource.device.should eql("/dev/sdb3") @@ -76,19 +76,19 @@ describe Chef::Resource::Mount do @resource.options "rw,noexec" @resource.options.should be_a_kind_of(Array) end - + it "should allow options attribute as an array" do @resource.options ["ro", "nosuid"] @resource.options.should be_a_kind_of(Array) end it "should accept true for mounted" do - @resource.mounted(true) + @resource.mounted(true) @resource.mounted.should eql(true) end it "should accept false for mounted" do - @resource.mounted(false) + @resource.mounted(false) @resource.mounted.should eql(false) end @@ -101,12 +101,12 @@ describe Chef::Resource::Mount do end it "should accept true for enabled" do - @resource.enabled(true) + @resource.enabled(true) @resource.enabled.should eql(true) end it "should accept false for enabled" do - @resource.enabled(false) + @resource.enabled(false) @resource.enabled.should eql(false) end @@ -152,7 +152,7 @@ describe Chef::Resource::Mount do end describe "when it has mount point, device type, and fstype" do - before do + before do @resource.device("charmander") @resource.mount_point("123.456") @resource.device_type(:device) @@ -172,7 +172,7 @@ describe Chef::Resource::Mount do end describe "when it has username, password and domain" do - before do + before do @resource.mount_point("T:") @resource.device("charmander") @resource.username("Administrator") diff --git a/spec/unit/resource/ohai_spec.rb b/spec/unit/resource/ohai_spec.rb index 82df61e509..b8d062b4c9 100644 --- a/spec/unit/resource/ohai_spec.rb +++ b/spec/unit/resource/ohai_spec.rb @@ -43,7 +43,7 @@ describe Chef::Resource::Ohai do end describe "when it has a plugin value" do - before do + before do @resource.name("test") @resource.plugin("passwd") end diff --git a/spec/unit/resource/package_spec.rb b/spec/unit/resource/package_spec.rb index 3f9cc7a408..0f175dda12 100644 --- a/spec/unit/resource/package_spec.rb +++ b/spec/unit/resource/package_spec.rb @@ -7,9 +7,9 @@ # 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. @@ -23,7 +23,7 @@ describe Chef::Resource::Package do before(:each) do @resource = Chef::Resource::Package.new("emacs") - end + end it "should create a new Chef::Resource::Package" do @resource.should be_a_kind_of(Chef::Resource) @@ -38,12 +38,12 @@ describe Chef::Resource::Package 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") @@ -71,7 +71,7 @@ describe Chef::Resource::Package do state[:version].should == "10.9.8" state[:options].should == "-al" end - + it "returns the file path as its identity" do @resource.identity.should == "tomcat" end diff --git a/spec/unit/resource/pacman_package_spec.rb b/spec/unit/resource/pacman_package_spec.rb index 53ecd296c9..ec5feeb82c 100644 --- a/spec/unit/resource/pacman_package_spec.rb +++ b/spec/unit/resource/pacman_package_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,19 +19,19 @@ require 'spec_helper' describe Chef::Resource::PacmanPackage, "initialize" do - + before(:each) do @resource = Chef::Resource::PacmanPackage.new("foo") end - + it "should return a Chef::Resource::PacmanPackage" do @resource.should be_a_kind_of(Chef::Resource::PacmanPackage) end - + it "should set the resource_name to :pacman_package" do @resource.resource_name.should eql(:pacman_package) end - + it "should set the provider to Chef::Provider::Package::Pacman" do @resource.provider.should eql(Chef::Provider::Package::Pacman) end diff --git a/spec/unit/resource/perl_spec.rb b/spec/unit/resource/perl_spec.rb index f0313e6fb9..d25dc98563 100644 --- a/spec/unit/resource/perl_spec.rb +++ b/spec/unit/resource/perl_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -22,17 +22,17 @@ describe Chef::Resource::Perl do before(:each) do @resource = Chef::Resource::Perl.new("fakey_fakerton") - end + 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 diff --git a/spec/unit/resource/portage_package_spec.rb b/spec/unit/resource/portage_package_spec.rb index da086d95ba..510f3b5864 100644 --- a/spec/unit/resource/portage_package_spec.rb +++ b/spec/unit/resource/portage_package_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,19 +19,19 @@ require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper")) describe Chef::Resource::PortagePackage, "initialize" do - + before(:each) do @resource = Chef::Resource::PortagePackage.new("foo") end - + it "should return a Chef::Resource::PortagePackage" do @resource.should be_a_kind_of(Chef::Resource::PortagePackage) end - + it "should set the resource_name to :portage_package" do @resource.resource_name.should eql(:portage_package) end - + it "should set the provider to Chef::Provider::Package::Portage" do @resource.provider.should eql(Chef::Provider::Package::Portage) end diff --git a/spec/unit/resource/powershell_spec.rb b/spec/unit/resource/powershell_spec.rb index 6ec37583e6..a35e37c696 100644 --- a/spec/unit/resource/powershell_spec.rb +++ b/spec/unit/resource/powershell_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -30,19 +30,19 @@ describe Chef::Resource::PowershellScript do @resource = Chef::Resource::PowershellScript.new("powershell_unit_test", run_context) - end + end it "should create a new Chef::Resource::PowershellScript" do @resource.should be_a_kind_of(Chef::Resource::PowershellScript) end - + context "windowsscript" do let(:resource_instance) { @resource } let(:resource_instance_name ) { @resource.command } let(:resource_name) { :powershell_script } let(:interpreter_file_name) { 'powershell.exe' } - it_should_behave_like "a Windows script resource" + it_should_behave_like "a Windows script resource" end end diff --git a/spec/unit/resource/python_spec.rb b/spec/unit/resource/python_spec.rb index ff9547db9a..3362b68c62 100644 --- a/spec/unit/resource/python_spec.rb +++ b/spec/unit/resource/python_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -22,17 +22,17 @@ describe Chef::Resource::Python do before(:each) do @resource = Chef::Resource::Python.new("fakey_fakerton") - end + 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 diff --git a/spec/unit/resource/registry_key_spec.rb b/spec/unit/resource/registry_key_spec.rb index 9d7680de0c..3f227e26b6 100644 --- a/spec/unit/resource/registry_key_spec.rb +++ b/spec/unit/resource/registry_key_spec.rb @@ -6,9 +6,9 @@ # 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. diff --git a/spec/unit/resource/remote_directory_spec.rb b/spec/unit/resource/remote_directory_spec.rb index e4fa8fc4e3..d3800062ae 100644 --- a/spec/unit/resource/remote_directory_spec.rb +++ b/spec/unit/resource/remote_directory_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -22,7 +22,7 @@ describe Chef::Resource::RemoteDirectory do before(:each) do @resource = Chef::Resource::RemoteDirectory.new("/etc/dunk") - end + end it "should create a new Chef::Resource::RemoteDirectory" do @resource.should be_a_kind_of(Chef::Resource) @@ -46,35 +46,35 @@ describe Chef::Resource::RemoteDirectory 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 - + describe "when it has cookbook, files owner, files mode, and source" do - before do + before do @resource.path("/var/path/") @resource.cookbook("pokemon.rb") @resource.files_owner("root") diff --git a/spec/unit/resource/remote_file_spec.rb b/spec/unit/resource/remote_file_spec.rb index 93fb3c0c36..643bc8ba21 100644 --- a/spec/unit/resource/remote_file_spec.rb +++ b/spec/unit/resource/remote_file_spec.rb @@ -7,9 +7,9 @@ # 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. @@ -123,7 +123,7 @@ describe Chef::Resource::RemoteFile do end describe "when it has group, mode, owner, source, and checksum" do - before do + before do if Chef::Platform.windows? @resource.path("C:/temp/origin/file.txt") @resource.rights(:read, "Everyone") @@ -144,7 +144,7 @@ describe Chef::Resource::RemoteFile do puts state state[:rights].should == [{:permissions => :read, :principals => "Everyone"}] state[:deny_rights].should == [{:permissions => :full_control, :principals => "Clumsy_Sam"}] - else + else state[:group].should == "pokemon" state[:mode].should == "0664" state[:owner].should == "root" diff --git a/spec/unit/resource/route_spec.rb b/spec/unit/resource/route_spec.rb index 966b3aed34..bca42f1101 100644 --- a/spec/unit/resource/route_spec.rb +++ b/spec/unit/resource/route_spec.rb @@ -7,9 +7,9 @@ # 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. @@ -23,31 +23,31 @@ describe Chef::Resource::Route do before(:each) do @resource = Chef::Resource::Route.new("10.0.0.10") - end + end it "should create a new Chef::Resource::Route" do @resource.should be_a_kind_of(Chef::Resource) @resource.should be_a_kind_of(Chef::Resource::Route) end - + it "should have a name" do @resource.name.should eql("10.0.0.10") end - + it "should have a default action of 'add'" do @resource.action.should eql([:add]) end - + it "should accept add or delete for action" do lambda { @resource.action :add }.should_not raise_error(ArgumentError) lambda { @resource.action :delete }.should_not raise_error(ArgumentError) lambda { @resource.action :lolcat }.should raise_error(ArgumentError) end - + it "should use the object name as the target by default" do @resource.target.should eql("10.0.0.10") end - + it "should allow you to specify the netmask" do @resource.netmask "255.255.255.0" @resource.netmask.should eql("255.255.255.0") @@ -72,22 +72,22 @@ describe Chef::Resource::Route do @resource.route_type "host" @resource.route_type.should eql(:host) end - + it "should default to a host route type" do @resource.route_type.should eql(:host) end - + it "should accept a net route type" do @resource.route_type :net @resource.route_type.should eql(:net) end - + it "should reject any other route_type but :host and :net" do lambda { @resource.route_type "lolcat" }.should raise_error(ArgumentError) end - + describe "when it has netmask, gateway, and device" do - before do + before do @resource.target("charmander") @resource.netmask("lemask") @resource.gateway("111.111.111") diff --git a/spec/unit/resource/rpm_package_spec.rb b/spec/unit/resource/rpm_package_spec.rb index d59dc6b29c..25930a5484 100644 --- a/spec/unit/resource/rpm_package_spec.rb +++ b/spec/unit/resource/rpm_package_spec.rb @@ -6,9 +6,9 @@ # 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. diff --git a/spec/unit/resource/ruby_block_spec.rb b/spec/unit/resource/ruby_block_spec.rb index 637d4fe34d..82bbd1ffc7 100644 --- a/spec/unit/resource/ruby_block_spec.rb +++ b/spec/unit/resource/ruby_block_spec.rb @@ -7,9 +7,9 @@ # 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. @@ -33,7 +33,7 @@ describe Chef::Resource::RubyBlock do it "should have a default action of 'create'" do @resource.action.should eql("run") end - + it "should have a resource name of :ruby_block" do @resource.resource_name.should eql(:ruby_block) end @@ -50,7 +50,7 @@ describe Chef::Resource::RubyBlock do end describe "when it has been initialized with block code" do - before do + before do @resource.block_name("puts 'harrrr'") end diff --git a/spec/unit/resource/ruby_spec.rb b/spec/unit/resource/ruby_spec.rb index 48dfd90898..9bf7316e6d 100644 --- a/spec/unit/resource/ruby_spec.rb +++ b/spec/unit/resource/ruby_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -22,17 +22,17 @@ describe Chef::Resource::Ruby do before(:each) do @resource = Chef::Resource::Ruby.new("fakey_fakerton") - end + 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 diff --git a/spec/unit/resource/scm_spec.rb b/spec/unit/resource/scm_spec.rb index d88a4160e7..8f6593a931 100644 --- a/spec/unit/resource/scm_spec.rb +++ b/spec/unit/resource/scm_spec.rb @@ -151,7 +151,7 @@ describe Chef::Resource::Scm do end describe "when it has repository, revision, user, and group" do - before do + before do @resource.destination("hell") @resource.repository("apt") @resource.revision("1.2.3") diff --git a/spec/unit/resource/script_spec.rb b/spec/unit/resource/script_spec.rb index 53735daf01..f100b0dc85 100644 --- a/spec/unit/resource/script_spec.rb +++ b/spec/unit/resource/script_spec.rb @@ -7,9 +7,9 @@ # 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. @@ -20,7 +20,7 @@ require 'spec_helper' describe Chef::Resource::Script do - let(:resource_instance_name) { "fakey_fakerton" } + let(:resource_instance_name) { "fakey_fakerton" } let(:script_resource) { Chef::Resource::Script.new(resource_instance_name) } let(:resource_name) { :script } @@ -30,7 +30,7 @@ describe Chef::Resource::Script do end describe "when it has interpreter and flags" do - before do + before do script_resource.command("grep") script_resource.interpreter("gcc") script_resource.flags("-al") @@ -40,7 +40,7 @@ describe Chef::Resource::Script do script_resource.identity.should == "grep" end end - + it_behaves_like "a script resource" end diff --git a/spec/unit/resource/service_spec.rb b/spec/unit/resource/service_spec.rb index c06eb9dd77..067fa7d0d3 100644 --- a/spec/unit/resource/service_spec.rb +++ b/spec/unit/resource/service_spec.rb @@ -7,9 +7,9 @@ # 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. @@ -23,7 +23,7 @@ describe Chef::Resource::Service do before(:each) do @resource = Chef::Resource::Service.new("chef") - end + end it "should create a new Chef::Resource::Service" do @resource.should be_a_kind_of(Chef::Resource) @@ -42,7 +42,7 @@ describe Chef::Resource::Service 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(".*") @@ -53,7 +53,7 @@ describe Chef::Resource::Service do @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") @@ -64,7 +64,7 @@ describe Chef::Resource::Service do @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") @@ -75,23 +75,23 @@ describe Chef::Resource::Service do @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 /.*/ @@ -102,13 +102,13 @@ describe Chef::Resource::Service do @resource.reload_command "/etc/init.d/chef reload" @resource.reload_command.should eql("/etc/init.d/chef reload") end - + it "should not accept a regexp for the service reload command" do lambda { @resource.reload_command /.*/ }.should raise_error(ArgumentError) end - + it "should accept a string for the service init command" do @resource.init_command "/etc/init.d/chef" @resource.init_command.should eql("/etc/init.d/chef") @@ -122,15 +122,15 @@ describe Chef::Resource::Service do %w{enabled running}.each do |attrib| it "should accept true for #{attrib}" do - @resource.send(attrib, true) + @resource.send(attrib, true) @resource.send(attrib).should eql(true) end - + it "should accept false for #{attrib}" do @resource.send(attrib, false) @resource.send(attrib).should eql(false) end - + it "should not accept a string for #{attrib}" do lambda { @resource.send(attrib, "poop") }.should raise_error(ArgumentError) end @@ -138,7 +138,7 @@ describe Chef::Resource::Service do it "should default all the feature support to false" do support_hash = { :status => false, :restart => false, :reload=> false } @resource.supports.should == support_hash - end + end it "should allow you to set what features this resource supports as a array" do support_array = [ :status, :restart ] @@ -155,7 +155,7 @@ describe Chef::Resource::Service do end describe "when it has pattern and supports" do - before do + before do @resource.service_name("superfriend") @resource.enabled(true) @resource.running(false) @@ -172,5 +172,5 @@ describe Chef::Resource::Service do end end - + end diff --git a/spec/unit/resource/smartos_package_spec.rb b/spec/unit/resource/smartos_package_spec.rb index ca815320ad..4898311bf0 100644 --- a/spec/unit/resource/smartos_package_spec.rb +++ b/spec/unit/resource/smartos_package_spec.rb @@ -6,9 +6,9 @@ # 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. diff --git a/spec/unit/resource/subversion_spec.rb b/spec/unit/resource/subversion_spec.rb index 650eb010a6..67593c5a7c 100644 --- a/spec/unit/resource/subversion_spec.rb +++ b/spec/unit/resource/subversion_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,20 +19,20 @@ require 'spec_helper' describe Chef::Resource::Subversion do - + before do @svn = Chef::Resource::Subversion.new("ohai, svn project!") end - + it "is a subclass of Resource::Scm" do @svn.should be_an_instance_of(Chef::Resource::Subversion) @svn.should be_a_kind_of(Chef::Resource::Scm) end - + it "uses the subversion provider" do @svn.provider.should eql(Chef::Provider::Subversion) end - + it "allows the force_export action" do @svn.allowed_actions.should include(:force_export) end diff --git a/spec/unit/resource/timestamped_deploy_spec.rb b/spec/unit/resource/timestamped_deploy_spec.rb index 89b881830a..f380ffca87 100644 --- a/spec/unit/resource/timestamped_deploy_spec.rb +++ b/spec/unit/resource/timestamped_deploy_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,10 +19,10 @@ require 'spec_helper' describe Chef::Resource::TimestampedDeploy do - + it "defaults to the TimestampedDeploy provider" do @resource = Chef::Resource::TimestampedDeploy.new("stuff") @resource.provider.should == Chef::Provider::Deploy::Timestamped end - + end diff --git a/spec/unit/resource/user_spec.rb b/spec/unit/resource/user_spec.rb index 3454152367..caf12aa416 100644 --- a/spec/unit/resource/user_spec.rb +++ b/spec/unit/resource/user_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -21,7 +21,7 @@ require 'spec_helper' describe Chef::Resource::User, "initialize" do before(:each) do @resource = Chef::Resource::User.new("adam") - end + end it "should create a new Chef::Resource::User" do @resource.should be_a_kind_of(Chef::Resource) @@ -31,29 +31,29 @@ describe Chef::Resource::User, "initialize" do it "should set the resource_name to :user" do @resource.resource_name.should eql(:user) end - + it "should set the username equal to the argument to initialize" do @resource.username.should eql("adam") end - + %w{comment uid gid home shell password}.each do |attrib| it "should set #{attrib} to nil" do @resource.send(attrib).should eql(nil) end end - + it "should set action to :create" do @resource.action.should eql(:create) end - + it "should set supports[:manage_home] to false" do @resource.supports[:manage_home].should eql(false) end - + it "should set supports[:non_unique] to false" do @resource.supports[:non_unique].should eql(false) end - + %w{create remove modify manage lock unlock}.each do |action| it "should allow action #{action}" do @resource.allowed_actions.detect { |a| a == action.to_sym }.should eql(action.to_sym) @@ -72,7 +72,7 @@ end describe Chef::Resource::User, attrib do before(:each) do @resource = Chef::Resource::User.new("adam") - end + end it "should allow a string" do @resource.send(attrib, "adam") @@ -89,13 +89,13 @@ end describe Chef::Resource::User, attrib do before(:each) do @resource = Chef::Resource::User.new("adam") - end + end it "should allow a string" do @resource.send(attrib, "100") @resource.send(attrib).should eql("100") end - + it "should allow an integer" do @resource.send(attrib, 100) @resource.send(attrib).should eql(100) @@ -105,7 +105,7 @@ end lambda { @resource.send(attrib, { :woot => "i found it" }) }.should raise_error(ArgumentError) end end - + describe "when it has uid, gid, and home" do before do @resource = Chef::Resource::User.new("root") diff --git a/spec/unit/resource/yum_package_spec.rb b/spec/unit/resource/yum_package_spec.rb index a0f4aaee55..783a539eb2 100644 --- a/spec/unit/resource/yum_package_spec.rb +++ b/spec/unit/resource/yum_package_spec.rb @@ -6,9 +6,9 @@ # 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. @@ -19,19 +19,19 @@ require 'spec_helper' describe Chef::Resource::YumPackage, "initialize" do - + before(:each) do @resource = Chef::Resource::YumPackage.new("foo") end - + it "should return a Chef::Resource::YumPackage" do @resource.should be_a_kind_of(Chef::Resource::YumPackage) end - + it "should set the resource_name to :yum_package" do @resource.resource_name.should eql(:yum_package) end - + it "should set the provider to Chef::Provider::Package::Yum" do @resource.provider.should eql(Chef::Provider::Package::Yum) end @@ -56,7 +56,7 @@ describe Chef::Resource::YumPackage, "flush_cache" do it "should default the flush timing to false" do flush_hash = { :before => false, :after => false } @resource.flush_cache.should == flush_hash - end + end it "should allow you to set the flush timing with an array" do flush_array = [ :before, :after ] |