diff options
author | Lamont Granquist <lamont@opscode.com> | 2013-04-17 16:52:19 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@opscode.com> | 2013-04-17 18:31:09 -0700 |
commit | ac3e24b233f4986caed145071d14cc3acab58ca8 (patch) | |
tree | 3e7811fe272ab9be8321dd7b8a63b4f07372b1a0 /spec/unit/provider/user | |
parent | 8d544b751d2b7e328cd5be5fe01c5837b743ee3e (diff) | |
download | chef-ac3e24b233f4986caed145071d14cc3acab58ca8.tar.gz |
fix specs
Diffstat (limited to 'spec/unit/provider/user')
-rw-r--r-- | spec/unit/provider/user/useradd_spec.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/spec/unit/provider/user/useradd_spec.rb b/spec/unit/provider/user/useradd_spec.rb index 6baea80c6b..a33748fd97 100644 --- a/spec/unit/provider/user/useradd_spec.rb +++ b/spec/unit/provider/user/useradd_spec.rb @@ -56,6 +56,7 @@ describe Chef::Provider::User::Useradd do 'comment' => "-c", 'gid' => "-g", 'uid' => "-u", + 'password' => "-p", 'shell' => "-s" } @@ -101,7 +102,7 @@ describe Chef::Provider::User::Useradd do end it "should set useradd -p" do - @provider.password_option.should =~ / -p 'hocus-pocus'/ + @provider.universal_options.should =~ / -p 'hocus-pocus'/ end describe "and platform is Solaris" do @@ -119,9 +120,12 @@ describe Chef::Provider::User::Useradd do it "should write out a modified version of the password file" do password_file = Tempfile.new("shadow") password_file.puts "adam:existingpassword:15441::::::" - password_file.flush + password_file.close @provider.password_file = password_file.path @provider.stub!(:run_command).and_return(true) + # may not be able to write to /etc for tests... + temp_file = Tempfile.new("shadow") + Tempfile.stub!(:new).with("shadow", "/etc").and_return(temp_file) @new_resource.password "verysecurepassword" @provider.manage_user ::File.open(password_file.path, "r").read.should =~ /adam:verysecurepassword:/ @@ -202,7 +206,7 @@ describe Chef::Provider::User::Useradd do end it "runs useradd with the computed command options" do - command = "useradd -c 'Adam Jacob' -g '23' -s '/usr/bin/zsh' -u '1000' -m -d '/Users/mud' -p 'abracadabra' adam" + command = "useradd -c 'Adam Jacob' -g '23' -p 'abracadabra' -s '/usr/bin/zsh' -u '1000' -m -d '/Users/mud' adam" @provider.should_receive(:run_command).with({ :command => command }).and_return(true) @provider.create_user end @@ -216,7 +220,7 @@ describe Chef::Provider::User::Useradd do end it "should not include -m or -d in the command options" do - command = "useradd -c 'Adam Jacob' -g '23' -s '/usr/bin/zsh' -u '1000' -p 'abracadabra' -r adam" + command = "useradd -c 'Adam Jacob' -g '23' -p 'abracadabra' -s '/usr/bin/zsh' -u '1000' -r adam" @provider.should_receive(:run_command).with({ :command => command }).and_return(true) @provider.create_user end |