Class: Sweet::Format::Cucumber::Scenario
- Inherits:
-
Object
- Object
- Sweet::Format::Cucumber::Scenario
- Defined in:
- lib/sweet/format/cucumber/scenario.rb
Instance Attribute Summary collapse
-
#description ⇒ Object
Returns the value of attribute description.
- #duration ⇒ Object
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#keyword ⇒ Object
Returns the value of attribute keyword.
-
#line_number ⇒ Object
Returns the value of attribute line_number.
-
#name ⇒ Object
Returns the value of attribute name.
-
#screenshot ⇒ Object
Returns the value of attribute screenshot.
-
#status ⇒ Object
Returns the value of attribute status.
-
#steps ⇒ Object
Returns the value of attribute steps.
-
#tags ⇒ Object
Returns the value of attribute tags.
Class Method Summary collapse
Instance Method Summary collapse
- #failed? ⇒ Boolean
-
#initialize(opts = {}) ⇒ Scenario
constructor
A new instance of Scenario.
- #is_background? ⇒ Boolean
Constructor Details
#initialize(opts = {}) ⇒ Scenario
Returns a new instance of Scenario.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 36 def initialize(opts = {}) @keyword = opts[:keyword] @name = opts[:name] @description = opts[:description] @line_number = opts[:line_number] @tags = opts[:tags] || [] @file_path = opts[:file_path] @steps = opts[:steps] || [] @steps.map! do |step| if step.is_a? Hash Step.new step else step end end @screenshot = opts[:screenshot] determine_status end |
Instance Attribute Details
#description ⇒ Object
Returns the value of attribute description.
32 33 34 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 32 def description @description end |
#duration ⇒ Object
66 67 68 69 70 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 66 def duration @steps.inject(0.0) do |sum, step| sum += step.duration || 0.0 end end |
#file_path ⇒ Object
Returns the value of attribute file_path.
32 33 34 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 32 def file_path @file_path end |
#keyword ⇒ Object
Returns the value of attribute keyword.
32 33 34 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 32 def keyword @keyword end |
#line_number ⇒ Object
Returns the value of attribute line_number.
32 33 34 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 32 def line_number @line_number end |
#name ⇒ Object
Returns the value of attribute name.
32 33 34 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 32 def name @name end |
#screenshot ⇒ Object
Returns the value of attribute screenshot.
32 33 34 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 32 def screenshot @screenshot end |
#status ⇒ Object
Returns the value of attribute status.
32 33 34 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 32 def status @status end |
#steps ⇒ Object
Returns the value of attribute steps.
32 33 34 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 32 def steps @steps end |
#tags ⇒ Object
Returns the value of attribute tags.
32 33 34 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 32 def @tags end |
Class Method Details
.from_output(data) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 8 def from_output(data) data = JSON.parse(data, symbolize_names: true) if data.is_a? String = if data[:tags] data[:tags].map do |tag| tag[:name] end end if data[:steps] steps = data[:steps].map { |step| Step.from_output step } end new keyword: data[:keyword], name: data[:name], description: data[:description], line_number: data[:line], tags: , file_path: data[:file_path], steps: steps, screenshot: data[:screenshot] end |
Instance Method Details
#failed? ⇒ Boolean
62 63 64 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 62 def failed? @status == :failed end |
#is_background? ⇒ Boolean
58 59 60 |
# File 'lib/sweet/format/cucumber/scenario.rb', line 58 def is_background? @keyword == 'Background' end |