Deprecated: I am not longer maintaining this little project. I recommend the wonderful TestProf instead.
FactoryInspector reports on where FactoryGirl is spending its time during your test runs. While FactoryGirl is awesomely useful, overuse can lead to slow tests due to a unexpected cascade of database writes when building test objects. FactoryInspector aims to help you find where object associations might be causing cascades.
The classic problem is using build
to keep a test entirely in memory, but not realising that object associations on the build
may lead to multiple create
s being invoked, slowing your 'in memory' test down unexpectedly. (Aside: build_stubbed
is the ideal way to use FactoryGirl)
Assuming you're using Bundler, add this line to your application's Gemfile
:
group :test do
gem 'factory_inspector'
end
And then update your gems:
$ bundle
Assuming RSpec, edit spec/spec_helper.rb
:
require 'factory_inspector'
FactoryInspector.instrument
RSpec.configure do |config|
config.after(:suite) { FactoryInspector.results }
end
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request