[rspec-users] bad specs better than none?

Siemen Baader siemenbaader at gmail.com
Fri Feb 29 02:55:57 EST 2008


On Thu, Feb 28, 2008 at 2:22 PM, Glenn Ford <glenn at aldenta.com> wrote:

I agree with David - you are certainly on the right track. I also think you
are doing the right thing when you write specs even if they seem not perfect
to you at first attempt - once you have written the code you can evaluate
why they could be better and then make your adjustments as you learn more.


A lot of times if I'm writing some code for a challenging piece, it's
> challenging to me because I don't already know how to do it.  I can
> write the basic "here's the setup, result.should eql(this_thing)" but
> I can't write any mocks/stubs/should_receives in the middle because at
> every step, I just honestly have no idea how it should work!!  So I
> throw in real models and try to make it as real as possible, rather
> than as "pure" as possible.  It's not until after I get things working
> that I even know what the solution should remotely look like.  This is
> due to my inexperience that I have to hack around a lot before I
> figure out how to make things work.  Unfortunately, I know this means
> I write code that is more complicated than it should be, but if I
> can't figure out a better way, I have to write something that still
> works!



I also often find it hard to implement a new solution from scratch using the
BDD / TDD test-first approach. Sometimes it works for me to make a very
crude spike solution to figure out how this part of the program actually
should work (often writing no automated tests at all). Once I have an idea
of the outline I put the spike away and start implementing the real solution
in the real codebase, writing tests first etc.

Interestingly, it seems to me that the whole task actually _is_ accomplished
quicker this way because I don't have to keep the production code clean &
tested while experimenting and because I don't have to sit and figure out
the design while writing the production code.

As a gain experience I think there will be more solutions that I can
implement without having to spike them before.

 -- Siemen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080229/bbef9a45/attachment-0001.html 


More information about the rspec-users mailing list