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?
Asked
Active
Viewed 236 times
0

Yong zhu
- 103
- 1
- 1
- 6
-
What testing framework are you using? – max pleaner May 28 '20 at 19:29
-
@maxpleaner I can use rspec or pytest – Yong zhu May 28 '20 at 19:33
1 Answers
1
Using rspec:
expect(Facter::Core::Execution).to receive(:execute).and_return(true)

max pleaner
- 26,189
- 9
- 66
- 118