[rspec-users] Any tips on teaching BDD with RSpec?

Pat Maddox pergesu at gmail.com
Wed Oct 17 13:14:10 EDT 2007

On 10/17/07, Ashley Moran <work at ashleymoran.me.uk> wrote:
> Hi
> I hope this is not OT.  I'm training my replacement at work to do BDD
> Rails development.  He's done a CS/maths degree but has no
> professional programming experience, so he's never NOT done a project
> without BDD.  In a way I am jealous of his unspoilt situation :)
> I've gone about things this way:
>    * first teach him some Ruby (he did mainly Java at uni)
>    * then let him write a small program (to a rough description I
> came up with) in Ruby however he wants
>    * then teach him how to do BDD-driven OO
>    * then let him re-write the sample app in a BDD way.
> The app loads a YAML file that lists some URLs, fetches the pages off
> the interweb, extracts some data from the body of the spec, and
> outputs it to XML.  He's picking stuff up quick - he wrote it in
> about 1 1/2 days despite only learning Ruby last week.
> I've gone through a really simple BDD example with him that is quite
> similar to part of the bigger app - he seems to follow the syntax of
> RSpec and flexmock, understands the concepts of full and partial
> mocks, etc.  But I've left him to rewrite his app along the same
> lines, and it's like there is a void.  Where before he just kept
> working at little bits until the output built up, now he's got the
> ability to isolate simple bits of code and develop/test them (eg
> formatting a <page> tag from a URL), he's taking longer.  He seems to
> be struggling to pick isolated pieces of functionality out of the
> bigger problem.
> One thing I have done for him is write a functional test - one that
> runs the whole app "WebParse.run(infile, outfile)" black-box style,
> and compares the output in "outfile" to the output of his existing
> app (which we've decided between us is correct and suitable as a
> reference).  I'm not sure if this has helped or confused the issue.
> Clearly there is something important I am not explaining, something I
> take for granted.  Does anyone have any ideas what? I was hoping
> someone else here has been through the experience of teaching BDD
> (RSpec or otherwise) from scratch and may be able to point me in the
> right direction.
> Thanks for any advice
> Ashley
> PS I haven't told him to subscribe to this list yet, so I'm safe to
> talk about him for a bit :o)
> --
> blog @ http://aviewfromafar.net/
> linked-in @ http://www.linkedin.com/in/ashleymoran
> currently @ work
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

Hey Ashley,

First of all, fun situation to be in!  I like installing BDD into
impressionable minds  - I create one more person who thinks I'm

I would say the best way to do this is to pair.  Start off with a toy
app, introducing him to the syntax and basics of RSpec.  I would
definitely start off with user stories, and then get into the
nuts-and-bolts object spec'ing.  Perhaps you could write one full
scenario in story runner (as I'm sure that's completely foreign to
him), and then you two can bounce back and forth while implementing
it.  You start off doing 60% of the coding letting him take 40%.
Gradually let him take over more as he gets the hang of it, then you
can lean back and sip pina coladas, swacking him with a ruler whenever
he missteps.

After you've done a little toy app, I would go to a part of your real
app.  If you've got any areas that have weak/no coverage, write some
specs for it together.  You can help show him how to retrofit specs
onto existing code, and you strengthen your coverage to boot!

I think you'll BOTH learn more and be far more efficient if you pair
together rather than giving him a bit of theory/tips & tricks and then
leaving him to his own devices.


More information about the rspec-users mailing list