[rspec-users] fixtures in stories

James Deville james.deville at gmail.com
Tue Jan 15 17:33:41 EST 2008


If you do a self.class.fixtures :all (or whatever name) in the given  
block, then you can read from fixtures, but you won't be able to do  
users(:tester), you'll have to do a User.find

JD
On Jan 15, 2008, at 7:23 AM, Ingo Weiss wrote:

> Thanks, Chris!
>
> This is how I create most of my data for stories. However, I have one
> case (globalize languages/countries) where loading the data from
> fixtures seems to make more sense. Also, I would like to load them in
> one place, globally for all stories, as you can do in spec_helper, in
> order to not have to include a 'Given language ...' in all of my
> stories. Is that possible?
>
> Ingo
>
>
> On Jan 15, 2008, at 4:07 PM, Chris Parsons wrote:
>
>> Hi Ingo,
>>
>> On 15 Jan 2008, at 14:55, Ingo Weiss wrote:
>>
>>> how/where do I load fixtures in stories?
>>
>> Try loading your data up manually using 'Given' blocks:
>>
>> (my_story.txt)
>> Given a user called Bob
>> And a user called Charlie
>>
>> and:
>>
>> (steps.rb)
>> Given "a user called $name" do |name|
>>   User.create! :name => name
>> end
>>
>> Hope this helps
>> Chris
>>
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>
> _______________________________________________
> rspec-users mailing list
> rspec-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users



More information about the rspec-users mailing list