[rspec-users] Constraints / Global requirements
pergesu at gmail.com
Wed Jan 7 22:00:49 EST 2009
On Wed, Jan 7, 2009 at 6:22 PM, Stephen Eley <sfeley at gmail.com> wrote:
> On Wed, Jan 7, 2009 at 7:00 PM, Steve Molitor <stevemolitor at gmail.com> wrote:
>> Lots of features use the word "should" in their then clauses.
>> Take this example from the 'Feature Introduction' of the cucumber wiki:
>> Scenario: Buy last coffee
>> Given there are 1 coffees left in the machine
>> And I have deposited 1$
>> When I press the coffee button
>> Then I should be served a coffee
> Maybe I'm overly audacious, but I'd call that imprecise wording. A
> better clause would be "Then I am served a coffee."
meh. I use "should" all over the place in my features.
>> Should this be an rspec example instead? It certainly could be, but I don't
>> think an rspec example would communicate as well with the customer as the
>> feature would. And that's the primary goal here (as Pat and Matt have
>> reminded me!).
> I agree. This is a flawed feature, but it really ought to be a
> feature: it describes a stimulus (an action) and a response. But this
> example doesn't have much in common with your original e-mail
> validation example. In that case, what's the action and what's the
> response? And is a feature clearer to the customer to explain e-mail
> validation than a spec?
"pat.maddox at gmail.com".should be_valid_email
"pat.maddox+foo at gmail.com".should be_valid_email
"pat.maddox at gmail".should_not be_valid_email
Seems pretty clear to me.
Email validation and the lease cost formula are examples of acceptance
tests that are probably best handled with FIT. I know that cucumber
has FIT-inspired tables, but those are still coupled to scenarios,
Actually, I'd still prefer to write these tests with prose. But it'd
be super simple:
pat.maddox at gmail.com is a valid email address
pat.maddox at gmail is an invalid email address
You can achieve this with cucumber already...
Then pat.maddox at gmail.com is a valid email address
Then pat.maddox at gmail is an invalid email address
but it looks stupid.
More information about the rspec-users