FactoryBot未初始化的常量FactoryName

时间:2019-03-12 12:06:54

标签: ruby rspec factory-bot

我有工厂

FactoryBot.define do
    factory :activity_fit_file do
        association :user, factory: :user
        activity_type {:cycling}
        after(:build) do |activity|
            activity.original_activity_log_file.attach(
                io: File.open("#{Rails.root}/spec/files/example_fit_file.fit"),
                filename: 'example_fit_file.fit',
                content_type: 'application/vnd.ant.fit'
            )
        end
    end
end

在我看来,我有

require 'rails_helper'

RSpec.describe "Activity upload fixer" do
    it 'converts fit files to gpx' do
        activity = FactoryBot.create(:activity_fit_file)
    end
end

运行规范会给出错误

 NameError:
   uninitialized constant ActivityFitFile

不太确定出什么问题了,因为它看起来与其他工作工厂相同。

0 个答案:

没有答案