Factory Girl - 为非activerecord类编写测试,用于静态方法

时间:2014-05-15 10:01:58

标签: ruby-on-rails rspec factory-bot rspec-rails

我有两个问题:

2:次要问题

将工厂用于非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

1:主要问题

如何在Factory Girl中执行静态(类)方法测试? 我现在以非工厂的方式做到这一点:

expect(Transactions::Stations.find("MIX")).to_not be_blank

0 个答案:

没有答案