On 11 Jul 2007, at 15:00, Pedro Del Gallego wrote:

>  Thats my biggest problem with rspec, (I'm a non english speaker
> working in a German/English environment)  It would be great a guide or
> a tips list to make our specs more  readebles, Something like 10
> English tips to improve your specs readability ;)


Don't think I can come up with 10 off the top of my head but I always  
told Pawel to follow the rule "phrase descriptions as GIVEN WHEN  
THEN".  There's plenty of better examples on this list and elsewhere,  
but basically if I have an idea like this:

   A cow prodded with a stick should moo

I think:
   GIVEN="a cow", WHEN="prodded with a stick", THEN="moo"

and turn it into this code:
   describe Cow do
     before(:each) do
       @cow = Cow.new
     end
     it 'should say "moo" when sent prod_with_stick' do
       @cow.prod_with_stick.should == "moo"
     end
   end

It doesn't apply rigidly to every situation, but 90% of the time, if  
I keep chanting GIVEN WHEN THEN I write clean, focussed specs.  The  
rest is mainly vocabulary (although sometimes it can be hard to  
phrase something clearly).

Ashley
_______________________________________________
rspec-users mailing list
rspec-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users

Reply via email to