Class: Autotestforphp::Result

Inherits:
Object
  • Object
show all
Includes:
REXML
Defined in:
lib/autotestforphp/result.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(num_tests, num_assertions, num_errors, num_failures) ⇒ Result

Returns a new instance of Result.



10
11
12
13
14
15
# File 'lib/autotestforphp/result.rb', line 10

def initialize(num_tests, num_assertions, num_errors, num_failures)
  @num_tests = num_tests
  @num_assertions = num_assertions
  @num_errors = num_errors
  @num_failures = num_failures
end

Instance Attribute Details

#num_assertionsObject (readonly)

Returns the value of attribute num_assertions.



5
6
7
# File 'lib/autotestforphp/result.rb', line 5

def num_assertions
  @num_assertions
end

#num_errorsObject (readonly)

Returns the value of attribute num_errors.



5
6
7
# File 'lib/autotestforphp/result.rb', line 5

def num_errors
  @num_errors
end

#num_failuresObject (readonly)

Returns the value of attribute num_failures.



5
6
7
# File 'lib/autotestforphp/result.rb', line 5

def num_failures
  @num_failures
end

#num_testsObject (readonly)

Returns the value of attribute num_tests.



5
6
7
# File 'lib/autotestforphp/result.rb', line 5

def num_tests
  @num_tests
end

Class Method Details

.build_from_xml(xml) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/autotestforphp/result.rb', line 30

def self.build_from_xml(xml)
  unless xml.is_a?(Document)
    xml = Document.new(xml)
  end
  results = XPath.first(xml, '//testsuite')
  num_tests = results.attributes["tests"].to_i
  num_failures = results.attributes["failures"].to_i
  num_errors = results.attributes["errors"].to_i
  num_assertions = results.attributes["assertions"].to_i
  new(num_tests, num_assertions, num_errors, num_failures)
end

Instance Method Details

#imageObject



21
22
23
24
25
26
27
28
# File 'lib/autotestforphp/result.rb', line 21

def image
  config = Autotestforphp::Notification::Config
  if num_failures == 0 and num_errors == 0
    config.success_image
  else
    config.fail_image
  end
end

#messageObject



17
18
19
# File 'lib/autotestforphp/result.rb', line 17

def message
  "#{num_tests} tests, #{num_assertions} assertions, #{num_failures} failures, #{num_errors} errors"
end