Class: Example
- Inherits:
-
Object
- Object
- Example
- Defined in:
- lib/rspec_html_formatter.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#duration ⇒ Object
readonly
Returns the value of attribute duration.
-
#example_group ⇒ Object
readonly
Returns the value of attribute example_group.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
-
#failed_screenshot ⇒ Object
readonly
Returns the value of attribute failed_screenshot.
-
#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.
-
#screenrecord ⇒ Object
readonly
Returns the value of attribute screenrecord.
-
#screenshots ⇒ Object
readonly
Returns the value of attribute screenshots.
-
#spec ⇒ Object
readonly
Returns the value of attribute spec.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
- #example_title ⇒ Object
- #has_exception? ⇒ Boolean
- #has_failed_screenshot? ⇒ Boolean
- #has_screenrecord? ⇒ Boolean
- #has_screenshots? ⇒ 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.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rspec_html_formatter.rb', line 81 def initialize(example) @example_group = example.example_group.to_s @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) @spec = nil @screenshots = @metadata[:screenshots] @screenrecord = @metadata[:screenrecord] @failed_screenshot = @metadata[:failed_screenshot] end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
79 80 81 |
# File 'lib/rspec_html_formatter.rb', line 79 def description @description end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
79 80 81 |
# File 'lib/rspec_html_formatter.rb', line 79 def duration @duration end |
#example_group ⇒ Object (readonly)
Returns the value of attribute example_group.
79 80 81 |
# File 'lib/rspec_html_formatter.rb', line 79 def example_group @example_group end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
79 80 81 |
# File 'lib/rspec_html_formatter.rb', line 79 def exception @exception end |
#failed_screenshot ⇒ Object (readonly)
Returns the value of attribute failed_screenshot.
79 80 81 |
# File 'lib/rspec_html_formatter.rb', line 79 def failed_screenshot @failed_screenshot end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
79 80 81 |
# File 'lib/rspec_html_formatter.rb', line 79 def file_path @file_path end |
#full_description ⇒ Object (readonly)
Returns the value of attribute full_description.
79 80 81 |
# File 'lib/rspec_html_formatter.rb', line 79 def full_description @full_description end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
79 80 81 |
# File 'lib/rspec_html_formatter.rb', line 79 def @metadata end |
#run_time ⇒ Object (readonly)
Returns the value of attribute run_time.
79 80 81 |
# File 'lib/rspec_html_formatter.rb', line 79 def run_time @run_time end |
#screenrecord ⇒ Object (readonly)
Returns the value of attribute screenrecord.
79 80 81 |
# File 'lib/rspec_html_formatter.rb', line 79 def screenrecord @screenrecord end |
#screenshots ⇒ Object (readonly)
Returns the value of attribute screenshots.
79 80 81 |
# File 'lib/rspec_html_formatter.rb', line 79 def screenshots @screenshots end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
79 80 81 |
# File 'lib/rspec_html_formatter.rb', line 79 def spec @spec end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
79 80 81 |
# File 'lib/rspec_html_formatter.rb', line 79 def status @status end |
Instance Method Details
#example_title ⇒ Object
98 99 100 101 102 103 |
# File 'lib/rspec_html_formatter.rb', line 98 def example_title title_arr = @example_group.to_s.split('::') - ['RSpec', 'ExampleGroups'] title_arr.push @description title_arr.join(' → ') end |
#has_exception? ⇒ Boolean
105 106 107 |
# File 'lib/rspec_html_formatter.rb', line 105 def has_exception? !@exception.klass.nil? end |
#has_failed_screenshot? ⇒ Boolean
121 122 123 |
# File 'lib/rspec_html_formatter.rb', line 121 def has_failed_screenshot? !@failed_screenshot.nil? end |
#has_screenrecord? ⇒ Boolean
117 118 119 |
# File 'lib/rspec_html_formatter.rb', line 117 def has_screenrecord? !@screenrecord.nil? end |
#has_screenshots? ⇒ Boolean
113 114 115 |
# File 'lib/rspec_html_formatter.rb', line 113 def has_screenshots? !@screenshots.nil? && !@screenshots.empty? end |
#has_spec? ⇒ Boolean
109 110 111 |
# File 'lib/rspec_html_formatter.rb', line 109 def has_spec? !@spec.nil? end |
#klass(prefix = 'label-') ⇒ Object
129 130 131 132 |
# File 'lib/rspec_html_formatter.rb', line 129 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
125 126 127 |
# File 'lib/rspec_html_formatter.rb', line 125 def set_spec(spec) @spec = spec end |