Is there a way to mock Facter::Core::Execution.execute output in ruby?

288 Views Asked by At

I have a custom fact in ruby that uses Facter::Core::Execution.execute to execute a system command and sets the fact to true or false based on the output of the execute command. Is there a way I could mock the output of the execute command to test it?

1

There are 1 best solutions below

0
max pleaner On BEST ANSWER

Using rspec:

expect(Facter::Core::Execution).to receive(:execute).and_return(true)