Skip to content

Instantly share code, notes, and snippets.

@draveness
Last active September 29, 2017 08:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save draveness/bb69bf40d54f5ae803f0c6dfdcaed042 to your computer and use it in GitHub Desktop.
Save draveness/bb69bf40d54f5ae803f0c6dfdcaed042 to your computer and use it in GitHub Desktop.
Monitor FactoryGirl record creation with ActiveSupport notifications
# source: https://robots.thoughtbot.com/debugging-why-your-specs-have-slowed-down
# spec/spec_helper.rb
config.before(:each, :monitor_database_record_creation) do |example|
ActiveSupport::Notifications.subscribe("factory_girl.run_factory") do |name, start, finish, id, payload|
$stderr.puts "FactoryGirl: #{payload[:strategy]}(:#{payload[:name]})"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment