Just want to make sure I understand things.
From what I gather so far, Cucumber is simply a ‘wrapper’ or a nice way to organize your tests by categorizing things into features and steps, where the actual unit tests are in the steps phase.
It allows to organize your tests into how things will work.
Is that correct?
Sort of.
It is a way to organize tests, but it’s more than that. It behaves like the original Rails integration tests were supposed to, but is much easier to use. The big win here being that your session is maintained transparently across the entire
Scenario.Another thing that’s going on with Cucumber is that you’re (supposed to be) testing from the point-of-view of a browser or client using your code. If you want you can use steps to build objects and set up state, but usually you want your steps to go through the motions required to achieve that state in the first place.
For example you could do this:
But you should probably do something like this instead:
And of course you can pass in arguments to either of those steps to give your calling code some more fine-grained control over the step’s behavior.
What I have generally been doing with my tests is as follows.
And, of course, I still write Rails unit tests for my models, libraries, helpers, etc.