I am a bit stuck here with a modification to the HPUX user provider module. 

What I wrote works fine when running the rspec against it on HP-UX but 
fails everywhere else.  Part of the problem I is that to find if the system 
is trusted I have to run a shell command. 

To get the modify command to work correctly for trusted and untrusted 
systems, the code needs to be able to add a second program to the command 
line to reset password expiration to 0.

In the code I have a call to a routing to check for the system being a 
trusted computer. When bundler / rspec runs against it on my Linux test 
box, it fails because ther command is HPUX specific, as expected.

How do I stub / mock how to get it to have the rspec not try to make that 
call and take the provided return as if it had done so?  I tried stubs and 
mocks with no success, and I have tried as many ways as I could to figure 
this out with no success.

Code in hpux.rb:
 def modifycmd(param,value)
     cmd = super(param, value)
     cmd << "-F"
     if self.trusted == "Trusted"
        cmd << ";"
        cmd << "/usr/lbin/modprpw"
        cmd << "-v"
        cmd << "-l"
        cmd << "#{resource.name}"
     end
     cmd
  end


hpux_spec.rb subset:
  it "should add /usr/lbin/modprpw -v -l when modifying user if trusted" do
       resource.stubs(:allowdupe?).returns true
       provider.expects(:execute).with() { |args| 
 args.include?('/usr/lbin/modprpw') and args.include?("-v") and 
args.include?("-l") }
       provider.uid = 1000
  end



-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-dev+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-dev/3a21b300-eda7-4168-b1fe-44c28d932d2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to