Skip to content
This repository has been archived by the owner on Mar 6, 2023. It is now read-only.

TheTeaNerd/factory_inspector

 
 

Repository files navigation

FactoryInspector

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 creates being invoked, slowing your 'in memory' test down unexpectedly. (Aside: build_stubbed is the ideal way to use FactoryGirl)

Installation

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

Usage

Assuming RSpec, edit spec/spec_helper.rb:

  require 'factory_inspector'

  FactoryInspector.instrument
  RSpec.configure do |config|
    config.after(:suite) { FactoryInspector.results }
  end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

How often is FactoryGirl being used during your tests?

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%