Testing CamelCase String Factory Definitions in Factory Bot
This test suite validates Factory Bot’s ability to handle factory definitions using camel case strings. It ensures proper registration and instantiation of factories when defined with CamelCase naming conventions, which is crucial for maintaining flexibility in factory naming patterns.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
thoughtbot/factory_bot
spec/acceptance/definition_camel_string_spec.rb
describe "an instance generated by a factory named a camel case string " do
before do
define_model("UserModel")
FactoryBot.define do
factory "UserModel", class: UserModel
end
end
it "registers the UserModel factory" do
expect(FactoryBot::Internal.factory_by_name("UserModel"))
.to be_a(FactoryBot::Factory)
end
end