Class: Uberspec::Notify::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/uberspec/notify.rb

Direct Known Subclasses

Growl, LibNotify

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pass_img, fail_img) ⇒ Base

Returns a new instance of Base.



8
9
10
11
# File 'lib/uberspec/notify.rb', line 8

def initialize(pass_img,fail_img)
  @passing_image = pass_img
  @failure_image = fail_img
end

Instance Attribute Details

#failure_imageObject (readonly)

Returns the value of attribute failure_image.



5
6
7
# File 'lib/uberspec/notify.rb', line 5

def failure_image
  @failure_image
end

#passing_imageObject (readonly)

Returns the value of attribute passing_image.



6
7
8
# File 'lib/uberspec/notify.rb', line 6

def passing_image
  @passing_image
end

#statsObject (readonly)

Returns the value of attribute stats.



4
5
6
# File 'lib/uberspec/notify.rb', line 4

def stats
  @stats
end

Instance Method Details

#bodyObject



22
23
24
25
26
27
28
29
30
# File 'lib/uberspec/notify.rb', line 22

def body
  %Q{
#{stats[:examples]} Examples
#{stats[:failed]} Failed
#{stats[:pending]} Pending

Tests took #{stats[:time]} seconds
  }
end

#commandObject



32
33
34
# File 'lib/uberspec/notify.rb', line 32

def command
  raise "'command' Must be defined by notification library"
end

#imageObject



36
37
38
# File 'lib/uberspec/notify.rb', line 36

def image
  failed ? failure_image : passing_image
end

#notify(stats = {}) ⇒ Object



13
14
15
16
# File 'lib/uberspec/notify.rb', line 13

def notify(stats = {})
  @stats = stats
  system("#{command} #{title} #{body} #{image}")
end

#titleObject



18
19
20
# File 'lib/uberspec/notify.rb', line 18

def title
  failed ? "Tests Failed!" : "Tests Passed!"
end