Testing simple STI with FactoryGirl

You can declare the definitions of factories as follow:

FactoryGirl.define do
  factory :task, class: 'Task' do
    shop
    currency
    value 10
  end

  factory :counter_task, parent: :task, class: 'CounterTask' do
  end
end

And now you can test base class isolated from its own factory and the same for each inherited class.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)