[rspec-users] cucumber and fixtures

Daniel Higginbotham lists at ruby-forum.com
Wed Oct 8 19:05:23 EDT 2008


Zach Dennis wrote:
> I use seed_fu with cucumber.
> 
> http://github.com/mbleigh/seed-fu/tree
> 
> To load them I use the following my features/steps/env.rb. I reload
> them for every scenarios:
> 
> Before do
>   ActiveRecord::Base.establish_connection(ActiveRecord::Base.configurations['test'])
>   ActiveRecord::Schema.verbose = false
>   load "#{RAILS_ROOT}/db/schema.rb"
>   Dir[File.join(RAILS_ROOT, "features/fixtures", '*.rb')].sort.each {
> |fixture| load fixture }
> end
> 
> My fixture files live in features/fixtures/ and each looks like:
> 
> # my_model.rb
> MyModel.transaction do
>    MyModel.seed_many(:id, [
>      { :name => "blah", :id => 1 },
>      { :name => "foo", :id => 2
>    ])
> end
> 
> I use seed_fu for seeding production data as well. I don't use it in
> the sense of Rails fixtures. I use it in the sense of "the app needs
> this data to even run, period." Seems maybe this is what you're
> looking for,
> 
> Zach

This isn't quite what I'm looking for. I'd actually like to be able to 
use the fixtures in spec/fixtures , just as I can for plain old specs. 
With specs, you can define which fixtures to use in each "describe" 
block, using something like

describe TodoList do
  fixtures :todo_lists, :todos, :users

  it "should return an error when blah blah blah" do
    ...
  end
end

Are you similarly able to load your YAML fixtures from spec/fixtures 
when you're running a Cucumber feature?

Thanks,
Daniel Higginbotham
-- 
Posted via http://www.ruby-forum.com/.


More information about the rspec-users mailing list