Class: Example
- Inherits:
-
Object
- Object
- Example
- Defined in:
- lib/example.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#file_path ⇒ Object
readonly
Returns the value of attribute file_path.
-
#full_description ⇒ Object
readonly
Returns the value of attribute full_description.
-
#metadata ⇒ Object
readonly
Returns the value of attribute metadata.
-
#run_time ⇒ Object
readonly
Returns the value of attribute run_time.
-
#screenshot ⇒ Object
readonly
Returns the value of attribute screenshot.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #has_exception? ⇒ Boolean
- #has_spec? ⇒ Boolean
-
#initialize(example) ⇒ Example
constructor
A new instance of Example.
- #klass(prefix = 'label-') ⇒ Object
- #set_spec(spec) ⇒ Object
Constructor Details
#initialize(example) ⇒ Example
Returns a new instance of Example.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/example.rb', line 9 def initialize(example) @description = example.description @full_description = example.full_description @execution_result = example.execution_result @run_time = (@execution_result.run_time).round(5) @duration = @execution_result.run_time.to_s(:rounded, precision: 5) @status = @execution_result.status.to_s @metadata = example. @file_path = @metadata[:file_path] @exception = Oopsy.new(example.exception, @file_path) filename = File.basename(@metadata[:file_path]) line_number = @metadata[:line_number] @screenshot = "#{filename}-#{line_number}.png" @spec = nil end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
6 7 8 |
# File 'lib/example.rb', line 6 def description @description end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
6 7 8 |
# File 'lib/example.rb', line 6 def duration @duration end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
6 7 8 |
# File 'lib/example.rb', line 6 def exception @exception end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
6 7 8 |
# File 'lib/example.rb', line 6 def file_path @file_path end |
#full_description ⇒ Object (readonly)
Returns the value of attribute full_description.
6 7 8 |
# File 'lib/example.rb', line 6 def full_description @full_description end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
6 7 8 |
# File 'lib/example.rb', line 6 def @metadata end |
#run_time ⇒ Object (readonly)
Returns the value of attribute run_time.
6 7 8 |
# File 'lib/example.rb', line 6 def run_time @run_time end |
#screenshot ⇒ Object (readonly)
Returns the value of attribute screenshot.
6 7 8 |
# File 'lib/example.rb', line 6 def screenshot @screenshot end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
6 7 8 |
# File 'lib/example.rb', line 6 def spec @spec end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
6 7 8 |
# File 'lib/example.rb', line 6 def status @status end |
Instance Method Details
#has_exception? ⇒ Boolean
25 26 27 |
# File 'lib/example.rb', line 25 def has_exception? !@exception.klass.nil? end |
#has_spec? ⇒ Boolean
29 30 31 |
# File 'lib/example.rb', line 29 def has_spec? !@spec.nil? end |
#klass(prefix = 'label-') ⇒ Object
37 38 39 40 |
# File 'lib/example.rb', line 37 def klass(prefix='label-') class_map = {passed: "#{prefix}success", failed: "#{prefix}danger", pending: "#{prefix}warning"} class_map[@status.to_sym] end |
#set_spec(spec) ⇒ Object
33 34 35 |
# File 'lib/example.rb', line 33 def set_spec(spec) @spec = spec end |