Class: Example
- Inherits:
-
Object
- Object
- Example
- Defined in:
- lib/rspec_pretty_report.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) ⇒ 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.
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/rspec_pretty_report.rb', line 85 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) @spec = nil end |
Instance Attribute Details
#description ⇒ Object (readonly)
Returns the value of attribute description.
83 84 85 |
# File 'lib/rspec_pretty_report.rb', line 83 def description @description end |
#duration ⇒ Object (readonly)
Returns the value of attribute duration.
83 84 85 |
# File 'lib/rspec_pretty_report.rb', line 83 def duration @duration end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
83 84 85 |
# File 'lib/rspec_pretty_report.rb', line 83 def exception @exception end |
#file_path ⇒ Object (readonly)
Returns the value of attribute file_path.
83 84 85 |
# File 'lib/rspec_pretty_report.rb', line 83 def file_path @file_path end |
#full_description ⇒ Object (readonly)
Returns the value of attribute full_description.
83 84 85 |
# File 'lib/rspec_pretty_report.rb', line 83 def full_description @full_description end |
#metadata ⇒ Object (readonly)
Returns the value of attribute metadata.
83 84 85 |
# File 'lib/rspec_pretty_report.rb', line 83 def @metadata end |
#run_time ⇒ Object (readonly)
Returns the value of attribute run_time.
83 84 85 |
# File 'lib/rspec_pretty_report.rb', line 83 def run_time @run_time end |
#spec ⇒ Object (readonly)
Returns the value of attribute spec.
83 84 85 |
# File 'lib/rspec_pretty_report.rb', line 83 def spec @spec end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
83 84 85 |
# File 'lib/rspec_pretty_report.rb', line 83 def status @status end |
Instance Method Details
#has_exception? ⇒ Boolean
98 99 100 |
# File 'lib/rspec_pretty_report.rb', line 98 def has_exception? !@exception.klass.nil? end |
#has_spec? ⇒ Boolean
102 103 104 |
# File 'lib/rspec_pretty_report.rb', line 102 def has_spec? !@spec.nil? end |
#klass(prefix = 'label-') ⇒ Object
110 111 112 113 |
# File 'lib/rspec_pretty_report.rb', line 110 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
106 107 108 |
# File 'lib/rspec_pretty_report.rb', line 106 def set_spec(spec) @spec = spec end |