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.
-
#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, report_folder) ⇒ Example
constructor
A new instance of Example.
- #klass(prefix = 'label-') ⇒ Object
- #screenshot ⇒ Object
- #set_spec(spec) ⇒ Object
Constructor Details
#initialize(example, report_folder) ⇒ Example
Returns a new instance of Example.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/example.rb', line 10 def initialize(example, report_folder) @description = example.description @full_description = example.full_description @execution_result = example.execution_result @metadata = example. @file_path = @metadata[:file_path] @exception = Oopsy.new(example.exception, @file_path) @spec = nil @report_folder = report_folder end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/example.rb', line 7 def description @description end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
7 8 9 |
# File 'lib/example.rb', line 7 def duration @duration end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
7 8 9 |
# File 'lib/example.rb', line 7 def exception @exception end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
7 8 9 |
# File 'lib/example.rb', line 7 def file_path @file_path end |
#full_description ⇒ Object (readonly)
Returns the value of attribute full_description.
7 8 9 |
# File 'lib/example.rb', line 7 def full_description @full_description end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
7 8 9 |
# File 'lib/example.rb', line 7 def @metadata end |
#run_time ⇒ Object (readonly)
Returns the value of attribute run_time.
7 8 9 |
# File 'lib/example.rb', line 7 def run_time @run_time end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
7 8 9 |
# File 'lib/example.rb', line 7 def spec @spec end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
7 8 9 |
# File 'lib/example.rb', line 7 def status @status end |
Instance Method Details
#has_exception? ⇒ Boolean
21 22 23 |
# File 'lib/example.rb', line 21 def has_exception? !@exception.klass.nil? end |
#has_spec? ⇒ Boolean
25 26 27 |
# File 'lib/example.rb', line 25 def has_spec? !@spec.nil? end |
#klass(prefix = 'label-') ⇒ Object
33 34 35 36 |
# File 'lib/example.rb', line 33 def klass(prefix = 'label-') class_map = { passed: "#{prefix}success", failed: "#{prefix}danger", pending: "#{prefix}warning" } class_map[status.to_sym] end |
#screenshot ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/example.rb', line 38 def screenshot return nil unless @metadata[:screenshot] unless File.exist?(@metadata[:screenshot]) puts "The screenshot '#{@metadata[:screenshot]}' does not exist" end report_dir = Pathname.new(File.(File.dirname(@report_folder))) screenshot = Pathname.new(File.(@metadata[:screenshot])) screenshot.relative_path_from(report_dir).to_s end |
#set_spec(spec) ⇒ Object
29 30 31 |
# File 'lib/example.rb', line 29 def set_spec(spec) @spec = spec end |