Class: Applitools::TestResults
- Inherits:
-
Object
- Object
- Applitools::TestResults
- Defined in:
- lib/applitools/core/test_results.rb
Instance Attribute Summary collapse
-
#is_new ⇒ Object
Returns the value of attribute is_new.
-
#matches ⇒ Object
readonly
Returns the value of attribute matches.
-
#mismatches ⇒ Object
readonly
Returns the value of attribute mismatches.
-
#missing ⇒ Object
readonly
Returns the value of attribute missing.
-
#original_results ⇒ Object
readonly
Returns the value of attribute original_results.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(results = {}) ⇒ TestResults
constructor
A new instance of TestResults.
- #new? ⇒ Boolean
- #passed? ⇒ Boolean (also: #is_passed)
- #to_s(advanced = false) ⇒ Object
Constructor Details
#initialize(results = {}) ⇒ TestResults
Returns a new instance of TestResults.
8 9 10 11 12 13 14 15 16 |
# File 'lib/applitools/core/test_results.rb', line 8 def initialize(results = {}) @steps = results.fetch('steps', 0) @matches = results.fetch('matches', 0) @mismatches = results.fetch('mismatches', 0) @missing = results.fetch('missing', 0) @is_new = nil @url = nil @original_results = results end |
Instance Attribute Details
#is_new ⇒ Object
Returns the value of attribute is_new.
5 6 7 |
# File 'lib/applitools/core/test_results.rb', line 5 def is_new @is_new end |
#matches ⇒ Object (readonly)
Returns the value of attribute matches.
6 7 8 |
# File 'lib/applitools/core/test_results.rb', line 6 def matches @matches end |
#mismatches ⇒ Object (readonly)
Returns the value of attribute mismatches.
6 7 8 |
# File 'lib/applitools/core/test_results.rb', line 6 def mismatches @mismatches end |
#missing ⇒ Object (readonly)
Returns the value of attribute missing.
6 7 8 |
# File 'lib/applitools/core/test_results.rb', line 6 def missing @missing end |
#original_results ⇒ Object (readonly)
Returns the value of attribute original_results.
6 7 8 |
# File 'lib/applitools/core/test_results.rb', line 6 def original_results @original_results end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
6 7 8 |
# File 'lib/applitools/core/test_results.rb', line 6 def steps @steps end |
#url ⇒ Object
Returns the value of attribute url.
5 6 7 |
# File 'lib/applitools/core/test_results.rb', line 5 def url @url end |
Instance Method Details
#==(other) ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/applitools/core/test_results.rb', line 32 def ==(other) if other.is_a? self.class result = true %w(is_new url steps matches mismatches missing).each do |field| result &&= send(field) == other.send(field) end return result if result end false end |
#failed? ⇒ Boolean
23 24 25 26 |
# File 'lib/applitools/core/test_results.rb', line 23 def failed? return (mismatches > 0) || (missing > 0) unless new? false end |
#new? ⇒ Boolean
28 29 30 |
# File 'lib/applitools/core/test_results.rb', line 28 def new? is_new end |
#passed? ⇒ Boolean Also known as: is_passed
18 19 20 21 |
# File 'lib/applitools/core/test_results.rb', line 18 def passed? return !(mismatches > 0) && !(missing > 0) unless new? false end |
#to_s(advanced = false) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/applitools/core/test_results.rb', line 45 def to_s(advanced = false) is_new_str = '' is_new_str = is_new ? 'New test' : 'Existing test' unless is_new.nil? return @original_results.to_yaml if advanced "#{is_new_str} [ steps: #{steps}, matches: #{matches}, mismatches: #{mismatches}, missing: #{missing} ], " \ "URL: #{url}" end |