On 30 Dec 2008, at 04:17, Erik Pukinskis wrote:

The approach I like to take is to follow the guidance of the system
(cucumber + rspec) every step of the way. Right now there are no
passing steps, so I'd write the code for the 1st pending step, run the
features and find the first thing that is missing or failing.

This is one thing I don't get.  I just started implementing steps, but
I feel like THAT code is all completely untested.  I don't know if my
regular expression is correct, I don't know if it does what I think it
should do.  What I really want to do is write something like this:

describe "steps for withdrawing money"

 describe "Given user has a balance"

   before :each
     cucumber "Given user has $50 dollars"
   end

   it "should match a particular step"

   it "should create an account"

   it "should set the account balance to $50"

 end

end


But is there such a "cucumber" method?  And how do you check that your
regular expressions are going to the right place?

Maybe the best thing to do is write your cucumber steps like this:

 user_has_a_balance = /user has $(.*) dollars/
 Given user_has_a_balance do |balance|
   ...
 end

And then in your spec you can do:

 user_has_a_balance.match("user has $20 dollars").should_not == nil

How do people write specs for their cucumber steps?  And if you don't
write specs, how do you live with the uncertainty?

Erik

It seems like at least part of the uncertainty you're talking about is that the step matcher in your step definition ruby code won't match all the steps defined in your features files that you intended it to. I have also worried about this, particularly after refactoring steps in a codebase with a large number of features.

A while back, I suggested a feature for cucumber, which would allow you to run it in a 'strict' mode, where the build would fail if any of the steps in features were not matched to a ruby step definition. I'm not sure whether this ticket has been implemented or not - I had a feeling it was, but I can't see anything in the help for 0.1.13, and the ticket hasn't been updated. Plus it's Christmas and my brain is pickled. Anyway, take a look at the ticket:

http://rspec.lighthouseapp.com/projects/16211-cucumber/tickets/52-unmatched-steps-should-less-tolerable-than-pending-steps#ticket-52-23

cheers,

Matt Wynne
http://blog.mattwynne.net
http://www.songkick.com

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

Reply via email to