Class: FactoryGirlProfiling::Initializer

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_girl_profiling/initializer.rb

Class Method Summary collapse

Class Method Details

.initialize_rspecObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/factory_girl_profiling/initializer.rb', line 3

def self.initialize_rspec
  RSpec.configure do |config|
    if ENV['PROFILE_FACTORY_GIRL']
      config.before(:suite) do
        ActiveSupport::Notifications.subscribe("factory_girl.run_factory") do |name, start, finish, id, payload|
          FactoryGirlProfiling::Profiler.add(name, start, finish, id, payload)
        end
      end

      config.after(:suite) do
        FactoryGirlProfiling::Profiler.print_results
        FactoryGirlProfiling::Profiler.reset
      end
    end
  end
end