I want to define alternative sets of fixtures per database table.
For example,
class BusinessSpec
describe "some aspect of businesses" do
fixtures :fixture_set_1
...
end
describe "so开发者_开发百科me unrelated aspect of businesses" do
fixtures :fixture_set_2
...
end
end
Is this, or something similar, possible?
It's much easier to do this using something like factory_girl. You can define multiple factories per table.
Factory.define :my_post, :class => Post do |f|
f.name "Mine"
f.created_at 2.weeks.ago
end
Factory.define :another_post, :class => Post, :parent => :my_post do |f|
f.name "Another"
end
The 2nd example keeps things dry. Factory girl is an easy replacement for fixtures. Try it, you'll love it.
精彩评论