Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # spec_helper.rb
- RSpec.configure do |config|
- if ENV["RSPEC_WATCH_ME"]
- config.after(:suite) do
- time_formatter = Class.new(Object) do
- include RSpec::Core::Formatters::Helpers
- end.new
- log_file = File.join Rails.root, 'log', "rspec-test-runs-#{Date.today.to_s}.txt"
- reporter = Rspec.configuration.reporter
- passed = reporter.instance_variable_get(:@example_count)
- pending = reporter.instance_variable_get(:@pending_count)
- failed = reporter.instance_variable_get(:@failure_count)
- total = passed + failed
- start = Rspec.configuration.reporter.instance_variable_get(:@start)
- duration = if start; "#{time_formatter.format_seconds(Time.now - start)}s"; else "unknown"; end
- FOR_APPENDING = 'a'
- File.open(log_file, FOR_APPENDING) do |file|
- file.puts(
- "[#{Time.now}] Finished in #{duration}. " +
- "#{total} examples, #{failed} failures, #{pending} pending"
- )
- end
- end
- end
- end
Add Comment
Please, Sign In to add comment