lib/rspeed/extension.rb in rspeed-0.1.0 vs lib/rspeed/extension.rb in rspeed-0.2.0

- old
+ new

@@ -2,42 +2,10 @@ if ENV['RSPEED'] == 'true' require 'rspec/rails' RSpec.configure do |config| - config.before :suite do - File.open('rspeed.csv', 'w') { |file| file.truncate 0 } - end - - config.before do |example| - example.update_inherited_metadata start_at: example.clock.now - end - - config.after do |example| - file_path = example.metadata[:file_path] - time_difference = example.clock.now - example.metadata[:start_at] - - File.open('rspeed.csv', 'a') do |file| - file.write "#{time_difference},#{file_path}\n" - end - end - - config.after :suite do |_example| - result = {} - - CSV.read('rspeed.csv').each do |line| - result[line[1]] ||= 0 - result[line[1]] += line[0].to_d - end - - result = result.sort_by { |line| line[1] }.reverse - - File.open('rspeed.csv', 'w') { |file| file.truncate 0 } - - File.open('rspeed.csv', 'a') do |file| - result.each do |file_spec, time| - file.write "#{time},#{file_spec}\n" - end - end - end + config.before(:suite) { RSpeed::Observer.before_suite } + config.before { |example| RSpeed::Observer.before(example) } + config.after { |example| RSpeed::Observer.after(example) } end end