diff options
Diffstat (limited to 'spec/unit/provider')
45 files changed, 304 insertions, 304 deletions
diff --git a/spec/unit/provider/cron_spec.rb b/spec/unit/provider/cron_spec.rb index f0d800741d..8a819b699c 100644 --- a/spec/unit/provider/cron_spec.rb +++ b/spec/unit/provider/cron_spec.rb @@ -181,7 +181,7 @@ CRONTAB before :each do @provider.stub!(:read_crontab).and_return(<<-CRONTAB) 0 2 * * * /some/other/command - + # Chef Name: cronhole some stuff * 5 * Jan Mon /bin/true param1 param2 # Chef Name: something else @@ -196,7 +196,7 @@ CRONTAB @provider.cron_exists.should == true @provider.cron_empty.should == false end - + it "should pull the details out of the cron line" do cron = @provider.load_current_resource cron.minute.should == '*' @@ -581,7 +581,7 @@ CRONTAB end it "should log nothing changed" do - Chef::Log.should_receive(:debug).with("Found cron '#{@new_resource.name}'") + Chef::Log.should_receive(:debug).with("Found cron '#{@new_resource.name}'") Chef::Log.should_receive(:debug).with("Skipping existing cron entry '#{@new_resource.name}'") @provider.run_action(:create) end diff --git a/spec/unit/provider/deploy/timestamped_spec.rb b/spec/unit/provider/deploy/timestamped_spec.rb index b891a03ce2..a9cea1142e 100644 --- a/spec/unit/provider/deploy/timestamped_spec.rb +++ b/spec/unit/provider/deploy/timestamped_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::Provider::Deploy::Timestamped do - + before do @release_time = Time.utc( 2004, 8, 15, 16, 23, 42) Time.stub!(:now).and_return(@release_time) @@ -32,9 +32,9 @@ describe Chef::Provider::Deploy::Timestamped do @runner = mock("runnah") Chef::Runner.stub!(:new).and_return(@runner) end - + it "gives a timestamp for release_slug" do @timestamped_deploy.send(:release_slug).should == "20040815162342" end - + end diff --git a/spec/unit/provider/deploy_spec.rb b/spec/unit/provider/deploy_spec.rb index 0d837f99c3..1a9fee8831 100644 --- a/spec/unit/provider/deploy_spec.rb +++ b/spec/unit/provider/deploy_spec.rb @@ -163,18 +163,18 @@ describe Chef::Provider::Deploy do @provider.stub!(:deploy).and_return{ raise "Unexpected error" } @provider.stub!(:previous_release_path).and_return('previous_release') @provider.should_not_receive(:rollback) - lambda { + lambda { @provider.run_action(:deploy) }.should raise_exception(RuntimeError, "Unexpected error") end - + it "rollbacks to previous release if error happens on deploy" do @resource.rollback_on_error true @provider.stub!(:all_releases).and_return(['previous_release']) @provider.stub!(:deploy).and_return{ raise "Unexpected error" } @provider.stub!(:previous_release_path).and_return('previous_release') @provider.should_receive(:rollback) - lambda { + lambda { @provider.run_action(:deploy) }.should raise_exception(RuntimeError, "Unexpected error") end @@ -225,15 +225,15 @@ describe Chef::Provider::Deploy do #FileUtils.should_receive(:rm_rf).with("/my/deploy/dir/releases/20040815162342") #@provider.run_action(:rollback) #@provider.release_path.should eql(NIL) -- no check needed since assertions will fail - lambda { + lambda { @provider.run_action(:rollback) }.should raise_exception(RuntimeError, "There is no release to rollback to!") end - + it "an exception is raised when there are no releases" do all_releases = [] Dir.stub!(:glob).with("/my/deploy/dir/releases/*").and_return(all_releases) - lambda { + lambda { @provider.run_action(:rollback) }.should raise_exception(RuntimeError, "There is no release to rollback to!") end @@ -433,7 +433,7 @@ describe Chef::Provider::Deploy do @provider.should_receive(:enforce_ownership) @provider.link_tempfiles_to_current_release end - + end it "does nothing for restart if restart_command is empty" do diff --git a/spec/unit/provider/execute_spec.rb b/spec/unit/provider/execute_spec.rb index bf913cca12..0d108f521d 100644 --- a/spec/unit/provider/execute_spec.rb +++ b/spec/unit/provider/execute_spec.rb @@ -31,7 +31,7 @@ describe Chef::Provider::Execute do @provider = Chef::Provider::Execute.new(@new_resource, @run_context) @current_resource = Chef::Resource::Ifconfig.new("foo_resource", @run_context) @provider.current_resource = @current_resource - Chef::Log.level = :info + Chef::Log.level = :info # FIXME: There should be a test for how STDOUT.tty? changes the live_stream option being passed STDOUT.stub!(:tty?).and_return(true) end @@ -73,7 +73,7 @@ describe Chef::Provider::Execute do @provider.run_action(:run) @new_resource.should_not be_updated - end + end it "should warn if user specified relative path without cwd" do @new_resource.creates "foo_resource" diff --git a/spec/unit/provider/group/dscl_spec.rb b/spec/unit/provider/group/dscl_spec.rb index b526848dfd..28d78cbdbd 100644 --- a/spec/unit/provider/group/dscl_spec.rb +++ b/spec/unit/provider/group/dscl_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,14 +27,14 @@ describe Chef::Provider::Group::Dscl do @current_resource = Chef::Resource::Group.new("aj") @provider = Chef::Provider::Group::Dscl.new(@new_resource, @run_context) @provider.current_resource = @current_resource - @status = mock("Process::Status", :exitstatus => 0) + @status = mock("Process::Status", :exitstatus => 0) @pid = 2342 @stdin = StringIO.new @stdout = StringIO.new("\n") @stderr = StringIO.new("") @provider.stub!(:popen4).and_yield(@pid,@stdin,@stdout,@stderr).and_return(@status) end - + it "should run popen4 with the supplied array of arguments appended to the dscl command" do @provider.should_receive(:popen4).with("dscl . -cmd /Path arg1 arg2") @provider.dscl("cmd", "/Path", "arg1", "arg2") @@ -52,7 +52,7 @@ describe Chef::Provider::Group::Dscl do @provider = Chef::Provider::Group::Dscl.new(@node, @new_resource) @provider.stub!(:dscl).and_return(["cmd", @status, "stdout", "stderr"]) end - + it "should run dscl with the supplied cmd /Path args" do @provider.should_receive(:dscl).with("cmd /Path args") @provider.safe_dscl("cmd /Path args") @@ -84,7 +84,7 @@ describe Chef::Provider::Group::Dscl do lambda { @provider.safe_dscl("cmd /Path arguments") }.should raise_error(Chef::Exceptions::Group) end end - + describe "with the dscl command returning a zero exit status" do it "should return the third array element, the string of standard output" do safe_dscl_retval = @provider.safe_dscl("cmd /Path args") @@ -100,7 +100,7 @@ describe Chef::Provider::Group::Dscl do @provider = Chef::Provider::Group::Dscl.new(@node, @new_resource) @provider.stub!(:safe_dscl).and_return("\naj 200\njt 201\n") end - + it "should run safe_dscl with list /Groups gid" do @provider.should_receive(:safe_dscl).with("list /Groups gid") @provider.get_free_gid @@ -109,7 +109,7 @@ describe Chef::Provider::Group::Dscl do it "should return the first unused gid number on or above 200" do @provider.get_free_gid.should equal(202) end - + it "should raise an exception when the search limit is exhausted" do search_limit = 1 lambda { @provider.get_free_gid(search_limit) }.should raise_error(RuntimeError) @@ -127,7 +127,7 @@ describe Chef::Provider::Group::Dscl do @provider.should_receive(:safe_dscl).with("list /Groups gid") @provider.gid_used?(500) end - + it "should return true for a used gid number" do @provider.gid_used?(500).should be_true end @@ -151,7 +151,7 @@ describe Chef::Provider::Group::Dscl do lambda { @provider.set_gid }.should raise_error(Chef::Exceptions::Group) end end - + describe "with no gid number for the new resources" do it "should run get_free_gid and return a valid, unused gid number" do @provider.should_receive(:get_free_gid).and_return(501) @@ -220,7 +220,7 @@ describe Chef::Provider::Group::Dscl do @provider.set_members end end - + describe "with no members in the new resource" do before do @new_resource.append(true) @@ -276,7 +276,7 @@ describe Chef::Provider::Group::Dscl do @provider.should_receive(:set_gid) @provider.manage_group end - + it "should manage the members if it changed and the new resources members is not null" do @current_resource.members(%{charlie root}) @new_resource.members(%{crab revenge}) diff --git a/spec/unit/provider/group/gpasswd_spec.rb b/spec/unit/provider/group/gpasswd_spec.rb index 59da88e851..8889ba322e 100644 --- a/spec/unit/provider/group/gpasswd_spec.rb +++ b/spec/unit/provider/group/gpasswd_spec.rb @@ -36,8 +36,8 @@ describe Chef::Provider::Group::Gpasswd, "modify_group_members" do @provider.define_resource_requirements end - # Checking for required binaries is already done in the spec - # for Chef::Provider::Group - no need to repeat it here. We'll + # Checking for required binaries is already done in the spec + # for Chef::Provider::Group - no need to repeat it here. We'll # include only what's specific to this provider. it "should raise an error if the required binary /usr/bin/gpasswd doesn't exist" do File.stub!(:exists?).and_return(true) diff --git a/spec/unit/provider/group/groupmod_spec.rb b/spec/unit/provider/group/groupmod_spec.rb index c9c56313b5..69b96c6edb 100644 --- a/spec/unit/provider/group/groupmod_spec.rb +++ b/spec/unit/provider/group/groupmod_spec.rb @@ -29,7 +29,7 @@ describe Chef::Provider::Group::Groupmod do @new_resource.append false @provider = Chef::Provider::Group::Groupmod.new(@new_resource, @run_context) end - + describe "manage_group" do describe "when determining the current group state" do it "should raise an error if the required binary /usr/sbin/group doesn't exist" do @@ -41,25 +41,25 @@ describe Chef::Provider::Group::Groupmod do File.should_receive(:exists?).with("/usr/sbin/user").and_return(false) lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Group) end - + it "shouldn't raise an error if the required binaries exist" do File.stub!(:exists?).and_return(true) lambda { @provider.load_current_resource }.should_not raise_error(Chef::Exceptions::Group) end end - + describe "after the group's current state is known" do before do @current_resource = @new_resource.dup @provider.current_resource = @current_resource end - + describe "when no group members are specified and append is not set" do before do @new_resource.append(false) @new_resource.members([]) end - + it "logs a message and sets group's members to 'none', then removes existing group members" do Chef::Log.should_receive(:debug).with("group[wheel] setting group members to: none") Chef::Log.should_receive(:debug).with("group[wheel] removing members lobster, rage, fist") @@ -69,26 +69,26 @@ describe Chef::Provider::Group::Groupmod do @provider.manage_group end end - + describe "when no group members are specified and append is set" do before do @new_resource.append(true) @new_resource.members([]) end - + it "logs a message and does not modify group membership" do Chef::Log.should_receive(:debug).with("group[wheel] not changing group members, the group has no members to add") @provider.should_not_receive(:shell_out!) @provider.manage_group end end - + describe "when removing some group members" do before do @new_resource.append(false) @new_resource.members(%w{ lobster }) end - + it "updates group membership correctly" do Chef::Log.stub!(:debug) @provider.should_receive(:shell_out!).with("group mod -n wheel_bak wheel") @@ -100,14 +100,14 @@ describe Chef::Provider::Group::Groupmod do end end end - + describe "create_group" do describe "when creating a new group" do before do @current_resource = Chef::Resource::Group.new("wheel") @provider.current_resource = @current_resource end - + it "should run a group add command and some user mod commands" do @provider.should_receive(:shell_out!).with("group add -g '123' wheel") @provider.should_receive(:shell_out!).with("user mod -G wheel lobster") @@ -117,14 +117,14 @@ describe Chef::Provider::Group::Groupmod do end end end - + describe "remove_group" do describe "when removing an existing group" do before do @current_resource = @new_resource.dup @provider.current_resource = @current_resource end - + it "should run a group del command" do @provider.should_receive(:shell_out!).with("group del wheel") @provider.remove_group diff --git a/spec/unit/provider/group/pw_spec.rb b/spec/unit/provider/group/pw_spec.rb index a7dbdb8615..e7c38f9555 100644 --- a/spec/unit/provider/group/pw_spec.rb +++ b/spec/unit/provider/group/pw_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. @@ -23,7 +23,7 @@ describe Chef::Provider::Group::Pw do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - + @new_resource = Chef::Resource::Group.new("wheel") @new_resource.gid 50 @new_resource.members [ "root", "aj"] @@ -34,12 +34,12 @@ describe Chef::Provider::Group::Pw do @provider = Chef::Provider::Group::Pw.new(@new_resource, @run_context) @provider.current_resource = @current_resource end - + describe "when setting options for the pw command" do it "does not set the gid option if gids match or are unmanaged" do @provider.set_options.should == " wheel" end - + it "sets the option for gid if it is not nil" do @new_resource.gid(42) @provider.set_options.should eql(" wheel -g '42'") @@ -55,7 +55,7 @@ describe Chef::Provider::Group::Pw do end describe "when managing the group" do - + it "should run pw groupmod with the return of set_options" do @new_resource.gid(42) @provider.should_receive(:run_command).with({ :command => "pw groupmod wheel -g '42' -M root,aj" }).and_return(true) @@ -72,18 +72,18 @@ describe Chef::Provider::Group::Pw do end describe "when setting group membership" do - + describe "with an empty members array in both the new and current resource" do before do @new_resource.stub!(:members).and_return([]) @current_resource.stub!(:members).and_return([]) end - + it "should log an appropriate message" do Chef::Log.should_receive(:debug).with("group[wheel] not changing group members, the group has no members") @provider.set_members_option end - + it "should set no options" do @provider.set_members_option.should eql("") end @@ -94,28 +94,28 @@ describe Chef::Provider::Group::Pw do @new_resource.stub!(:members).and_return([]) @current_resource.stub!(:members).and_return(["all", "your", "base"]) end - + it "should log an appropriate message" do Chef::Log.should_receive(:debug).with("group[wheel] removing group members all, your, base") @provider.set_members_option end - + it "should set the -d option with the members joined by ','" do @provider.set_members_option.should eql(" -d all,your,base") end end - + describe "with supplied members array in the new resource and an empty members array in the current resource" do before do @new_resource.stub!(:members).and_return(["all", "your", "base"]) @current_resource.stub!(:members).and_return([]) end - + it "should log an appropriate debug message" do Chef::Log.should_receive(:debug).with("group[wheel] setting group members to all, your, base") @provider.set_members_option end - + it "should set the -M option with the members joined by ','" do @provider.set_members_option.should eql(" -M all,your,base") end @@ -123,7 +123,7 @@ describe Chef::Provider::Group::Pw do end describe"load_current_resource" do - before (:each) do + before (:each) do @provider.load_current_resource @provider.define_resource_requirements end @@ -131,7 +131,7 @@ describe Chef::Provider::Group::Pw do File.should_receive(:exists?).with("/usr/sbin/pw").and_return(false) lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Group) end - + it "shouldn't raise an error if /usr/sbin/pw exists" do File.stub!(:exists?).and_return(true) lambda { @provider.process_resource_requirements }.should_not raise_error(Chef::Exceptions::Group) diff --git a/spec/unit/provider/group/usermod_spec.rb b/spec/unit/provider/group/usermod_spec.rb index 880a3b01e4..7f2931f2e2 100644 --- a/spec/unit/provider/group/usermod_spec.rb +++ b/spec/unit/provider/group/usermod_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. @@ -28,20 +28,20 @@ describe Chef::Provider::Group::Usermod do @provider = Chef::Provider::Group::Usermod.new(@new_resource, @run_context) @provider.stub!(:run_command) end - + describe "modify_group_members" do - + describe "with an empty members array" do before do @new_resource.stub!(:members).and_return([]) end - + it "should log an appropriate message" do Chef::Log.should_receive(:debug).with("group[wheel] not changing group members, the group has no members") @provider.modify_group_members end end - + describe "with supplied members" do platforms = { "openbsd" => "-G", @@ -61,10 +61,10 @@ describe Chef::Provider::Group::Usermod do @provider.define_resource_requirements @provider.load_current_resource @provider.instance_variable_set("@group_exists", true) - @provider.action = :modify + @provider.action = :modify lambda { @provider.run_action(@provider.process_resource_requirements) }.should raise_error(Chef::Exceptions::Group, "setting group members directly is not supported by #{@provider.to_s}, must set append true in group") end - + platforms.each do |platform, flags| it "should usermod each user when the append option is set on #{platform}" do @node.automatic_attrs[:platform] = platform @@ -89,7 +89,7 @@ describe Chef::Provider::Group::Usermod do File.should_receive(:exists?).with("/usr/sbin/usermod").and_return(false) lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Group) end - + it "shouldn't raise an error if the required binaries exist" do File.stub!(:exists?).and_return(true) lambda { @provider.process_resource_requirements }.should_not raise_error(Chef::Exceptions::Group) diff --git a/spec/unit/provider/group_spec.rb b/spec/unit/provider/group_spec.rb index 8fceb7428e..caad9878b6 100644 --- a/spec/unit/provider/group_spec.rb +++ b/spec/unit/provider/group_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. @@ -33,7 +33,7 @@ describe Chef::Provider::User do @current_resource = Chef::Resource::Group.new("aj", @run_context) @current_resource.gid 500 @current_resource.members "aj" - + @provider.current_resource = @current_resource @pw_group = mock("Struct::Group", @@ -43,13 +43,13 @@ describe Chef::Provider::User do ) Etc.stub!(:getgrnam).with('wheel').and_return(@pw_group) end - + it "assumes the group exists by default" do @provider.group_exists.should be_true end describe "when establishing the current state of the group" do - + it "sets the group name of the current resource to the group name of the new resource" do @provider.load_current_resource @provider.current_resource.group_name.should == 'wheel' @@ -65,22 +65,22 @@ describe Chef::Provider::User do @provider.load_current_resource @new_resource.gid.should == 20 end - + it "looks up the group in /etc/group with getgrnam" do Etc.should_receive(:getgrnam).with(@new_resource.group_name).and_return(@pw_group) @provider.load_current_resource @provider.current_resource.gid.should == 20 @provider.current_resource.members.should == %w{root aj} end - + it "should flip the value of exists if it cannot be found in /etc/group" do Etc.stub!(:getgrnam).and_raise(ArgumentError) @provider.load_current_resource @provider.group_exists.should be_false end - + it "should return the current resource" do - @provider.load_current_resource.should equal(@provider.current_resource) + @provider.load_current_resource.should equal(@provider.current_resource) end end @@ -91,7 +91,7 @@ describe Chef::Provider::User do @provider.compare_group.should be_true end end - + it "should return false if gid and members are equal" do @provider.compare_group.should be_false end @@ -116,28 +116,28 @@ describe Chef::Provider::User do @provider.should_receive(:create_group).and_return(true) @provider.run_action(:create) end - + it "should set the new_resources updated flag when it creates the group" do @provider.group_exists = false @provider.stub!(:create_group) @provider.run_action(:create) @provider.new_resource.should be_updated end - + it "should check to see if the group has mismatched attributes if the group exists" do @provider.group_exists = true @provider.stub!(:compare_group).and_return(false) @provider.run_action(:create) @provider.new_resource.should_not be_updated end - + it "should call manage_group if the group exists and has mismatched attributes" do @provider.group_exists = true @provider.stub!(:compare_group).and_return(true) @provider.should_receive(:manage_group).and_return(true) @provider.run_action(:create) end - + it "should set the new_resources updated flag when it creates the group if we call manage_group" do @provider.group_exists = true @provider.stub!(:compare_group).and_return(true) @@ -148,14 +148,14 @@ describe Chef::Provider::User do end describe "when removing a group" do - + it "should not call remove_group if the group does not exist" do @provider.group_exists = false - @provider.should_not_receive(:remove_group) + @provider.should_not_receive(:remove_group) @provider.run_action(:remove) @provider.new_resource.should_not be_updated end - + it "should call remove_group if the group exists" do @provider.group_exists = true @provider.should_receive(:remove_group) @@ -169,26 +169,26 @@ describe Chef::Provider::User do @provider.group_exists = true @provider.stub!(:manage_group).and_return(true) end - + it "should run manage_group if the group exists and has mismatched attributes" do @provider.should_receive(:compare_group).and_return(true) @provider.should_receive(:manage_group).and_return(true) @provider.run_action(:manage) end - + it "should set the new resources updated flag to true if manage_group is called" do @provider.stub!(:compare_group).and_return(true) @provider.stub!(:manage_group).and_return(true) @provider.run_action(:manage) @new_resource.should be_updated end - + it "should not run manage_group if the group does not exist" do @provider.group_exists = false @provider.should_not_receive(:manage_group) @provider.run_action(:manage) end - + it "should not run manage_group if the group exists but has no differing attributes" do @provider.should_receive(:compare_group).and_return(false) @provider.should_not_receive(:manage_group) @@ -201,26 +201,26 @@ describe Chef::Provider::User do @provider.group_exists = true @provider.stub!(:manage_group).and_return(true) end - + it "should run manage_group if the group exists and has mismatched attributes" do @provider.should_receive(:compare_group).and_return(true) @provider.should_receive(:manage_group).and_return(true) @provider.run_action(:modify) end - + it "should set the new resources updated flag to true if manage_group is called" do @provider.stub!(:compare_group).and_return(true) @provider.stub!(:manage_group).and_return(true) @provider.run_action(:modify) @new_resource.should be_updated end - + it "should not run manage_group if the group exists but has no differing attributes" do @provider.should_receive(:compare_group).and_return(false) @provider.should_not_receive(:manage_group) @provider.run_action(:modify) end - + it "should raise a Chef::Exceptions::Group if the group doesn't exist" do @provider.group_exists = false lambda { @provider.run_action(:modify) }.should raise_error(Chef::Exceptions::Group) @@ -230,7 +230,7 @@ describe Chef::Provider::User do describe "when determining the reason for a change" do it "should report which group members are missing if members are missing and appending to the group" do @new_resource.members << "user1" - @new_resource.members << "user2" + @new_resource.members << "user2" @new_resource.stub!(:append).and_return true @provider.compare_group.should be_true @provider.change_desc.should == "add missing member(s): user1, user2" @@ -238,7 +238,7 @@ describe Chef::Provider::User do it "should report that the group members will be overwritten if not appending" do @new_resource.members << "user1" - @new_resource.stub!(:append).and_return false + @new_resource.stub!(:append).and_return false @provider.compare_group.should be_true @provider.change_desc.should == "replace group members with new list of members" end diff --git a/spec/unit/provider/ifconfig/aix_spec.rb b/spec/unit/provider/ifconfig/aix_spec.rb index a97853b22c..39e9919740 100644 --- a/spec/unit/provider/ifconfig/aix_spec.rb +++ b/spec/unit/provider/ifconfig/aix_spec.rb @@ -20,7 +20,7 @@ require 'spec_helper' require 'chef/exceptions' describe Chef::Provider::Ifconfig::Aix do - + before(:all) do @ifconfig_output = <<-IFCONFIG en1: flags=1e080863,480<UP,BROADCAST,NOTRAILERS,RUNNING,SIMPLEX,MULTICAST,GROUPRT,64BIT,CHECKSUM_OFFLOAD(ACTIVE),CHAIN> @@ -47,8 +47,8 @@ IFCONFIG @provider = Chef::Provider::Ifconfig::Aix.new(@new_resource, @run_context) end - describe "#load_current_resource" do - before do + describe "#load_current_resource" do + before do status = double("Status", :exitstatus => 0) @provider.should_receive(:popen4).with("ifconfig -a").and_yield(@pid,@stdin,StringIO.new(@ifconfig_output),@stderr).and_return(status) @new_resource.device "en0" @@ -177,4 +177,4 @@ IFCONFIG end end end -end
\ No newline at end of file +end diff --git a/spec/unit/provider/ifconfig_spec.rb b/spec/unit/provider/ifconfig_spec.rb index d1d20f7f22..f4fdc23353 100644 --- a/spec/unit/provider/ifconfig_spec.rb +++ b/spec/unit/provider/ifconfig_spec.rb @@ -38,20 +38,20 @@ describe Chef::Provider::Ifconfig do status = mock("Status", :exitstatus => 0) @provider.instance_variable_set("@status", status) @provider.current_resource = @current_resource - + end - describe Chef::Provider::Ifconfig, "load_current_resource" do - before do + describe Chef::Provider::Ifconfig, "load_current_resource" do + before do status = mock("Status", :exitstatus => 1) - @provider.should_receive(:popen4).and_return status + @provider.should_receive(:popen4).and_return status @provider.load_current_resource end it "should track state of ifconfig failure." do @provider.instance_variable_get("@status").exitstatus.should_not == 0 end - it "should thrown an exception when ifconfig fails" do + it "should thrown an exception when ifconfig fails" do @provider.define_resource_requirements - lambda { @provider.process_resource_requirements }.should raise_error Chef::Exceptions::Ifconfig + lambda { @provider.process_resource_requirements }.should raise_error Chef::Exceptions::Ifconfig end end describe Chef::Provider::Ifconfig, "action_add" do @@ -84,7 +84,7 @@ describe Chef::Provider::Ifconfig do end describe Chef::Provider::Ifconfig, "action_enable" do - + it "should enable interface if does not exist" do @provider.stub!(:load_current_resource) @current_resource.inet_addr nil @@ -129,7 +129,7 @@ describe Chef::Provider::Ifconfig do @new_resource.should_not be_updated end end - + describe Chef::Provider::Ifconfig, "action_disable" do it "should disable interface if it exists" do diff --git a/spec/unit/provider/link_spec.rb b/spec/unit/provider/link_spec.rb index 171e21171c..bd3204510b 100644 --- a/spec/unit/provider/link_spec.rb +++ b/spec/unit/provider/link_spec.rb @@ -241,8 +241,8 @@ describe Chef::Resource::Link, :not_supported_on_win2k3 do result end it 'create does no work' do - provider.file_class.should_not_receive(:symlink) - provider.file_class.should_not_receive(:link) + provider.file_class.should_not_receive(:symlink) + provider.file_class.should_not_receive(:link) provider.access_controls.should_not_receive(:set_all) provider.run_action(:create) end diff --git a/spec/unit/provider/log_spec.rb b/spec/unit/provider/log_spec.rb index fe3733240a..f6ff526dd4 100644 --- a/spec/unit/provider/log_spec.rb +++ b/spec/unit/provider/log_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. @@ -25,7 +25,7 @@ describe Chef::Provider::Log::ChefLog do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - end + end it "should be registered with the default platform hash" do Chef::Platform.platforms[:default][:log].should_not be_nil @@ -37,7 +37,7 @@ describe Chef::Provider::Log::ChefLog do Chef::Log.should_receive(:info).with(@log_str).and_return(true) @provider.action_write end - + it "should write the string to the Chef::Log object at debug level" do @new_resource = Chef::Resource::Log.new(@log_str) @new_resource.level :debug @@ -53,7 +53,7 @@ describe Chef::Provider::Log::ChefLog do Chef::Log.should_receive(:info).with(@log_str).and_return(true) @provider.action_write end - + it "should write the string to the Chef::Log object at warn level" do @new_resource = Chef::Resource::Log.new(@log_str) @new_resource.level :warn @@ -61,7 +61,7 @@ describe Chef::Provider::Log::ChefLog do Chef::Log.should_receive(:warn).with(@log_str).and_return(true) @provider.action_write end - + it "should write the string to the Chef::Log object at error level" do @new_resource = Chef::Resource::Log.new(@log_str) @new_resource.level :error @@ -69,7 +69,7 @@ describe Chef::Provider::Log::ChefLog do Chef::Log.should_receive(:error).with(@log_str).and_return(true) @provider.action_write end - + it "should write the string to the Chef::Log object at fatal level" do @new_resource = Chef::Resource::Log.new(@log_str) @new_resource.level :fatal @@ -77,5 +77,5 @@ describe Chef::Provider::Log::ChefLog do Chef::Log.should_receive(:fatal).with(@log_str).and_return(true) @provider.action_write end - + end diff --git a/spec/unit/provider/mount/aix_spec.rb b/spec/unit/provider/mount/aix_spec.rb index 92aa8177f2..89de47038a 100644 --- a/spec/unit/provider/mount/aix_spec.rb +++ b/spec/unit/provider/mount/aix_spec.rb @@ -217,7 +217,7 @@ ENABLED mount = true options = rw ETCFILESYSTEMS - + filesystems = StringIO.new ::File.stub!(:open).with("/etc/filesystems", "w").and_yield(filesystems) @@ -234,4 +234,4 @@ ETCFILESYSTEMS @provider.run_action(:disable) end end -end
\ No newline at end of file +end diff --git a/spec/unit/provider/mount/windows_spec.rb b/spec/unit/provider/mount/windows_spec.rb index 74579b14fe..4c9916ae87 100644 --- a/spec/unit/provider/mount/windows_spec.rb +++ b/spec/unit/provider/mount/windows_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/provider/mount_spec.rb b/spec/unit/provider/mount_spec.rb index 1a98f10cb0..a44f9705ee 100644 --- a/spec/unit/provider/mount_spec.rb +++ b/spec/unit/provider/mount_spec.rb @@ -23,13 +23,13 @@ describe Chef::Provider::Mount do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - + @new_resource = Chef::Resource::Mount.new('/tmp/foo') @new_resource.device "/dev/sdz1" @new_resource.name "/tmp/foo" @new_resource.mount_point "/tmp/foo" @new_resource.fstype "ext3" - + @current_resource = Chef::Resource::Mount.new('/tmp/foo') @current_resource.device "/dev/sdz1" @current_resource.name "/tmp/foo" @@ -39,7 +39,7 @@ describe Chef::Provider::Mount do @provider = Chef::Provider::Mount.new(@new_resource, @run_context) @provider.current_resource = @current_resource end - + describe "when the target state is a mounted filesystem" do it "should mount the filesystem if it isn't mounted" do @@ -78,7 +78,7 @@ describe Chef::Provider::Mount do before do @new_resource.supports[:remount] = true end - + it "should remount the filesystem if it is mounted" do @current_resource.stub!(:mounted).and_return(true) @provider.should_receive(:remount_fs).and_return(true) @@ -93,8 +93,8 @@ describe Chef::Provider::Mount do @new_resource.should_not be_updated_by_last_action end end - describe "when the filesystem should be remounted and the resource does not support remounting" do - before do + describe "when the filesystem should be remounted and the resource does not support remounting" do + before do @new_resource.supports[:remount] = false end diff --git a/spec/unit/provider/package/apt_spec.rb b/spec/unit/provider/package/apt_spec.rb index eb11c1e417..32b55163b4 100644 --- a/spec/unit/provider/package/apt_spec.rb +++ b/spec/unit/provider/package/apt_spec.rb @@ -87,18 +87,18 @@ VPKG_STDOUT @provider.should_receive(:shell_out!).with("apt-cache policy libmysqlclient15-dev").and_return(virtual_package) showpkg_out =<<-SHOWPKG_STDOUT Package: libmysqlclient15-dev -Versions: +Versions: -Reverse Depends: +Reverse Depends: libmysqlclient-dev,libmysqlclient15-dev libmysqlclient-dev,libmysqlclient15-dev libmysqlclient-dev,libmysqlclient15-dev libmysqlclient-dev,libmysqlclient15-dev libmysqlclient-dev,libmysqlclient15-dev libmysqlclient-dev,libmysqlclient15-dev -Dependencies: -Provides: -Reverse Provides: +Dependencies: +Provides: +Reverse Provides: libmysqlclient-dev 5.1.41-3ubuntu12.7 libmysqlclient-dev 5.1.41-3ubuntu12.10 libmysqlclient-dev 5.1.41-3ubuntu12 @@ -135,17 +135,17 @@ VPKG_STDOUT @provider.should_receive(:shell_out!).with("apt-cache policy mp3-decoder").and_return(virtual_package) showpkg_out=<<-SHOWPKG_STDOUT Package: mp3-decoder -Versions: +Versions: -Reverse Depends: +Reverse Depends: nautilus,mp3-decoder vux,mp3-decoder plait,mp3-decoder ecasound,mp3-decoder nautilus,mp3-decoder -Dependencies: -Provides: -Reverse Provides: +Dependencies: +Provides: +Reverse Provides: vlc-nox 1.0.6-1ubuntu1.8 vlc 1.0.6-1ubuntu1.8 vlc-nox 1.0.6-1ubuntu1 diff --git a/spec/unit/provider/package/dpkg_spec.rb b/spec/unit/provider/package/dpkg_spec.rb index aa22e0a2a3..30021e31f3 100644 --- a/spec/unit/provider/package/dpkg_spec.rb +++ b/spec/unit/provider/package/dpkg_spec.rb @@ -60,15 +60,15 @@ describe Chef::Provider::Package::Dpkg do @provider.current_resource.package_name.should == "wget" @new_resource.version.should == version end - + it 'if short version provided' do check_version('1.11.4') end - + it 'if extended version provided' do check_version('1.11.4-1ubuntu1') end - + it 'if distro-specific version provided' do check_version('1.11.4-1ubuntu1~lucid') end diff --git a/spec/unit/provider/package/ips_spec.rb b/spec/unit/provider/package/ips_spec.rb index 641a527012..95839dbe89 100644 --- a/spec/unit/provider/package/ips_spec.rb +++ b/spec/unit/provider/package/ips_spec.rb @@ -170,7 +170,7 @@ PKG_STATUS before do @new_resource.stub!(:accept_license).and_return(true) end - + it "should run pkg install with the --accept flag" do @provider.should_receive(:run_command_with_systems_locale).with({ :command => "pkg install -q --accept crypto/gnupg@2.0.17" diff --git a/spec/unit/provider/package/rpm_spec.rb b/spec/unit/provider/package/rpm_spec.rb index 9dd94a7441..86327be42b 100644 --- a/spec/unit/provider/package/rpm_spec.rb +++ b/spec/unit/provider/package/rpm_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,35 +23,35 @@ describe Chef::Provider::Package::Rpm do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - + @new_resource = Chef::Resource::Package.new("emacs") @new_resource.source "/tmp/emacs-21.4-20.el5.i386.rpm" - + @provider = Chef::Provider::Package::Rpm.new(@new_resource, @run_context) - + @status = mock("Status", :exitstatus => 0) ::File.stub!(:exists?).and_return(true) end - + describe "when determining the current state of the package" do - + it "should create a current resource with the name of new_resource" do @provider.stub!(:popen4).and_return(@status) @provider.load_current_resource @provider.current_resource.name.should == "emacs" end - + it "should set the current reource package name to the new resource package name" do @provider.stub!(:popen4).and_return(@status) @provider.load_current_resource @provider.current_resource.package_name.should == 'emacs' end - + it "should raise an exception if a source is supplied but not found" do ::File.stub!(:exists?).and_return(false) lambda { @provider.run_action(:any) }.should raise_error(Chef::Exceptions::Package) end - + it "should get the source package version from rpm if provided" do @stdout = StringIO.new("emacs 21.4-20.el5") @provider.should_receive(:popen4).with("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' /tmp/emacs-21.4-20.el5.i386.rpm").and_yield(@pid, @stdin, @stdout, @stderr).and_return(@status) @@ -60,7 +60,7 @@ describe Chef::Provider::Package::Rpm do @provider.current_resource.package_name.should == "emacs" @provider.new_resource.version.should == "21.4-20.el5" end - + it "should return the current version installed if found by rpm" do @stdout = StringIO.new("emacs 21.4-20.el5") @provider.should_receive(:popen4).with("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' /tmp/emacs-21.4-20.el5.i386.rpm").and_return(@status) @@ -68,20 +68,20 @@ describe Chef::Provider::Package::Rpm do @provider.load_current_resource @provider.current_resource.version.should == "21.4-20.el5" end - + it "should raise an exception if the source is not set but we are installing" do new_resource = Chef::Resource::Package.new("emacs") provider = Chef::Provider::Package::Rpm.new(new_resource, @run_context) lambda { provider.run_action(:any) }.should raise_error(Chef::Exceptions::Package) end - + it "should raise an exception if rpm fails to run" do status = mock("Status", :exitstatus => -1) @provider.stub!(:popen4).and_return(status) lambda { @provider.run_action(:any) }.should raise_error(Chef::Exceptions::Package) end end - + describe "after the current resource is loaded" do before do @current_resource = Chef::Resource::Package.new("emacs") @@ -95,7 +95,7 @@ describe Chef::Provider::Package::Rpm do }) @provider.install_package("emacs", "21.4-20.el5") end - + it "should run rpm -U with the package source to upgrade" do @current_resource.version("21.4-19.el5") @provider.should_receive(:run_command_with_systems_locale).with({ diff --git a/spec/unit/provider/package/smartos_spec.rb b/spec/unit/provider/package/smartos_spec.rb index 71ea3fab04..e5092f69d9 100644 --- a/spec/unit/provider/package/smartos_spec.rb +++ b/spec/unit/provider/package/smartos_spec.rb @@ -27,8 +27,8 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::Package.new("varnish") @current_resource = Chef::Resource::Package.new("varnish") - - + + @status = mock("Status", :exitstatus => 0) @provider = Chef::Provider::Package::SmartOS.new(@new_resource, @run_context) Chef::Resource::Package.stub!(:new).and_return(@current_resource) @@ -88,7 +88,7 @@ describe Chef::Provider::Package::SmartOS, "load_current_resource" do end describe "when manipulating a resource" do - + it "run pkgin and install the package" do out = OpenStruct.new(:stdout => nil) @provider.should_receive(:shell_out!).with("/opt/local/sbin/pkg_info -E \"varnish*\"", {:env => nil, :returns=>[0,1]}).and_return(@shell_out) diff --git a/spec/unit/provider/package_spec.rb b/spec/unit/provider/package_spec.rb index 85aab981e8..f80eed17bd 100644 --- a/spec/unit/provider/package_spec.rb +++ b/spec/unit/provider/package_spec.rb @@ -286,7 +286,7 @@ describe Chef::Provider::Package do @provider.should_not_receive(:reconfig_package) @provider.run_action(:reconfig) @new_resource.should_not be_updated_by_last_action - end + end it "should debug log and not reconfigure the package if no response_file is given" do @current_resource.stub!(:version).and_return('1.0') diff --git a/spec/unit/provider/powershell_spec.rb b/spec/unit/provider/powershell_spec.rb index ac4160080e..33c402836b 100644 --- a/spec/unit/provider/powershell_spec.rb +++ b/spec/unit/provider/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. @@ -24,7 +24,7 @@ describe Chef::Provider::PowershellScript, "action_run" do @node.default["kernel"] = Hash.new @node.default["kernel"][:machine] = :x86_64.to_s - + @run_context = Chef::RunContext.new(@node, {}, @events) @new_resource = Chef::Resource::PowershellScript.new('run some powershell code', @run_context) diff --git a/spec/unit/provider/remote_directory_spec.rb b/spec/unit/provider/remote_directory_spec.rb index f2bb1b4a3f..d3f1438f0f 100644 --- a/spec/unit/provider/remote_directory_spec.rb +++ b/spec/unit/provider/remote_directory_spec.rb @@ -57,10 +57,10 @@ describe Chef::Provider::RemoteDirectory do @provider_second_run.run_action(:create) end it "identifies that the state has changed the after first run" do - @provider_second_run.new_resource.updated_by_last_action? == true + @provider_second_run.new_resource.updated_by_last_action? == true end it "identifies that the state has not changed after the second run" do - @provider_second_run.new_resource.updated_by_last_action? == false + @provider_second_run.new_resource.updated_by_last_action? == false end end diff --git a/spec/unit/provider/route_spec.rb b/spec/unit/provider/route_spec.rb index 072cb2a698..863f12641c 100644 --- a/spec/unit/provider/route_spec.rb +++ b/spec/unit/provider/route_spec.rb @@ -111,13 +111,13 @@ describe Chef::Provider::Route do it "should not delete config file for :add action (CHEF-3332)" do @node.automatic_attrs[:platform] = 'centos' - + route_file = StringIO.new File.should_receive(:new).and_return(route_file) @resource_add = Chef::Resource::Route.new('192.168.1.0/24 via 192.168.0.1') @run_context.resource_collection << @resource_add @provider.stub!(:run_command).and_return(true) - + @resource_add.action(:add) @provider.run_action(:add) route_file.string.split("\n").should have(1).items diff --git a/spec/unit/provider/ruby_block_spec.rb b/spec/unit/provider/ruby_block_spec.rb index 7fc58c9c70..6e5c9a638b 100644 --- a/spec/unit/provider/ruby_block_spec.rb +++ b/spec/unit/provider/ruby_block_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/provider/service/arch_service_spec.rb b/spec/unit/provider/service/arch_service_spec.rb index 42e7868600..0865fdae86 100644 --- a/spec/unit/provider/service/arch_service_spec.rb +++ b/spec/unit/provider/service/arch_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. @@ -61,7 +61,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do @provider.should_receive(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0)) @provider.load_current_resource end - + it "should set running to true if the status command returns 0" do @provider.stub!(:shell_out).with("/etc/rc.d/chef status").and_return(OpenStruct.new(:exitstatus => 0)) @provider.load_current_resource @@ -92,7 +92,7 @@ describe Chef::Provider::Service::Arch, "load_current_resource" do @provider.should_receive(:shell_out).with("/etc/rc.d/chefhasmonkeypants status").and_return(OpenStruct.new(:exitstatus => 0)) @provider.load_current_resource end - + end it "should raise error if the node has a nil ps attribute and no other means to get status" do @@ -129,7 +129,7 @@ aj 8119 6041 0 21:34 pts/3 00:00:03 vi init_service_spec.rb DEFAULT_PS @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub!(:shell_out!).and_return(@status) - + @node.automatic_attrs[:command] = {:ps => "ps -ef"} end @@ -139,7 +139,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 chef aj 7842 5057 0 21:26 pts/2 00:00:06 poos RUNNING_PS @status.stub!(:stdout).and_return(@stdout) - @provider.load_current_resource + @provider.load_current_resource @provider.current_resource.running.should be_true end @@ -162,13 +162,13 @@ RUNNING_PS ::File.stub!(:read).with("/etc/rc.conf").and_return("DAEMONS=(network !apache ssh)") @provider.daemons.should == ['network', '!apache', 'ssh'] end - + context "when the current service status is known" do before do @current_resource = Chef::Resource::Service.new("chef") @provider.current_resource = @current_resource end - + describe Chef::Provider::Service::Arch, "enable_service" do # before(:each) do # @new_resource = mock("Chef::Resource::Service", @@ -178,7 +178,7 @@ RUNNING_PS # :running => false # ) # @new_resource.stub!(:start_command).and_return(false) - # + # # @provider = Chef::Provider::Service::Arch.new(@node, @new_resource) # Chef::Resource::Service.stub!(:new).and_return(@current_resource) # end @@ -199,7 +199,7 @@ RUNNING_PS # :running => false # ) # @new_resource.stub!(:start_command).and_return(false) - # + # # @provider = Chef::Provider::Service::Arch.new(@node, @new_resource) # Chef::Resource::Service.stub!(:new).and_return(@current_resource) # end @@ -221,11 +221,11 @@ RUNNING_PS # :running => false # ) # @new_resource.stub!(:start_command).and_return(false) - # + # # @provider = Chef::Provider::Service::Arch.new(@node, @new_resource) # Chef::Resource::Service.stub!(:new).and_return(@current_resource) # end - + it "should call the start command if one is specified" do @new_resource.stub!(:start_command).and_return("/etc/rc.d/chef startyousillysally") @provider.should_receive(:shell_out!).with("/etc/rc.d/chef startyousillysally") @@ -235,7 +235,7 @@ RUNNING_PS it "should call '/etc/rc.d/service_name start' if no start command is specified" do @provider.should_receive(:shell_out!).with("/etc/rc.d/#{@new_resource.service_name} start") @provider.start_service() - end + end end describe Chef::Provider::Service::Arch, "stop_service" do @@ -247,7 +247,7 @@ RUNNING_PS # :running => false # ) # @new_resource.stub!(:stop_command).and_return(false) - # + # # @provider = Chef::Provider::Service::Arch.new(@node, @new_resource) # Chef::Resource::Service.stub!(:new).and_return(@current_resource) # end @@ -274,7 +274,7 @@ RUNNING_PS # ) # @new_resource.stub!(:restart_command).and_return(false) # @new_resource.stub!(:supports).and_return({:restart => false}) - # + # # @provider = Chef::Provider::Service::Arch.new(@node, @new_resource) # Chef::Resource::Service.stub!(:new).and_return(@current_resource) # end @@ -309,7 +309,7 @@ RUNNING_PS # ) # @new_resource.stub!(:reload_command).and_return(false) # @new_resource.stub!(:supports).and_return({:reload => false}) - # + # # @provider = Chef::Provider::Service::Arch.new(@node, @new_resource) # Chef::Resource::Service.stub!(:new).and_return(@current_resource) # end diff --git a/spec/unit/provider/service/debian_service_spec.rb b/spec/unit/provider/service/debian_service_spec.rb index bea9360561..b1aa193f0e 100644 --- a/spec/unit/provider/service/debian_service_spec.rb +++ b/spec/unit/provider/service/debian_service_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/provider/service/freebsd_service_spec.rb b/spec/unit/provider/service/freebsd_service_spec.rb index 72e896a16b..7861764309 100644 --- a/spec/unit/provider/service/freebsd_service_spec.rb +++ b/spec/unit/provider/service/freebsd_service_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. @@ -125,7 +125,7 @@ RC_SAMPLE @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end - + describe "when executing assertions" do it "should verify that /etc/rc.conf exists" do ::File.should_receive(:exists?).with("/etc/rc.conf") @@ -138,7 +138,7 @@ RC_SAMPLE it "should raise an exception when the action is #{action}" do ::File.stub!(:exists?).and_return(false) @provider.load_current_resource - @provider.define_resource_requirements + @provider.define_resource_requirements @provider.instance_variable_get("@rcd_script_found").should be_false @provider.action = action lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) @@ -157,7 +157,7 @@ RC_SAMPLE ::File.should_receive(:exists?).with("/etc/rc.conf").and_return false @provider.load_current_resource @provider.instance_variable_get("@enabled_state_found").should be_false - end + end it "update state when current resource enabled state could be determined" do ::File.stub!(:exist?).with("/usr/local/etc/rc.d/#{@new_resource.service_name}").and_return(true) @@ -165,10 +165,10 @@ RC_SAMPLE @provider.load_current_resource @provider.instance_variable_get("@enabled_state_found").should be_false @provider.instance_variable_get("@rcd_script_found").should be_true - @provider.define_resource_requirements + @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service, "Could not find the service name in /usr/local/etc/rc.d/#{@current_resource.service_name} and rcvar") - end + end it "should throw an exception if service line is missing from rc.d script" do pending "not implemented" do @@ -197,7 +197,7 @@ RC_SAMPLE it "should set running to true if the regex matches the output" do @stdout.stub!(:each_line).and_yield("555 ?? Ss 0:05.16 /usr/sbin/cron -s"). and_yield(" 9881 ?? Ss 0:06.67 /usr/local/sbin/httpd -DNOHTTPACCEPT") - @provider.load_current_resource + @provider.load_current_resource @current_resource.running.should be_true end diff --git a/spec/unit/provider/service/gentoo_service_spec.rb b/spec/unit/provider/service/gentoo_service_spec.rb index 8d4ada043b..b658cab4d8 100644 --- a/spec/unit/provider/service/gentoo_service_spec.rb +++ b/spec/unit/provider/service/gentoo_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. @@ -24,10 +24,10 @@ describe Chef::Provider::Service::Gentoo do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - + @new_resource = Chef::Resource::Service.new("chef") @current_resource = Chef::Resource::Service.new("chef") - + @provider = Chef::Provider::Service::Gentoo.new(@new_resource, @run_context) Chef::Resource::Service.stub!(:new).and_return(@current_resource) @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @@ -39,7 +39,7 @@ describe Chef::Provider::Service::Gentoo do end # new test: found_enabled state # - describe "load_current_resource" do + describe "load_current_resource" do it "should raise Chef::Exceptions::Service if /sbin/rc-update does not exist" do File.should_receive(:exists?).with("/sbin/rc-update").and_return(false) @provider.define_resource_requirements @@ -79,7 +79,7 @@ describe Chef::Provider::Service::Gentoo do File.stub!(:exists?).with("/etc/runlevels/default/chef").and_return(true) File.stub!(:readable?).with("/etc/runlevels/default/chef").and_return(false) end - + it "should set enabled to false" do @provider.load_current_resource @current_resource.enabled.should be_false @@ -101,10 +101,10 @@ describe Chef::Provider::Service::Gentoo do end end - + it "should return the current_resource" do @provider.load_current_resource.should == @current_resource - end + end it "should support the status command automatically" do @provider.load_current_resource @@ -122,7 +122,7 @@ describe Chef::Provider::Service::Gentoo do end end - + describe "action_methods" do before(:each) { @provider.stub!(:load_current_resource).and_return(@current_resource) } diff --git a/spec/unit/provider/service/init_service_spec.rb b/spec/unit/provider/service/init_service_spec.rb index 4131ee61a8..c7d47e6281 100644 --- a/spec/unit/provider/service/init_service_spec.rb +++ b/spec/unit/provider/service/init_service_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. @@ -40,7 +40,7 @@ PS @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub!(:shell_out!).and_return(@status) end - + it "should create a current resource with the name of the new resource" do @provider.load_current_resource @provider.current_resource.should equal(@current_resource) @@ -60,7 +60,7 @@ PS @provider.should_receive(:shell_out).with("/etc/init.d/#{@current_resource.service_name} status").and_return(@status) @provider.load_current_resource end - + it "should set running to true if the status command returns 0" do @provider.stub!(:shell_out).with("/etc/init.d/#{@current_resource.service_name} status").and_return(@status) @provider.load_current_resource @@ -90,9 +90,9 @@ PS @provider.should_receive(:shell_out).with("/etc/init.d/chefhasmonkeypants status").and_return(@status) @provider.load_current_resource end - + end - + describe "when an init command has been specified" do before do @new_resource.stub!(:init_command).and_return("/opt/chef-server/service/erchef") @@ -107,7 +107,7 @@ PS end describe "when the node has not specified a ps command" do - + it "should raise an error if the node has a nil ps attribute" do @node.automatic_attrs[:command] = {:ps => nil} @provider.load_current_resource @@ -123,7 +123,7 @@ PS @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end - + end @@ -139,7 +139,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 chef aj 7842 5057 0 21:26 pts/2 00:00:06 poos RUNNING_PS @status.stub!(:stdout).and_return(@stdout) - @provider.load_current_resource + @provider.load_current_resource @current_resource.running.should be_true end @@ -172,7 +172,7 @@ RUNNING_PS it "should call '/etc/init.d/service_name start' if no start command is specified" do @provider.should_receive(:shell_out!).with("/etc/init.d/#{@new_resource.service_name} start") @provider.start_service() - end + end end describe Chef::Provider::Service::Init, "stop_service" do diff --git a/spec/unit/provider/service/insserv_service_spec.rb b/spec/unit/provider/service/insserv_service_spec.rb index c823d511b5..8b5f09e78c 100644 --- a/spec/unit/provider/service/insserv_service_spec.rb +++ b/spec/unit/provider/service/insserv_service_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. @@ -35,7 +35,7 @@ describe Chef::Provider::Service::Insserv do describe "load_current_resource" do describe "when startup links exist" do - before do + before do Dir.stub!(:glob).with("/etc/rc**/S*initgrediant").and_return(["/etc/rc5.d/S18initgrediant", "/etc/rc2.d/S18initgrediant", "/etc/rc4.d/S18initgrediant", "/etc/rc3.d/S18initgrediant"]) end @@ -46,7 +46,7 @@ describe Chef::Provider::Service::Insserv do end describe "when startup links do not exist" do - before do + before do Dir.stub!(:glob).with("/etc/rc**/S*initgrediant").and_return([]) end @@ -65,7 +65,7 @@ describe Chef::Provider::Service::Insserv do @provider.enable_service end end - + describe "disable_service" do it "should call insserv and remove the links" do @provider.should_receive(:run_command).with({:command=>"/sbin/insserv -r -f #{@new_resource.service_name}"}) diff --git a/spec/unit/provider/service/invokercd_service_spec.rb b/spec/unit/provider/service/invokercd_service_spec.rb index 798b987dd5..ca20657405 100644 --- a/spec/unit/provider/service/invokercd_service_spec.rb +++ b/spec/unit/provider/service/invokercd_service_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. @@ -40,7 +40,7 @@ PS @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub!(:shell_out!).and_return(@status) end - + it "should create a current resource with the name of the new resource" do @provider.load_current_resource @provider.current_resource.should equal(@current_resource) @@ -60,7 +60,7 @@ PS @provider.should_receive(:shell_out).with("/usr/sbin/invoke-rc.d #{@current_resource.service_name} status").and_return(@status) @provider.load_current_resource end - + it "should set running to true if the status command returns 0" do @provider.stub!(:shell_out).with("/usr/sbin/invoke-rc.d #{@current_resource.service_name} status").and_return(@status) @provider.load_current_resource @@ -90,9 +90,9 @@ PS @provider.should_receive(:shell_out).with("/usr/sbin/invoke-rc.d chefhasmonkeypants status").and_return(@status) @provider.load_current_resource end - + end - + describe "when the node has not specified a ps command" do it "should raise error if the node has a nil ps attribute and no other means to get status" do @node.automatic_attrs[:command] = {:ps => nil} @@ -107,7 +107,7 @@ PS @provider.define_resource_requirements lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end - + end @@ -125,7 +125,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 poos RUNNING_PS @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @provider.should_receive(:shell_out!).and_return(@status) - @provider.load_current_resource + @provider.load_current_resource @current_resource.running.should be_true end @@ -159,7 +159,7 @@ RUNNING_PS it "should call '/usr/sbin/invoke-rc.d service_name start' if no start command is specified" do @provider.should_receive(:shell_out!).with("/usr/sbin/invoke-rc.d #{@new_resource.service_name} start") @provider.start_service() - end + end end describe Chef::Provider::Service::Invokercd, "stop_service" do diff --git a/spec/unit/provider/service/redhat_spec.rb b/spec/unit/provider/service/redhat_spec.rb index dd874a4f05..3ce4301026 100644 --- a/spec/unit/provider/service/redhat_spec.rb +++ b/spec/unit/provider/service/redhat_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. @@ -47,7 +47,7 @@ describe "Chef::Provider::Service::Redhat" do @node.automatic_attrs[:command] = {:ps => 'foo'} @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - + @new_resource = Chef::Resource::Service.new("chef") @current_resource = Chef::Resource::Service.new("chef") @@ -73,7 +73,7 @@ describe "Chef::Provider::Service::Redhat" do @provider.load_current_resource @current_resource.enabled.should be_true end - + it "sets the current enabled status to false if the regex does not match" do status = mock("Status", :exitstatus => 0, :stdout => "" , :stderr => "") @provider.should_receive(:shell_out).with("/sbin/service chef status").and_return(status) @@ -84,10 +84,10 @@ describe "Chef::Provider::Service::Redhat" do @current_resource.enabled.should be_false end end - + describe "define resource requirements" do it_should_behave_like "define_resource_requirements_common" - + context "when the service does not exist" do before do status = mock("Status", :exitstatus => 1, :stdout => "", :stderr => "chef: unrecognized service") diff --git a/spec/unit/provider/service/simple_service_spec.rb b/spec/unit/provider/service/simple_service_spec.rb index cc0173e246..73cb3766d2 100644 --- a/spec/unit/provider/service/simple_service_spec.rb +++ b/spec/unit/provider/service/simple_service_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. @@ -39,7 +39,7 @@ NOMOCKINGSTRINGSPLZ @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub!(:shell_out!).and_return(@status) end - + it "should create a current resource with the name of the new resource" do Chef::Resource::Service.should_receive(:new).and_return(@current_resource) @provider.load_current_resource @@ -81,7 +81,7 @@ aj 7842 5057 0 21:26 pts/2 00:00:06 poos NOMOCKINGSTRINGSPLZ @status = mock("Status", :exitstatus => 0, :stdout => @stdout) @provider.stub!(:shell_out!).and_return(@status) - @provider.load_current_resource + @provider.load_current_resource @current_resource.running.should be_true end @@ -117,7 +117,7 @@ NOMOCKINGSTRINGSPLZ @provider.define_resource_requirements @provider.action = :start lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) - end + end end describe "when stopping a service" do @@ -144,7 +144,7 @@ NOMOCKINGSTRINGSPLZ it "should raise an exception if the resource doesn't support restart, no restart command is provided, and no stop command is provided" do @provider.define_resource_requirements @provider.action = :restart - lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) + lambda { @provider.process_resource_requirements }.should raise_error(Chef::Exceptions::Service) end it "should just call stop, then start when the resource doesn't support restart and no restart_command is specified" do diff --git a/spec/unit/provider/service/solaris_smf_service_spec.rb b/spec/unit/provider/service/solaris_smf_service_spec.rb index 5cda6ddb77..64afee078c 100644 --- a/spec/unit/provider/service/solaris_smf_service_spec.rb +++ b/spec/unit/provider/service/solaris_smf_service_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. @@ -44,7 +44,7 @@ describe Chef::Provider::Service::Solaris do it "should raise an error if /bin/svcs does not exist" do File.should_receive(:exists?).with("/bin/svcs").and_return(false) lambda { @provider.load_current_resource }.should raise_error(Chef::Exceptions::Service) - end + end describe "on a host with /bin/svcs" do @@ -63,7 +63,7 @@ describe Chef::Provider::Service::Solaris do it "should return the current resource" do @provider.stub!(:popen4).with("/bin/svcs -l chef").and_return(@status) @provider.load_current_resource.should eql(@current_resource) - end + end it "should popen4 '/bin/svcs -l service_name'" do @provider.should_receive(:popen4).with("/bin/svcs -l chef").and_return(@status) diff --git a/spec/unit/provider/service/systemd_service_spec.rb b/spec/unit/provider/service/systemd_service_spec.rb index bca28a2d92..a107888b0b 100644 --- a/spec/unit/provider/service/systemd_service_spec.rb +++ b/spec/unit/provider/service/systemd_service_spec.rb @@ -79,19 +79,19 @@ describe Chef::Provider::Service::Systemd do @provider.load_current_resource @provider.instance_variable_get("@status_check_success").should be_true end - + it "should set running to false if it catches a Chef::Exceptions::Exec when using a status command" do @provider.stub!(:run_command_with_systems_locale).and_raise(Chef::Exceptions::Exec) @current_resource.should_receive(:running).with(false) @provider.load_current_resource end - + it "should update state to indicate status check failed when an exception is thrown using a status command" do @provider.stub!(:run_command_with_systems_locale).and_raise(Chef::Exceptions::Exec) @provider.load_current_resource @provider.instance_variable_get("@status_check_success").should be_false end - end + end it "should check if the service is enabled" do @provider.should_receive(:is_enabled?) diff --git a/spec/unit/provider/service/upstart_service_spec.rb b/spec/unit/provider/service/upstart_service_spec.rb index 4224b229e5..8628a4eaf7 100644 --- a/spec/unit/provider/service/upstart_service_spec.rb +++ b/spec/unit/provider/service/upstart_service_spec.rb @@ -73,7 +73,7 @@ describe Chef::Provider::Service::Upstart do @stdout = StringIO.new @stderr = StringIO.new @pid = mock("PID") - + ::File.stub!(:exists?).and_return(true) ::File.stub!(:open).and_return(true) end @@ -172,7 +172,7 @@ describe Chef::Provider::Service::Upstart do @provider.load_current_resource end - it "should track state when the user-provided status command fails" do + it "should track state when the user-provided status command fails" do @provider.stub!(:popen4).and_yield(@pid, @stdin, @stdout, @stderr).and_raise(Chef::Exceptions::Exec) @provider.load_current_resource @provider.instance_variable_get("@command_success").should == false @@ -190,7 +190,7 @@ describe Chef::Provider::Service::Upstart do @provider.load_current_resource @provider.instance_variable_get("@command_success").should == false end - + it "should return the current resource" do @provider.load_current_resource.should eql(@current_resource) end diff --git a/spec/unit/provider/service/windows_spec.rb b/spec/unit/provider/service/windows_spec.rb index a68e798d36..7ec4ccf96a 100644 --- a/spec/unit/provider/service/windows_spec.rb +++ b/spec/unit/provider/service/windows_spec.rb @@ -95,7 +95,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do end describe Chef::Provider::Service::Windows, "stop_service" do - + before(:each) do Win32::Service.stub!(:status).with(@new_resource.service_name).and_return( mock("StatusStruct", :current_state => "running"), @@ -143,9 +143,9 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do it "should stop then start the service if it is running" do Win32::Service.stub!(:status).with(@new_resource.service_name).and_return( - mock("StatusStruct", :current_state => "running"), - mock("StatusStruct", :current_state => "stopped"), - mock("StatusStruct", :current_state => "stopped"), + mock("StatusStruct", :current_state => "running"), + mock("StatusStruct", :current_state => "stopped"), + mock("StatusStruct", :current_state => "stopped"), mock("StatusStruct", :current_state => "running")) Win32::Service.should_receive(:stop).with(@new_resource.service_name) Win32::Service.should_receive(:start).with(@new_resource.service_name) @@ -155,8 +155,8 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do it "should just start the service if it is stopped" do Win32::Service.stub!(:status).with(@new_resource.service_name).and_return( - mock("StatusStruct", :current_state => "stopped"), - mock("StatusStruct", :current_state => "stopped"), + mock("StatusStruct", :current_state => "stopped"), + mock("StatusStruct", :current_state => "stopped"), mock("StatusStruct", :current_state => "running")) Win32::Service.should_receive(:start).with(@new_resource.service_name) @provider.restart_service @@ -201,7 +201,7 @@ describe Chef::Provider::Service::Windows, "load_current_resource" do @new_resource.updated_by_last_action?.should be_false end end - + describe Chef::Provider::Service::Windows, "disable_service" do before(:each) do diff --git a/spec/unit/provider/subversion_spec.rb b/spec/unit/provider/subversion_spec.rb index 81e5860225..dd020d4597 100644 --- a/spec/unit/provider/subversion_spec.rb +++ b/spec/unit/provider/subversion_spec.rb @@ -247,7 +247,7 @@ describe Chef::Provider::Subversion do ::File.stub!(:directory?).with("/my/deploy").and_return(true) ::File.should_receive(:exist?).with("/my/deploy/dir/.svn").twice.and_return(false) @provider.should_receive(:action_checkout) - @provider.run_action(:sync) + @provider.run_action(:sync) end it "runs the sync_command on action_sync if the deploy dir exists and isn't empty" do diff --git a/spec/unit/provider/user/dscl_spec.rb b/spec/unit/provider/user/dscl_spec.rb index 3894cd61b4..dd98c55bd1 100644 --- a/spec/unit/provider/user/dscl_spec.rb +++ b/spec/unit/provider/user/dscl_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. @@ -29,7 +29,7 @@ describe Chef::Provider::User::Dscl do @new_resource = Chef::Resource::User.new("toor") @provider = Chef::Provider::User::Dscl.new(@new_resource, @run_context) end - + describe "when shelling out to dscl" do it "should run dscl with the supplied cmd /Path args" do shell_return = ShellCmdResult.new('stdout', 'err', 0) @@ -66,7 +66,7 @@ describe Chef::Provider::User::Dscl do before do @provider.stub!(:safe_dscl).and_return("\nwheel 200\nstaff 201\n") end - + it "should run safe_dscl with list /Users uid" do @provider.should_receive(:safe_dscl).with("list /Users uid") @provider.get_free_uid @@ -75,7 +75,7 @@ describe Chef::Provider::User::Dscl do it "should return the first unused uid number on or above 200" do @provider.get_free_uid.should == 202 end - + it "should raise an exception when the search limit is exhausted" do search_limit = 1 lambda { @provider.get_free_uid(search_limit) }.should raise_error(RuntimeError) @@ -91,7 +91,7 @@ describe Chef::Provider::User::Dscl do @provider.should_receive(:safe_dscl).with("list /Users uid") @provider.uid_used?(500) end - + it "should return true for a used uid number" do @provider.uid_used?(500).should be_true end @@ -111,7 +111,7 @@ describe Chef::Provider::User::Dscl do @provider.should_receive(:get_free_uid).and_return(501) lambda { @provider.set_uid }.should raise_error(Chef::Exceptions::RequestedUIDUnavailable) end - + it "finds a valid, unused uid when none is specified" do @provider.should_receive(:safe_dscl).with("list /Users uid").and_return('') @provider.should_receive(:safe_dscl).with("create /Users/toor UniqueID 501") @@ -119,7 +119,7 @@ describe Chef::Provider::User::Dscl do @provider.set_uid @new_resource.uid.should == 501 end - + it "sets the uid specified in the resource" do @new_resource.uid(1000) @provider.should_receive(:safe_dscl).with("create /Users/toor UniqueID 1000").and_return(true) @@ -132,7 +132,7 @@ describe Chef::Provider::User::Dscl do before do @new_resource.supports({ :manage_home => true }) @new_resource.home('/Users/toor') - + @current_resource = @new_resource.dup @provider.current_resource = @current_resource end @@ -142,7 +142,7 @@ describe Chef::Provider::User::Dscl do @provider.should_receive(:safe_dscl).with("delete /Users/toor NFSHomeDirectory").and_return(true) @provider.modify_home end - + it "raises InvalidHomeDirectory when the resource's home directory doesn't look right" do @new_resource.home('epic-fail') @@ -151,20 +151,20 @@ describe Chef::Provider::User::Dscl do it "moves the users home to the new location if it exists and the target location is different" do @new_resource.supports(:manage_home => true) - + current_home = CHEF_SPEC_DATA + '/old_home_dir' current_home_files = [current_home + '/my-dot-emacs', current_home + '/my-dot-vim'] @current_resource.home(current_home) @new_resource.gid(23) ::File.stub!(:exists?).with('/old/home/toor').and_return(true) ::File.stub!(:exists?).with('/Users/toor').and_return(true) - + FileUtils.should_receive(:mkdir_p).with('/Users/toor').and_return(true) FileUtils.should_receive(:rmdir).with(current_home) ::Dir.should_receive(:glob).with("#{CHEF_SPEC_DATA}/old_home_dir/*",::File::FNM_DOTMATCH).and_return(current_home_files) FileUtils.should_receive(:mv).with(current_home_files, "/Users/toor", :force => true) FileUtils.should_receive(:chown_R).with('toor','23','/Users/toor') - + @provider.should_receive(:safe_dscl).with("create /Users/toor NFSHomeDirectory '/Users/toor'") @provider.modify_home end @@ -251,7 +251,7 @@ describe Chef::Provider::User::Dscl do before do @new_resource.password("F"*48) end - + it "should write a shadow hash file with the expected salted sha1" do uuid = "B398449E-CEE0-45E0-80F8-B0B5B1BFDEAA" File.should_receive(:open).with('/var/db/shadow/hash/B398449E-CEE0-45E0-80F8-B0B5B1BFDEAA', "w", 384).and_yield(@output) @@ -262,7 +262,7 @@ describe Chef::Provider::User::Dscl do expected_shadow_hash[168] = expected_salted_sha1 @provider.modify_password @output.string.strip.should == expected_shadow_hash - end + end end describe "when given a shadow hash file for the password" do @@ -292,7 +292,7 @@ describe Chef::Provider::User::Dscl do @provider.should_receive(:safe_dscl).with("read /Users/toor").and_return("\nAuthenticationAuthority: ;ShadowHash;\n") @provider.modify_password @output.string.strip.should match(/^0{168}(FFFFFFFF1C1AA7935D4E1190AFEC92343F31F7671FBF126D)0{1071}$/) - end + end end it "should write the output directly to the shadow hash file at /var/db/shadow/hash/GUID" do @@ -392,7 +392,7 @@ describe Chef::Provider::User::Dscl do before do @current_resource = @new_resource.dup @provider.current_resource = @current_resource - + # These are all different from @current_resource @new_resource.username "mud" @new_resource.uid 2342 @@ -400,7 +400,7 @@ describe Chef::Provider::User::Dscl do @new_resource.home '/Users/death' @new_resource.password 'goaway' end - + it "sets the user, comment field, uid, gid, moves the home directory, sets the shell, and sets the password" do @provider.should_receive :dscl_create_user @provider.should_receive :dscl_create_comment @@ -417,11 +417,11 @@ describe Chef::Provider::User::Dscl do before do @current_resource = @new_resource.dup @provider.current_resource = @current_resource - + # This is different from @current_resource @new_resource.gid 2342 end - + it "sets the gid" do @provider.should_receive :dscl_set_gid @provider.manage_user @@ -436,7 +436,7 @@ describe Chef::Provider::User::Dscl do FileUtils.should_receive(:rm_rf).with("/Users/fuuuuuuuuuuuuu") @provider.remove_user end - + it "removes the user from any group memberships" do Etc.stub(:group).and_yield(OpenStruct.new(:name => 'ragefisters', :mem => 'toor')) @provider.should_receive(:safe_dscl).with("delete /Users/toor") diff --git a/spec/unit/provider/user/pw_spec.rb b/spec/unit/provider/user/pw_spec.rb index b7503ea15f..ea5bcfe740 100644 --- a/spec/unit/provider/user/pw_spec.rb +++ b/spec/unit/provider/user/pw_spec.rb @@ -23,7 +23,7 @@ describe Chef::Provider::User::Pw do @node = Chef::Node.new @events = Chef::EventDispatch::Dispatcher.new @run_context = Chef::RunContext.new(@node, {}, @events) - + @new_resource = Chef::Resource::User.new("adam") @new_resource.comment "Adam Jacob" @new_resource.uid 1000 @@ -31,7 +31,7 @@ describe Chef::Provider::User::Pw do @new_resource.home "/home/adam" @new_resource.shell "/usr/bin/zsh" @new_resource.password "abracadabra" - + @new_resource.supports :manage_home => true @current_resource = Chef::Resource::User.new("adam") diff --git a/spec/unit/provider/user/windows_spec.rb b/spec/unit/provider/user/windows_spec.rb index 6ede11b28c..b11eeaebe5 100644 --- a/spec/unit/provider/user/windows_spec.rb +++ b/spec/unit/provider/user/windows_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. @@ -41,7 +41,7 @@ describe Chef::Provider::User::Windows do @provider = Chef::Provider::User::Windows.new(@new_resource, @run_context) @provider.current_resource = @current_resource end - + describe "when comparing the user's current attributes to the desired attributes" do before do @new_resource.comment "Adam Jacob" @@ -79,7 +79,7 @@ describe Chef::Provider::User::Windows do end end - + describe "and the attributes do not match" do before do @current_resource = Chef::Resource::User.new("adam") @@ -130,7 +130,7 @@ describe Chef::Provider::User::Windows do before(:each) do @provider.stub!(:set_options).and_return(:name=> "monkey") end - + it "should call @net_user.update with the return of set_options" do @net_user.should_receive(:update).with(:name=> "monkey") @provider.manage_user diff --git a/spec/unit/provider/user_spec.rb b/spec/unit/provider/user_spec.rb index 8b1e0a54f4..d054fcc440 100644 --- a/spec/unit/provider/user_spec.rb +++ b/spec/unit/provider/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. @@ -58,7 +58,7 @@ describe Chef::Provider::User do describe "executing load_current_resource" do before(:each) do @node = Chef::Node.new - #@new_resource = mock("Chef::Resource::User", + #@new_resource = mock("Chef::Resource::User", # :null_object => true, # :username => "adam", # :comment => "Adam Jacob", @@ -152,17 +152,17 @@ describe Chef::Provider::User do @new_resource.password "some new password" Etc.stub!(:getpwnam).and_return(user) end - + unless shadow_lib_unavail? context "and we have the ruby-shadow gem" do - pending "and we are not root (rerun this again as root)", :requires_unprivileged_user => true - + pending "and we are not root (rerun this again as root)", :requires_unprivileged_user => true + context "and we are root", :requires_root => true do it "should pass assertions when ruby-shadow can be loaded" do @provider.action = 'create' original_method = @provider.method(:require) @provider.should_receive(:require) { |*args| original_method.call(*args) } - passwd_info = Struct::PasswdEntry.new(:sp_namp => "adm ", :sp_pwdp => "$1$T0N0Q.lc$nyG6pFI3Dpqa5cxUz/57j0", :sp_lstchg => 14861, :sp_min => 0, :sp_max => 99999, + passwd_info = Struct::PasswdEntry.new(:sp_namp => "adm ", :sp_pwdp => "$1$T0N0Q.lc$nyG6pFI3Dpqa5cxUz/57j0", :sp_lstchg => 14861, :sp_min => 0, :sp_max => 99999, :sp_warn => 7, :sp_inact => -1, :sp_expire => -1, :sp_flag => -1) Shadow::Passwd.should_receive(:getspnam).with("adam").and_return(passwd_info) @provider.load_current_resource @@ -177,7 +177,7 @@ describe Chef::Provider::User do @provider.should_receive(:require).with("shadow") { raise LoadError } @provider.load_current_resource @provider.define_resource_requirements - lambda {@provider.process_resource_requirements}.should raise_error Chef::Exceptions::MissingLibrary + lambda {@provider.process_resource_requirements}.should raise_error Chef::Exceptions::MissingLibrary end end @@ -214,13 +214,13 @@ describe Chef::Provider::User do it "should return false if the objects are identical" do @provider.compare_user.should eql(false) - end + end end describe "action_create" do before(:each) do @provider.stub!(:load_current_resource) - # @current_resource = mock("Chef::Resource::User", + # @current_resource = mock("Chef::Resource::User", # :null_object => true, # :username => "adam", # :comment => "Adam Jacob", @@ -270,7 +270,7 @@ describe Chef::Provider::User do it "should not call remove_user if the user does not exist" do @provider.user_exists = false - @provider.should_not_receive(:remove_user) + @provider.should_not_receive(:remove_user) @provider.action_remove end @@ -293,10 +293,10 @@ describe Chef::Provider::User do before(:each) do @provider.stub!(:load_current_resource) # @node = Chef::Node.new - # @new_resource = mock("Chef::Resource::User", + # @new_resource = mock("Chef::Resource::User", # :null_object => true # ) - # @current_resource = mock("Chef::Resource::User", + # @current_resource = mock("Chef::Resource::User", # :null_object => true # ) # @provider = Chef::Provider::User.new(@node, @new_resource) @@ -336,10 +336,10 @@ describe Chef::Provider::User do before(:each) do @provider.stub!(:load_current_resource) # @node = Chef::Node.new - # @new_resource = mock("Chef::Resource::User", + # @new_resource = mock("Chef::Resource::User", # :null_object => true # ) - # @current_resource = mock("Chef::Resource::User", + # @current_resource = mock("Chef::Resource::User", # :null_object => true # ) # @provider = Chef::Provider::User.new(@node, @new_resource) @@ -405,10 +405,10 @@ describe Chef::Provider::User do before(:each) do @provider.stub!(:load_current_resource) # @node = Chef::Node.new - # @new_resource = mock("Chef::Resource::User", + # @new_resource = mock("Chef::Resource::User", # :null_object => true # ) - # @current_resource = mock("Chef::Resource::User", + # @current_resource = mock("Chef::Resource::User", # :null_object => true # ) # @provider = Chef::Provider::User.new(@node, @new_resource) |