Class: Example

Inherits:
Object
  • Object
show all
Defined in:
lib/rspec_pretty_report.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#descriptionObject (readonly)

Returns the value of attribute description.



83
84
85
# File 'lib/rspec_pretty_report.rb', line 83

def description
  @description
end

#durationObject (readonly)

Returns the value of attribute duration.



83
84
85
# File 'lib/rspec_pretty_report.rb', line 83

def duration
  @duration
end

#exceptionObject (readonly)

Returns the value of attribute exception.



83
84
85
# File 'lib/rspec_pretty_report.rb', line 83

def exception
  @exception
end

#file_pathObject (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_descriptionObject (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

#metadataObject (readonly)

Returns the value of attribute metadata.



83
84
85
# File 'lib/rspec_pretty_report.rb', line 83

def 
  @metadata
end

#run_timeObject (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

#specObject (readonly)

Returns the value of attribute spec.



83
84
85
# File 'lib/rspec_pretty_report.rb', line 83

def spec
  @spec
end

#statusObject (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

Returns:

  • (Boolean)


98
99
100
# File 'lib/rspec_pretty_report.rb', line 98

def has_exception?
  !@exception.klass.nil?
end

#has_spec?Boolean

Returns:

  • (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