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

2008-09-11 Thread Jim Morris
Rick DeNatale wrote: I've done something similar, but I might have handled the steps implementation a bit differently in that I'm not sure my approach would be called stateless. For example say I had (in a very abstract form) Given 'Rick' has admin privileges Then 'Rick' can do

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

2008-09-10 Thread aslak hellesoy
On Tue, Sep 9, 2008 at 11:31 PM, Jim Morris [EMAIL PROTECTED] wrote: aslak hellesoy wrote: There is persistent state (database) and object state (the object that serves as a context for a scenario). I'm not saying that state in and of itself is bad. However, *coupling* is bad - for

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

2008-09-10 Thread Rick DeNatale
On Tue, Sep 9, 2008 at 8:42 AM, aslak hellesoy [EMAIL PROTECTED]wrote: On Tue, Sep 9, 2008 at 2:21 PM, Dan North [EMAIL PROTECTED] 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. The debate seems to be

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

2008-09-10 Thread Jim Morris
Rick DeNatale wrote: I've done something similar, but I might have handled the steps implementation a bit differently in that I'm not sure my approach would be called stateless. For example say I had (in a very abstract form) Given 'Rick' has admin privileges Then 'Rick' can do

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

2008-09-10 Thread Jonathan Linowes
of course, there's one 'global' shared between steps that we cant live without: response :) ___ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users

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

2008-09-09 Thread Dan North
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. The thing to bear in mind is that there is magic going on when you run steps. Each step in a scenario is run in the context of the same object instance (which you don't get to

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

2008-09-09 Thread aslak hellesoy
On Tue, Sep 9, 2008 at 2:21 PM, Dan North [EMAIL PROTECTED] 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. The thing to bear in mind is that there is magic going on when you run steps. Each step in a scenario is

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

2008-09-09 Thread Jim Morris
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

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

2008-09-09 Thread aslak hellesoy
On Tue, Sep 9, 2008 at 8:28 PM, Jim Morris [EMAIL PROTECTED] 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

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

2008-09-09 Thread Jim Morris
aslak hellesoy wrote: The debate seems to be whether step definitions should be stateful or not. In practice this is achieved by setting one or more @variables in a step and reusing them in a different step - all within a scenario. I think that is the debate, but I'd like to point out that

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

2008-09-09 Thread Matt Wynne
On 9 Sep 2008, at 19:52, Jim Morris wrote: aslak hellesoy wrote: The debate seems to be whether step definitions should be stateful or not. In practice this is achieved by setting one or more @variables in a step and reusing them in a different step - all within a scenario. I think that

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

2008-09-09 Thread aslak hellesoy
On Tue, Sep 9, 2008 at 8:52 PM, Jim Morris [EMAIL PROTECTED] wrote: aslak hellesoy wrote: The debate seems to be whether step definitions should be stateful or not. In practice this is achieved by setting one or more @variables in a step and reusing them in a different step - all within a

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

2008-09-09 Thread Jim Morris
Thanks for the hints, but I think I did point out I am not using Rails, I write Integration tests, that talk directly to the web application via HTTP running the full stack. So Active record is not available neither are transactions for the database. Sorry for the confusion. If I were using

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

2008-09-09 Thread Zach Dennis
On Tue, Sep 9, 2008 at 3:52 PM, Matt Wynne [EMAIL PROTECTED] wrote: On 9 Sep 2008, at 19:52, Jim Morris wrote: aslak hellesoy wrote: The debate seems to be whether step definitions should be stateful or not. In practice this is achieved by setting one or more @variables in a step and

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

2008-09-09 Thread Jim Morris
Sam Stokes wrote: It seems to me that with Given an existing post 'lol internet' # creates a post with that title Then the page should include 'lol internet' # assumes a post with that title the assumptions are in line with what you'd naturally understand from the English, whereas Given

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

2008-09-09 Thread Jarkko Laine
On 10.9.2008, at 0.29, Zach Dennis wrote: I don't think this works as you may expect since My SQL and PostgreSQL don't support nested transactions, which is what would happen if your test environment wrapped stories/scenarios in transactions and your application utilized transactions. I've

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

2008-09-08 Thread Jonathan Linowes
On Sep 7, 2008, at 7:58 PM, Sam Stokes wrote: What approaches do people use to achieve this? Perhaps I'm bucking what others have advised against, so take it for what it's worth. I make some limited use of global (instance) variables that correspond to english language pronouns. I have

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

2008-09-08 Thread Sam Stokes
Jonathan Linowes wrote: I make some limited use of global (instance) variables that correspond to english language pronouns. I have things like @current_user (corresponds to I), @current_project (corresponds to the project), etc. I am careful to be consistent. There's only a handful of these,

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

2008-09-08 Thread Jim Morris
Sam Stokes wrote: Jonathan Linowes wrote: I make some limited use of global (instance) variables that correspond to english language pronouns. I have things like @current_user (corresponds to I), @current_project (corresponds to the project), etc. I am careful to be consistent. There's only a

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

2008-09-08 Thread Sam Stokes
Zach Dennis wrote: This thread may help give you some insight... http://www.mail-archive.com/rspec-users@rubyforge.org/msg05382.html Thanks for pointing me there. The first insight it's given me is that I'm actually asking two different (though related) questions: 1) What's the best way to

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

2008-09-07 Thread Sam Stokes
Hi all, I'm just getting into RSpec stories and liking them (especially with webrat), but I'm finding it tricky to write steps that are self-contained and reusable, particularly where features intersect. What approaches do people use to achieve this? (Maybe a better question is, do people

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

2008-09-07 Thread Zach Dennis
This thread may help give you some insight... http://www.mail-archive.com/rspec-users@rubyforge.org/msg05382.html Zach On Sun, Sep 7, 2008 at 7:58 PM, Sam Stokes [EMAIL PROTECTED] wrote: Hi all, I'm just getting into RSpec stories and liking them (especially with webrat), but I'm finding it