D
David Palm
Hi all,
how can I set an expectation on an external command execution?
Code:
def do_stuff(arg)
%x(external_executable_name #{arg})
end
Test (not working):
it "shells out and executes 'external_executable_name' with a bunch of nifty options" do
Kernel.should_receive`).with("external_executable_name argy args")
@worker.do_stuff("argy args")
end
If I change the code to:
def do_stuff(arg)
Kernel.`(external_executable_name #{arg})
end
...the test passes.
If I change the code to:
def do_stuff(arg)
`(external_executable_name #{arg})`
end
...the test fails.
Any other ideas? I could use Kernel#system() of course, but then I'd lose the output (or I'd have to go through the hoops of redirecting and reading etc, which I'd prefer to avoid). Why can't I test for the original %x?
how can I set an expectation on an external command execution?
Code:
def do_stuff(arg)
%x(external_executable_name #{arg})
end
Test (not working):
it "shells out and executes 'external_executable_name' with a bunch of nifty options" do
Kernel.should_receive`).with("external_executable_name argy args")
@worker.do_stuff("argy args")
end
If I change the code to:
def do_stuff(arg)
Kernel.`(external_executable_name #{arg})
end
...the test passes.
If I change the code to:
def do_stuff(arg)
`(external_executable_name #{arg})`
end
...the test fails.
Any other ideas? I could use Kernel#system() of course, but then I'd lose the output (or I'd have to go through the hoops of redirecting and reading etc, which I'd prefer to avoid). Why can't I test for the original %x?