[rspec-users] The problem with learning RSpec

Ben Mabey ben at benmabey.com
Sat Jun 13 11:57:10 EDT 2009

Stephen Eley wrote:
> Ben and Rick,
> Thanks very much to both of you for the encouraging responses.  Your
> reply, Ben, came just in time as I was starting to wonder if I had
> made a complete and irrevocable ass of myself.
> On Fri, Jun 12, 2009 at 10:36 AM, Ben Mabey<ben at benmabey.com> wrote:
>> In general though I don't know if I
>> really see all of this as a problem specific to RSpec.  The problem is that
>> many people coming to RSpec are not just RSpec novices but are in fact TDD
>> novices (and Rails, and Ruby novices too boot at times as well!).
> FWIW, I agree totally.  In fact I re-read my message last night, and I
> want to retract one of my statements for sure: the statement that
> RSpec makes "some easy things easy, but other easy things very
> complicated."
> On deeper thought, I don't believe this is true.  RSpec doesn't make
> anything harder than it already is.  There's nothing _wrong_ with
> RSpec in this sense.  I think a more incisive statement would be that
> with RSpec, some complicated things _feel like they should be easier._
>  If only because other things feel so easy.  And newbies tend to
> confront those problem areas at a point in the growth curve where the
> complexity can be misinterpreted as them Just Not Getting It.  Some
> are driven off as a result.
> You're right about practice.  You're right that bringing together too
> many learning curves at once creates interference patterns that
> shouldn't be blamed on RSpec.  And Rick's reference to Martin Fowler's
> spiked learning curve -- "this is scary, this is nifty, WHOOPS I
> overdid it, this is okay in its place" -- is an excellent point.
> But I don't think it's totally out-of-bounds to frame it as an "RSpec
> problem," even if it isn't RSpec's fault.  The thing is...  Well...
> There are *opportunities* here.  If RSpec -- along with its tools and
> resources and culture -- was a little better at some of this stuff,
> how much easier would it be to learn *everything else?*
> How many of us learned BDD at the same time we learned programming?
> ...Show of hands?  Anyone?  The only developers who could make that
> claim would have to be pretty fresh out of the pond.  If that does
> apply to anyone reading this, please speak up -- I'd like to hear your
> thoughts on how you're doing.
> How many of us used TDD or BDD out of the gate when we learned Rails
> or Ruby?  This is plausible, but I get the sense it's uncommon.  Most
> of us don't even think to work on good testing practices until we
> believe we're getting the rest of the stuff down.  I know I didn't.

When learning a new technology I generally don't bother with testing let 
alone TDD (unless I think TDD could help the learning process).   It is 
like spiking and most of the stuff you are creating is throw-away code 
that won't need to be maintained.  There are times, like this, where 
testing isn't needed IMO.  But that isn't really your question is it.. 
You're wondering what effect teaching good testing practices up front 
would bring...  I've wondered this my self at times (in fact I'm helping 
prepare an intro rails course now and wresting with this very issue) and 
it seems like teaching good testing to people who don't even know OO can 
be like jumping in to the deep end of the pool.

> Formal education in programming doesn't help.  Not by any evidence to
> my eyes.  I've recently started seeing someone who's majoring in CS at
> a well-known university, and he said the first class he took on
> software design was in C.  Frickin' *C*.  _Then_ they did C++, and
> then Java, but there was nothing significant about testing.  I told
> him about Cucumber and it made his heart go pitter-patter.

I hear this complaint quite often and FWIW it is an untrue stereotype 
IME.  While I was at the university I was taught testing, design 
patterns, refactoring, Agile methodologies, pair programming, use cases, 
CI, etc...  In fact the first time I heard about TDD was in my first 
Java class where the professor would TDD all of his work in the lectures 
(live coding!).  We did team projects where we had a CI server setup and 
we were required to have tests and do pair programming at least part of 
the time.  We also had class projects where different teams would create 
different components and we had to work out our communication protocols, 
touch points, and integrate it all.  Anyways, I justed wanted to throw 
that out and say that formal education isn't totally failing like some 
people claim it is.  Only my "Software Engineering" courses taught and 
encouraged these practices, but I was still taught them.

> The teaching resources for Rails and Ruby don't help.  Just about
> every book makes a *nod* toward testing -- there's always a chapter,
> they always say "do this constantly" -- but the chapter's inevitably
> somewhere near the back, after everything else has been introduced.
> Rails culture is passionate about testing, but most of us don't start
> to tap into that culture until we're at 'Competent' or above.
> What if the world were different?  What if teaching were different?
> What if the predominant lessons people used to get started with Rails
> *did not* start with "Type 'rails', make a scaffold, watch it fly!"
> but instead started with, "What's the most important single piece of
> information in your app?  Okay, great.  Write a spec like this.  Now
> open up this file in /app/models..  [...]  Your spec passed, you're
> cooking!  Now let's spec a view so we can see that information...  Now
> let's spec a controller to bring them together..."
> (Even better would be to start with Cucumber, which would take up very
> little extra overhead in that type of tutorial.)

So...  From what I have seen people with little experience testing are 
able to pick up the notion of integration/acceptance testing a lot 
faster than object level testing.  So, I do think having a tutorial 
drive all the features out with Cucumber or just webrat+some testing 
framework isn't far fetched at all.  Object level examples are a 
different story though IME... 
> You get the gist.  What if learning Rails was *all about* learning
> BDD?  Would it make the Rails stuff easier to understand and develop
> competence faster?  I hypothesize that it would.
> Some things need to be easier in BDD before we can get there.  To me
> that means things need to be easier in RSpec.  I believe my tutorial
> above would be easy enough to do today on the model side, but it's
> just too cumbersome to write a view or controller spec.  You lose that
> "holy crap look how *fast* this is coming!" vibe which is so
> invigorating when you're doing something new.  We could make that
> tutorial happen when writing a controller spec takes about as long as
> writing the controller *code.*  There are some mitigators for this --
> the Shoulda macros may be great for this now that they work with RSpec
> -- but even so I think it's probably a little bit of wading into the
> swamp.
> I would like to see that world.  I'd like to help *make* it.  That
> college guy I'm dating has asked me about learning Rails -- but I'm
> planning to talk his ass off about Cucumber and RSpec before I agree
> to help him with code.  I'm hoping he'll be my experiment to test my
> hypothesis, and I'll get a better sense of just how easy or hard it is
> to learn agile Web development if BDD happens at the ground floor.
> Given time, I think the patterns facilitated by RSpec could
> *completely* revolutionize the way software happens everywhere, *if*
> the next generation of developers come to learn it first and not as an
> "add-on."  And that's why I'm picking on RSpec.  I can't think of any
> other technology in a better position to make this happen, with only
> some moderate shifts of emphasis in both the tools and the culture.
> Does anyone else think that'd be pretty cool?
Yeah, I think having such resources available would be very cool.  The 
most common complaint I hear in IRC rooms is that there is no good 
sample rails app that makes good use of RSpec and Cucumber.  I think 
there are some examples out there, but an app built as a tutorial would 
be much more helpful with the proper git tags and such.  I mentioned 
before that I was helping prepare a rails course.  This is with my local 
Ruby group and we have started on a tutorial app: 
It thought it would be cool to use this project and BDD all the way 
through and teach it like that.  However, I have other commitments so 
other people in the group will probably do most of the work without 
BDD... It is something I would like to revisit someday and provide such 
an app.  Have you started on a tutorial app like this yet?


More information about the rspec-users mailing list