Forum: RSpec [cucumber] Using worlds for loading fixtures

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
A731aaa10cdbc1ca0e9b9ea94f28a667?d=identicon&s=25 Fedor Fomenko (ffomenko)
on 2009-03-13 09:36
What is the right place to load fixtures specific to a given scenario? I
was thinking of using Worlds. Is it the right place for loading/deleting
fixtures? How do I specify which world scenario should run in?
3c28deaff162aeda44f2e0bcdca1dacf?d=identicon&s=25 Joseph Wilk (josephwilk)
on 2009-03-13 11:31
(Received via mailing list)
Fedor Fomenko wrote:
> What is the right place to load fixtures specific to a given scenario? I
> was thinking of using Worlds. Is it the right place for loading/deleting
> fixtures? How do I specify which world scenario should run in?
>
There 3 options I can think of:

1. Background Feature
This allows you to specify specific set of  steps which are only run for
the scenarios in the relevant feature
(http://wiki.github.com/aslakhellesoy/cucumber/background). I would
recommend this approach if you are using the latest cucumber version
from github.

2, In the scenario
Are you hiding state setup which would be better placed in the plain
text scenario? You don't have to get too granular with the data setup, a
high level "Given the system is setup...." style could be used to avoid
noise that detracts from the scenario value.

3. Before
If you do this in a Before you can gain access to the scenario name
(http://rspec.lighthouseapp.com/projects/16211-cucu...). You
could switch this to run the relevant fixture if you wish. (This is a
bit smelly)

HTH

--
Joseph Wilk
http://blog.josephwilk.net
39100495c9937c39b2e0c704444e1b4a?d=identicon&s=25 Pat Maddox (Guest)
on 2009-03-13 12:11
(Received via mailing list)
On Mar 13, 2009, at 3:11 AM, Joseph Wilk wrote:

> This allows you to specify specific set of  steps which are only run
> for the scenarios in the relevant feature 
(http://wiki.github.com/aslakhellesoy/cucumber/background
> ). I would recommend this approach if you are using the latest
> cucumber version from github.

Makes sense if it applies to every scenario within a feature.


> 2, In the scenario
> Are you hiding state setup which would be better placed in the plain
> text scenario? You don't have to get too granular with the data
> setup, a high level "Given the system is setup...." style could be
> used to avoid noise that detracts from the scenario value.

What I do 99% of the time.


> 3. Before
> If you do this in a Before you can gain access to the scenario name 
(http://rspec.lighthouseapp.com/projects/16211-cucu...
> ). You could switch this to run the relevant fixture if you wish.
> (This is a bit smelly)

You could clean it up: http://gist.github.com/78518  but it's still
horrible :P

Pat
0be0e4aa42aacd9a8a95c792de273ca7?d=identicon&s=25 Aslak Hellesøy (aslakhellesoy)
on 2009-03-13 12:33
(Received via mailing list)
On Fri, Mar 13, 2009 at 11:37 AM, Pat Maddox <pat.maddox@gmail.com>
wrote:

>> 1. Background Feature
>  2, In the scenario
>> If you do this in a Before you can gain access to the scenario name (
>> http://rspec.lighthouseapp.com/projects/16211-cucu...). You
>> could switch this to run the relevant fixture if you wish. (This is a bit
>> smelly)
>>
>
> You could clean it up: http://gist.github.com/78518  but it's still
> horrible :P
>

How about this:
http://rspec.lighthouseapp.com/projects/16211-cucu...

Aslak
This topic is locked and can not be replied to.