【发布时间】:2014-06-15 00:19:22
【问题描述】:
#spec
let(:price) { create :price,:some_trait,:my_trait }
#factory
FactoryGirl.define do
factory :price, class: 'Prices::Price' do
...
after(:build) do |p,e|
# How I can get the traits passed to the create method?
# => [:some_trait,:my_trait]
if called_traits_does_not_include(:my_trait) # fake code
build :price_cost,:order_from, price:p
end
end
...
end
end
如何在工厂的after(:build) 回调中获取传递给create 的特征?
【问题讨论】:
标签: ruby rspec factory-bot