Okay, so what I’m trying to do is write a rake task that runs my specs
and then, if they succeed, run svn commit. (In lieu of continuous
integration since I want it to happen semi-manually for now.) So
basically I’m running ‘rake spec’ and then checking the exit status.
However, I seem to have to run into a bug with RSpec. This is similar
to this bug report in Cucumber 1. I’m using spork to run my specs,
so naturally I’m using the --drb option. However, I’ve noticed that
when doing so (tested using just ‘spec SOME_FILE --drb’), ‘spec’ will
always return an exit code of 0. Ultimately this means that ‘rake
spec’ always returns an exit code of 0 too.
I’ve tried to take the patch applied to Cucumber and apply it to RSpec
but obviously the two are not built quite the same. I’ve looked inside
the RSpec code and here’s what I think I’ve figured out so far. So it
looks like when --drb is passed, OptionParser#parse_drb is eventually
called. And it looks like what that does is tell spork to run the
tests via DRb, and then since tests are already being run, it tells
itself to not run the tests by saying
@options.examples_should_not_be_run. Simple enough. However, jump to
Options#run_examples. That returns true if the examples should not be
run. But uh-oh, that means Spec::CommandLine.run (and also
Spec::Runner.run) returns true. Which means that ‘spec’ is essentially
saying ‘exit true’, and then when Spec::Runner.autorun is called the
same thing happens.
Does this look right or am I off track here? If so, how complicated
would it be to fix RSpec so the exit status depends on whatever spork
returns?
– Elliot