我有两个问题:
将工厂用于非activerecord类是否正确?我就是这样做的:
FactoryGirl.define do
factory :stations, :class => Transactions::Stations do |f|
end
end
- 台站不是ActiveRecord
类型。这是有效的,在规范定义中有一些限制:
describe "Transactions:Stations" do
it 'has valid factory' do
FactoryGirl.create(:stations) # undefined method `save!` error
expect { FactoryGirl.build(:stations) }.to_not raise_error # OK
end
end
如何在Factory Girl中执行静态(类)方法测试? 我现在以非工厂的方式做到这一点:
expect(Transactions::Stations.find("MIX")).to_not be_blank