summaryrefslogtreecommitdiff
path: root/spec/unit/provider/user_spec.rb
diff options
context:
space:
mode:
authortylercloke <tyler@opscode.com>2012-11-05 13:25:00 -0800
committertylercloke <tyler@opscode.com>2012-11-05 16:07:55 -0800
commitd0238d6ff8a32b10a76ae8ec059c8794d30ed6f3 (patch)
treed74d5d390e1ba9732e3ce04b042c58b694ebed34 /spec/unit/provider/user_spec.rb
parent926726fb40f738fa7d0c1c7944c8c3350a1694e8 (diff)
downloadchef-d0238d6ff8a32b10a76ae8ec059c8794d30ed6f3.tar.gz
Finished refactoring converge and updated tests
so that converge and converge! are no longer a method in the provider and why_run, respectively. There is instead set_updated_status in provider. Everything is now converged in why_run's add_action, so neither of the converge methods should ever need to be called. Updated tests to reflect this. Removed all calls to converge, and replaced with set_updated_status only for tests that are looking at the update status of a provider, where the converge behavior has been mocked out.
Diffstat (limited to 'spec/unit/provider/user_spec.rb')
-rw-r--r--spec/unit/provider/user_spec.rb23
1 files changed, 7 insertions, 16 deletions
diff --git a/spec/unit/provider/user_spec.rb b/spec/unit/provider/user_spec.rb
index 4066ffd7fe..9c4e2847f7 100644
--- a/spec/unit/provider/user_spec.rb
+++ b/spec/unit/provider/user_spec.rb
@@ -250,7 +250,7 @@ describe Chef::Provider::User do
@provider.user_exists = false
@provider.should_receive(:create_user).and_return(true)
@provider.action_create
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end
@@ -259,7 +259,6 @@ describe Chef::Provider::User do
@provider.stub!(:compare_user).and_return(true)
@provider.should_receive(:manage_user).and_return(true)
@provider.action_create
- @provider.converge
end
it "should set the the new_resources updated flag when it creates the user if we call manage_user" do
@@ -267,7 +266,7 @@ describe Chef::Provider::User do
@provider.stub!(:compare_user).and_return(true)
@provider.stub!(:manage_user).and_return(true)
@provider.action_create
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end
end
@@ -281,21 +280,19 @@ describe Chef::Provider::User do
@provider.user_exists = false
@provider.should_not_receive(:remove_user)
@provider.action_remove
- @provider.converge
end
it "should call remove_user if the user exists" do
@provider.user_exists = true
@provider.should_receive(:remove_user)
@provider.action_remove
- @provider.converge
end
it "should set the new_resources updated flag to true if the user is removed" do
@provider.user_exists = true
@provider.should_receive(:remove_user)
@provider.action_remove
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end
end
@@ -320,14 +317,13 @@ describe Chef::Provider::User do
@provider.should_receive(:compare_user).and_return(true)
@provider.should_receive(:manage_user).and_return(true)
@provider.action_manage
- @provider.converge
end
it "should set the new resources updated flag to true if manage_user is called" do
@provider.stub!(:compare_user).and_return(true)
@provider.stub!(:manage_user).and_return(true)
@provider.action_manage
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end
@@ -335,14 +331,12 @@ describe Chef::Provider::User do
@provider.user_exists = false
@provider.should_not_receive(:manage_user)
@provider.action_manage
- @provider.converge
end
it "should not run manage_user if the user exists but has no differing attributes" do
@provider.should_receive(:compare_user).and_return(false)
@provider.should_not_receive(:manage_user)
@provider.action_manage
- @provider.converge
end
end
@@ -366,14 +360,13 @@ describe Chef::Provider::User do
@provider.should_receive(:compare_user).and_return(true)
@provider.should_receive(:manage_user).and_return(true)
@provider.action_modify
- @provider.converge
end
it "should set the new resources updated flag to true if manage_user is called" do
@provider.stub!(:compare_user).and_return(true)
@provider.stub!(:manage_user).and_return(true)
@provider.action_modify
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end
@@ -381,7 +374,6 @@ describe Chef::Provider::User do
@provider.should_receive(:compare_user).and_return(false)
@provider.should_not_receive(:manage_user)
@provider.action_modify
- @provider.converge
end
it "should raise a Chef::Exceptions::User if the user doesn't exist" do
@@ -399,14 +391,13 @@ describe Chef::Provider::User do
@provider.stub!(:check_lock).and_return(false)
@provider.should_receive(:lock_user).and_return(true)
@provider.action_lock
- @provider.converge
end
it "should set the new resources updated flag to true if lock_user is called" do
@provider.stub!(:check_lock).and_return(false)
@provider.should_receive(:lock_user)
@provider.action_lock
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end
@@ -439,7 +430,7 @@ describe Chef::Provider::User do
@provider.stub!(:check_lock).and_return(true)
@provider.should_receive(:unlock_user).and_return(true)
@provider.action_unlock
- @provider.converge
+ @provider.set_updated_status
@new_resource.should be_updated
end