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

Ashley Moran work at ashleymoran.me.uk
Wed Oct 17 16:30:48 EDT 2007


On Oct 17, 2007, at 6:52 pm, Ed Howland wrote:

> If it were up to me, I would start with BDD, Probably, immediately
> right after hello_world.rb. Even before they learn any Ruby syntax at
> all. Your toy app sounds more like a real application to me. It has
> actual user stories, confirmable results, etc.
>
> Why not break the usual cycle of code a little, test, code a bit more,
> test, repeat, from the start? RSpec is a DSL, like Rails is a DSL. And
> you don't need to know much ruby to get started in Rails. I say that
> holds true in RSpec as well. The only qualms I can see is the concept
> of Mocks. But you could introduce that in something he is familiar
> with like Java.

That's an interesting approach.  My only hesitation is that if he's  
seen to be writing Rails apps it might be interpreted by management  
that he's learnt everything there is to know about behaviour-driven  
object-oriented MVC web programming, and I wouldn't get chance to  
show him the good stuff before I leave.

I think it's good to see something working, but I wanted to avoid  
instilling Rails = Ruby in him.  That's why I started writing specs  
for trivial things, then simple things like loading a YAML file.

Interestingly, mocks were a tough one.  It took a while to explain  
the difference between full and partial mocks, and the difference  
between mocking instances and stubbing on classes.  I don't think it  
was the concept of imaginary objects, more the idea of setting  
expectations on them and describing interactions, as opposed to  
seeing whether the final output of the program is right.


> I only wish my mentor had forced me to learn test first, back in the
> day. But that was before all you geniuses where on the scene to set us
> straight!

I feel spoilt too, I was lucky to stumble on RSpec (and more  
importantly, rspec-users) so soon after I started learning unit  
testing.  And Jim is a lucky guy too, having someone like me around  
to tirelessly relay the replies of experts to him.

Ashley


--
blog @ http://aviewfromafar.net/
linked-in @ http://www.linkedin.com/in/ashleymoran
currently @ home



More information about the rspec-users mailing list