Class: Cadre::RSpec3::NotifyOnCompleteFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/cadre/rspec3/notify-on-complete-formatter.rb

Instance Method Summary collapse

Constructor Details

#initialize(output) ⇒ NotifyOnCompleteFormatter

Returns a new instance of NotifyOnCompleteFormatter.



26
27
# File 'lib/cadre/rspec3/notify-on-complete-formatter.rb', line 26

def initialize(output)
end

Instance Method Details

#dump_summary(summary) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/cadre/rspec3/notify-on-complete-formatter.rb', line 29

def dump_summary(summary)
  duration = summary.duration
  example_count = summary.examples.length
  failure_count = summary.failed_examples.length
  pending_count = summary.pending_examples.length

  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/rspec3/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