Guest User

Untitled

a guest
Jul 16th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. # spec_helper.rb
  2. RSpec.configure do |config|
  3. if ENV["RSPEC_WATCH_ME"]
  4. config.after(:suite) do
  5.  
  6. time_formatter = Class.new(Object) do
  7. include RSpec::Core::Formatters::Helpers
  8. end.new
  9.  
  10. log_file = File.join Rails.root, 'log', "rspec-test-runs-#{Date.today.to_s}.txt"
  11.  
  12. reporter = Rspec.configuration.reporter
  13.  
  14. passed = reporter.instance_variable_get(:@example_count)
  15. pending = reporter.instance_variable_get(:@pending_count)
  16. failed = reporter.instance_variable_get(:@failure_count)
  17. total = passed + failed
  18. start = Rspec.configuration.reporter.instance_variable_get(:@start)
  19. duration = if start; "#{time_formatter.format_seconds(Time.now - start)}s"; else "unknown"; end
  20.  
  21. FOR_APPENDING = 'a'
  22. File.open(log_file, FOR_APPENDING) do |file|
  23. file.puts(
  24. "[#{Time.now}] Finished in #{duration}. " +
  25. "#{total} examples, #{failed} failures, #{pending} pending"
  26. )
  27. end
  28. end
  29. end
  30. end
Add Comment
Please, Sign In to add comment