I tried to convert from FactoryGirl to FactoryBot. This should not be a big issue but i do not get it to work. The code:
Added to Gem File
gem 'factory_bot'
Added to spec_helper
FactoryBot.definition_file_paths = %w(spec/factories)
FactoryBot.find_definitions
config.include FactoryBot::Syntax::Methods
Factory
FactoryBot.define do
factory :user do
first_name 'John'
last_name 'Doe'
birthdate { 21.years.ago }
admin false
end
end
When i try to run a rspec test i get following error:
NoMethodError: undefined method 'first_name' in 'user' factory!
Method_missing at C:/jruby-9.1.17.0/lib/ruby/gems/shared/gems/factory_bot-5.0.2/lib/factory_bot/definition_proxy.rb:97
block in (root) at <path to factory>
It seems to me the gem is correctly loaded into the project, the factoryBot code is executed. But for some reason it does not recognize the structure of the factory.
Note: - I did a bundle install/update
first_name { 'John' }
– Gullett