Testing Factory Registration Without Implementation Blocks in factory_bot
This test suite examines the core functionality of FactoryBot’s factory definition system without explicit blocks. It specifically validates the registration and instantiation of basic model factories, demonstrating the framework’s ability to handle minimal factory definitions.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
thoughtbot/factory_bot
spec/acceptance/definition_without_block_spec.rb
describe "an instance generated by a factory" do
before do
define_model("User")
FactoryBot.define do
factory :user
end
end
it "registers the user factory" do
expect(FactoryBot::Internal.factory_by_name(:user))
.to be_a(FactoryBot::Factory)
end
end