Class: Sweet::Format::RSpec::Example
- Inherits:
-
Object
- Object
- Sweet::Format::RSpec::Example
- Defined in:
- lib/sweet/format/rspec/example.rb
Instance Attribute Summary collapse
-
#backtrace ⇒ Object
Returns the value of attribute backtrace.
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#line_number ⇒ Object
Returns the value of attribute line_number.
-
#message ⇒ Object
Returns the value of attribute message.
-
#name ⇒ Object
Returns the value of attribute name.
-
#screenshot ⇒ Object
Returns the value of attribute screenshot.
-
#status ⇒ Object
Returns the value of attribute status.
Class Method Summary collapse
Instance Method Summary collapse
- #duration ⇒ Object
-
#initialize(opts = {}) ⇒ Example
constructor
A new instance of Example.
Constructor Details
#initialize(opts = {}) ⇒ Example
Returns a new instance of Example.
33 34 35 36 37 38 39 40 41 |
# File 'lib/sweet/format/rspec/example.rb', line 33 def initialize(opts = {}) @name = opts[:name] @status = opts[:status].to_sym if opts[:status] @file_path = sanitize_file_path(opts[:file_path]) @line_number = opts[:line_number] @duration = opts[:duration] @message = opts[:message] @screenshot = opts[:screenshot] end |
Instance Attribute Details
#backtrace ⇒ Object
Returns the value of attribute backtrace.
30 31 32 |
# File 'lib/sweet/format/rspec/example.rb', line 30 def backtrace @backtrace end |
#file_path ⇒ Object
Returns the value of attribute file_path.
30 31 32 |
# File 'lib/sweet/format/rspec/example.rb', line 30 def file_path @file_path end |
#line_number ⇒ Object
Returns the value of attribute line_number.
30 31 32 |
# File 'lib/sweet/format/rspec/example.rb', line 30 def line_number @line_number end |
#message ⇒ Object
Returns the value of attribute message.
30 31 32 |
# File 'lib/sweet/format/rspec/example.rb', line 30 def @message end |
#name ⇒ Object
Returns the value of attribute name.
30 31 32 |
# File 'lib/sweet/format/rspec/example.rb', line 30 def name @name end |
#screenshot ⇒ Object
Returns the value of attribute screenshot.
30 31 32 |
# File 'lib/sweet/format/rspec/example.rb', line 30 def screenshot @screenshot end |
#status ⇒ Object
Returns the value of attribute status.
30 31 32 |
# File 'lib/sweet/format/rspec/example.rb', line 30 def status @status end |
Class Method Details
.from_output(data) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/sweet/format/rspec/example.rb', line 6 def from_output(data) data = JSON.parse(data, symbolize_names: true) if data.is_a? String case data[:status] when 'pending' = data[:pending_message] when 'failed' e = data[:exception] = "#{e[:class]}\n#{e[:message]}" end backtrace = data[:exception][:backtrace] if data[:exception] new name: data[:full_description], status: data[:status], file_path: data[:file_path], line_number: data[:line_number], duration: data[:run_time], message: , backtrace: backtrace, screenshot: data[:screenshot] end |
Instance Method Details
#duration ⇒ Object
43 44 45 |
# File 'lib/sweet/format/rspec/example.rb', line 43 def duration @duration * 1_000_000_000 end |