Closed bitgangsta closed 10 years ago
Hi, can you add a test case for this?
@jyurek Sure I'm happy to add a test case. Can you think of a sure way to have $?
return nil
? For other test cases (where it is to return a return value), I see you guys have a small ruby script return the appropriate value. But for a nil value... my concern is: If state is left around from other tests $?
could be set to something. And it can't be set directly, since Ruby doesn't like that. There might be some way to hook into the language and do it, but I'd have to research... Curious if you have any suggestions. It doesn't feel like this is an easy test to write (the thought crossed my mind).
That's a good point. One way would be to extract the ternary you added into a new method, which you could stub for the purpose of testing. That might even be the only good way, actually.
Sorry about the delay. I pulled this in. The test isn't appreciably different and, as we discussed, it's difficult to test because of how Ruby works. Thanks!
Hi,
For an app I'm building ontop of cocaine, I'd like to be able to use the
FakeRunner
for testing in certain circumstances (for instance to log what commands will be run w/o actually running them). However, when I attempt to, the$?
object is nil, and thus I get the following error:It would seem that setting
@exit_status
conditionally, as you were, is unsafe since it is possible it will not be set. I have made the following (very small) change to set it to 0 when$?
is unavailable. This means when using the FakeRunner (or if for some reason$?
is not supported by the given runner), the exit status checking won't throw a fit.