我正在尝试在rails应用程序中创建shared_example。它正在工作,但我收到了弃用错误。我可以重构代码来解决这个问题吗?
Looking up factories by class is deprecated and will be removed in 5.0. Use symbols instead and set FactoryBot.allow_class_lookup = false.
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
关于这个主题的相关文章:FactoryBot namespaced models without class_name
从链接 - 更新工厂到factory :foo_bar, class: 'foo/bar' do; end
应该工作因为key.to_s.underscore.to_sym
in this class