Class: Cadre::RSpec::NotifyOnCompleteFormatter

Inherits:
RSpec::Core::Formatters::BaseFormatter
  • Object
show all
Defined in:
lib/cadre/rspec/notify-on-complete-formatter.rb

Instance Method Summary collapse

Instance Method Details

#dump_summary(duration, example_count, failure_count, pending_count) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/cadre/rspec/notify-on-complete-formatter.rb', line 24

def dump_summary(duration, example_count, failure_count, pending_count)
  notifier = Cadre::Notifier.get.new

  if duration < 20
    notifier.transient = true
    notifier.summary = "Finished spec run"
    notifier.message = notify_message(duration, example_count, failure_count, pending_count)
  else
    notifier.summary = "Finished long spec run"
    notifier.message = notify_message(duration, example_count, failure_count, pending_count)
  end
  if failure_count > 0
    notifier.sound = "failure"
  else
    notifier.sound = "success"
  end
  notifier.go
end

#notify_message(duration, example_count, failure_count, pending_count) ⇒ Object



20
21
22
# File 'lib/cadre/rspec/notify-on-complete-formatter.rb', line 20

def notify_message(duration, example_count, failure_count, pending_count)
  "Total duration: #{duration}\n Total: #{example_count}\n Failed: #{failure_count}\n Pending: #{pending_count}\n\nFinished at #{Time.now}"
end