[rspec-users] bad specs better than none?

David Chelimsky dchelimsky at gmail.com
Thu Feb 28 09:16:17 EST 2008


On Thu, Feb 28, 2008 at 7:22 AM, Glenn Ford <glenn at aldenta.com> wrote:
> I have a similar perspective from my own personal experience.  I am
>  still quite the novice, but I'm as much of a novice in RSpec as I am
>  in Ruby / RoR.  Honestly, a lot of my specs in new sections end up
>  having great coverage, but are full of real models and few of the
>  "purist" BDD practices.  Before I started with BDD I did a lot of
>  reading so I feel that I have a good understanding of the goal, and I
>  do have some specs with little database access and great
>  implementation of the MVC "goodness" that RoR supports, but I simply
>  can't always keep this up even when I want to.
>
>  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!
>
>  So while I have a lot of the knowledge behind the theory of good BDD
>  practice, I can't always implement it even when I want to.  My Ruby /
>  RoR inexperience is what holds me back the most in that department.
>  It's just something I have to cultivate really.  Until then I'm happy
>  with my green specs with excellent coverage that slam the database
>  like crazy and take a long time and have few mocks/stubs/
>  should_receives.

And you *should* be happy with that! The beauty of your situation is
that even though you are admittedly new at this you are able to
deliver code in which you have confidence. Clearly you recognize that
you have some growth ahead, but you're posing much less risk for your
clients.

Additionally, as you do learn, because you have good coverage, you'll
be in a good position to address design decisions that you later
decide are poor based on new understanding.

Naturally, since you are not 100% clear about what's going on you may
be missing a step here and there. Test quality is every bit as
important as test coverage, but good coverage is a better place to
start than poor coverage.

Keep up the good work!

Cheers,
David

>
>  Glenn
>
>
>
>  On Feb 27, 2008, at 10:45 PM, Kero wrote:
>
>  >>> I also had to go into specs on a project I'm not working on, and
>  >>> found
>  >>> an unholy hive of database-accessing specs. It's disheartening.
>  >>> Basically, it's cargo cult development practices - using the "best
>  >>> practice" without actually understanding it.
>  >>
>  >> This is a really tough problem. The whole motivation for BDD was
>  >> "people don't get TDD, so let's come up with some new ways to frame
>  >> it
>  >> so people get it." Now people don't get the new frame. In that
>  >> respect
>  >> we've made things twice as bad.
>  >
>  > What did you expect? Honestly?
>  > You need to show people the Right way, otherwise they're unlikely to
>  > figure
>  > it out by themselves. But as the fortune cookies go:
>  > "To make the right decision, one needs experience.
>  >  To gain experience, one needs to make the wrong decision."
>  >
>  > It is easier for me to explain this from the point of view of aikido:
>  > I've been shown the right moves thousands of times. I can not even see
>  > what sensei does, let alone reproduce it. I can not perceive the
>  > balance,
>  > the timing, the acceptance of an attacker and the reflection of his/
>  > her
>  > energy to -ultimately- unbalance. How could I learn by trying even
>  > tens
>  > or hundreds of thousands of time?
>  > After seven years, I'm still a puny beginner. And I need other people
>  > to show me my mistakes. Again, again and again.
>  >
>  > To the original poster: yes, teach BDD.
>  > Make sure they accept you as a teacher,
>  > then teach, small steps at a time, by showing what is wrong.
>  > when they figure out a solution by themselves, encourage them, accept
>  > that solution (use it yourself). When they don't figure it out by
>  > themselves (likely enough), show how you would do it.
>  > And be prepared to repeat yourself.
>  >
>  > HtH,
>  > Kero.
>  > _______________________________________________
>  > rspec-users mailing list
>  > rspec-users at rubyforge.org
>  > http://rubyforge.org/mailman/listinfo/rspec-users
>
>  _______________________________________________
>  rspec-users mailing list
>  rspec-users at rubyforge.org
>  http://rubyforge.org/mailman/listinfo/rspec-users
>


More information about the rspec-users mailing list