[rspec-users] Best practices for sharing state between story steps?

aslak hellesoy aslak.hellesoy at gmail.com
Tue Sep 9 14:40:41 EDT 2008

On Tue, Sep 9, 2008 at 8:28 PM, Jim Morris <ml at e4net.com> wrote:
> Dan North wrote:
>> Hi Jim.
>> I guess I'm not a purist then - that looks fine to me, and it's probably
>> something I would consider doing too.
> I'd never call you a purist Dan ;) But I do feel less dirty now, although
> after reading Aslaks post
> I wonder what exactly is meant by stateless steps? It seems to me that you

What I mean by a stateless step is a step that doesn't assign or use
any @variables in its own context.

> have to set some kind of
> variable between steps to communicate what was done in one and what needs to
> be checked in another.
> Having been guilty of writing unit tests that were not stateless (ie one
> unit test depended on the
> result of a previous one, which BTW I really avoid doing), I did not
> consider setting variables
> between steps to be stateful.
>> scenario steps themselves. Perhaps not. In the latter case I would
>> definitely go with $globals to communicate state into your scenario, as long
>> as you promise never to use them in your application code. Never, you hear
>> me?
> Hmmm well OK I'll try to never use them ;)
> --
> Jim Morris, http://blog.wolfman.com
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

More information about the rspec-users mailing list