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"
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