[rspec-users] BDD / cucumber thought - chaining 'Then' steps with Which
joshuachisholm at gmail.com
Fri Sep 26 08:59:43 EDT 2008
Stories without shared state feel clunky to me, because we would never speak
I also had a similar urge, don't know if it's a "programmer" urge:
Given a user
With the name 'josh'
And the password 'sesame'
...so I don't end up with an explosion of steps for 'a user with x', 'a user
with y', 'a user with x and y' .
So there are named things, but we also often want to refer to the anonymous
"last mentioned thing" like we do in speech. So I end up doing things like
Given /a user/ do
shared_state["he"] = shared_state["she"] = shared_state["it"] = User.new
...is that bad?
On Fri, Sep 26, 2008 at 12:30 PM, Matt Wynne <matt at mattwynne.net> wrote:
> Going back to the debate about keeping state between steps, I found myself
> with the mild urge to be able to write this today:
> Given there is a user
> And the user has 20 friends
> Then I should see a thumbnail of each of the users's friends
> Which should be a link to the user profile page for that friend
> NB: An idiom in this which may be songkick-only but was inspired by what
> we've read on this list, and worth explaining: "the user" as in "the user
> has 20 friends", means User.first in rails. If there's more than one user
> when this step runs, it will flunk, because the English no longer works.
> So anyway, what I was thinking was that it would be nice to be able to
> refer to the last thing I said I should be able to see, and decorate it with
> more specification in a subsequent step or steps.
> Obviously, I could roll these into one long Then step, but maybe this is
> more elegant...
> Just thinking out loud. I have no idea what the steps code would look
> In case you wondered: The opinions expressed in this email are my own and
> do not necessarily reflect the views of any former, current or future
> employers of mine.
> rspec-users mailing list
> rspec-users at rubyforge.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the rspec-users