[rspec-users] Do people write specs for the code in their steps? How?

Stephen Eley sfeley at gmail.com
Tue Dec 30 09:37:12 EST 2008

On Mon, Dec 29, 2008 at 11:17 PM, Erik Pukinskis
<erikpukinskis at gmail.com> wrote:
> This is one thing I don't get.  I just started implementing steps, but
> I feel like THAT code is all completely untested.  I don't know if my
> regular expression is correct, I don't know if it does what I think it
> should do.

The tests are tested by your working application.  If you have
application code that clearly does the right thing in actual use, but
your tests for that specific use case fail, your tests are broken.  If
your application has bugs but your tests for that use case pass, your
tests are broken.  If your application works and your tests pass, then
practically speaking the tests are valid.  If your tests fail and your
application fails for that use case, the tests are valid.

Is that the same as formal proof?  No.  From a formal logic
perspective it's not even in the ballpark.  And it's not necessarily
sufficient, either.  You could have entirely valid tests but still not
be testing everything you should.  There's always some edge case you
didn't think of.  TDD/BDD isn't formal, it's agile.  It's supposed to
make it easy to get to "good enough" and then improve incrementally
from there, raising the bar for "good enough" with every iteration.

As for writing tests for your tests...  Sure, you could potentially
have turtles all the way down.  But as I see it, I'm not being paid to
write tests.  Or when I'm doing projects for personal goals, the test
code isn't the goal.  Eventually common sense has to kick in, and you
have to trust yourself somewhere.  If you can't trust yourself, if
your regexes are so complicated that you can't understand them and
determine their validity with a couple of passing/failing application
cases, maybe you need to simplify things with clearer or more granular

Have Fun,
   Steve Eley (sfeley at gmail.com)
   ESCAPE POD - The Science Fiction Podcast Magazine

More information about the rspec-users mailing list