class YertleFormatter

Attributes

slow_specs[R]

Public Instance Methods

dump_summary(summary_notification) click to toggle source
Calls superclass method
# File lib/yertle_formatter.rb, line 17
def dump_summary(summary_notification)
  super(summary_notification)
  summarize_slow_specs(summary_notification) if slow_specs
end
example_passed(notification) click to toggle source
# File lib/yertle_formatter.rb, line 8
def example_passed(notification)
  if slow_spec?(notification.example)
    @slow_specs = true
    print_turtle
  else
    print_dot
  end
end

Private Instance Methods

print_dot() click to toggle source
print_turtle() click to toggle source
slow_spec?(example) click to toggle source
# File lib/yertle_formatter.rb, line 24
def slow_spec?(example)
  example.metadata[:execution_result].run_time > threshold
end
slow_spec_examples(summary_notification) click to toggle source
# File lib/yertle_formatter.rb, line 55
def slow_spec_examples(summary_notification)
  summary_notification.examples.select do |example|
    slow_spec?(example)
  end.sort do |example_1, example_2|
    example_2.metadata[:execution_result].run_time <=> example_1.metadata[:execution_result].run_time
  end
end
slow_time_environment_variable() click to toggle source
# File lib/yertle_formatter.rb, line 40
def slow_time_environment_variable
  ENV["YERTLE_SLOW_TIME"] ? ENV["YERTLE_SLOW_TIME"].to_f : nil
end
summarize_slow_specs(summary_notification) click to toggle source
# File lib/yertle_formatter.rb, line 44
  def summarize_slow_specs(summary_notification)
    output.puts "\n------"
    slow_spec_examples(summary_notification).each do |example|
      slow_test_description = <<-SLOW_TEST_OUTPUT
"#{example.full_description}" #{example.metadata[:execution_result].run_time} seconds
#{example.location}
      SLOW_TEST_OUTPUT
      output.puts slow_test_description
    end
  end
threshold() click to toggle source
# File lib/yertle_formatter.rb, line 36
def threshold
  slow_time_environment_variable || RSpec.configuration.yertle_slow_time || 0.1
end