按类别查找的Factorybot已弃用

问题描述 投票:0回答:1

我正在尝试在rails应用程序中创建shared_example。它正在工作,但我收到了弃用错误。我可以重构代码来解决这个问题吗?

error

Looking up factories by class is deprecated and will be removed in 5.0. Use symbols instead and set FactoryBot.allow_class_lookup = false.

source

shared_examples 'a sanatized_record' do
  subject { build(described_class) }

  describe 'stripped_attributes' do
    described_class::STRIPPED_ATTRIBUTES.each do |attr|
      it "strips whitespaces from #{attr}" do
        original = subject[attr]
        subject[attr] = " #{original} "
        subject.validate
        expect(subject[attr]).to eq original
      end
    end
  end
end
ruby-on-rails ruby rspec factory-bot
1个回答
2
投票

关于这个主题的相关文章:FactoryBot namespaced models without class_name

从链接 - 更新工厂到factory :foo_bar, class: 'foo/bar' do; end应该工作因为key.to_s.underscore.to_sym in this class

© www.soinside.com 2019 - 2024. All rights reserved.