Use current object for associations, preventing FactoryGirl creates a new one record in database. Works with FactoryGirl, RSpec and Minitest.
From rubygems:
Manually
gem install instance-factory
Gemfile
gem "instance-factory"
From source code:
git clone [email protected]:vgsantoniazzi/instance-factory.git
cd instance-factory
gem build --verbose instance-factory.gemspec
gem install instance-factory-version.gem
To include helper on FactoryGirl
FactoryGirl::SyntaxRunner.send(:include, InstanceFactory)
Adjust your spec_helper
RSpec.configure do |config|
config.include InstanceFactory
config.after(:each) do
instance_factory_clear!
end
end
Or to include on default test of rails 4
class ActiveSupport::TestCase
include InstanceFactory
end
after :each do
instance_factory_clear!
end
I ❤️ Open source!
Follow github guides for forking a project
Follow github guides for contributing open source
Gem is released under the MIT license.