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