Class: Sweet::Format::Cucumber::Feature
- Inherits:
-
Object
- Object
- Sweet::Format::Cucumber::Feature
- Defined in:
- lib/sweet/format/cucumber/feature.rb
Instance Attribute Summary collapse
-
#backgrounds ⇒ Object
Returns the value of attribute backgrounds.
-
#description ⇒ Object
Returns the value of attribute description.
-
#failed ⇒ Object
Returns the value of attribute failed.
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#keyword ⇒ Object
Returns the value of attribute keyword.
-
#name ⇒ Object
Returns the value of attribute name.
-
#passed ⇒ Object
Returns the value of attribute passed.
-
#pending ⇒ Object
Returns the value of attribute pending.
-
#scenarios ⇒ Object
Returns the value of attribute scenarios.
-
#skipped ⇒ Object
Returns the value of attribute skipped.
-
#tags ⇒ Object
Returns the value of attribute tags.
Class Method Summary collapse
Instance Method Summary collapse
- #duration ⇒ Object
-
#initialize(opts = {}) ⇒ Feature
constructor
A new instance of Feature.
- #total_failed ⇒ Object
- #total_passed ⇒ Object
- #total_pending ⇒ Object
- #total_skipped ⇒ Object
- #total_tests ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Feature
Returns a new instance of Feature.
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/sweet/format/cucumber/feature.rb', line 43 def initialize(opts = {}) @file_path = opts[:file_path] @keyword = opts[:keyword] @name = opts[:name] @description = opts[:description] @tags = opts[:tags] || [] @passed = [] @failed = [] @pending = [] @skipped = [] @backgrounds = opts[:backgrounds] || [] @scenarios = opts[:scenarios] || [] [@backgrounds, @scenarios].each do |scenarios| scenarios.map! do |scenario| if scenario.is_a? Hash Scenario.new scenario else scenario end scenario.file_path = @file_path scenario end end organize_scenarios end |
Instance Attribute Details
#backgrounds ⇒ Object
Returns the value of attribute backgrounds.
39 40 41 |
# File 'lib/sweet/format/cucumber/feature.rb', line 39 def backgrounds @backgrounds end |
#description ⇒ Object
Returns the value of attribute description.
39 40 41 |
# File 'lib/sweet/format/cucumber/feature.rb', line 39 def description @description end |
#failed ⇒ Object
Returns the value of attribute failed.
41 42 43 |
# File 'lib/sweet/format/cucumber/feature.rb', line 41 def failed @failed end |
#file_path ⇒ Object
Returns the value of attribute file_path.
39 40 41 |
# File 'lib/sweet/format/cucumber/feature.rb', line 39 def file_path @file_path end |
#keyword ⇒ Object
Returns the value of attribute keyword.
39 40 41 |
# File 'lib/sweet/format/cucumber/feature.rb', line 39 def keyword @keyword end |
#name ⇒ Object
Returns the value of attribute name.
39 40 41 |
# File 'lib/sweet/format/cucumber/feature.rb', line 39 def name @name end |
#passed ⇒ Object
Returns the value of attribute passed.
41 42 43 |
# File 'lib/sweet/format/cucumber/feature.rb', line 41 def passed @passed end |
#pending ⇒ Object
Returns the value of attribute pending.
41 42 43 |
# File 'lib/sweet/format/cucumber/feature.rb', line 41 def pending @pending end |
#scenarios ⇒ Object
Returns the value of attribute scenarios.
39 40 41 |
# File 'lib/sweet/format/cucumber/feature.rb', line 39 def scenarios @scenarios end |
#skipped ⇒ Object
Returns the value of attribute skipped.
41 42 43 |
# File 'lib/sweet/format/cucumber/feature.rb', line 41 def skipped @skipped end |
#tags ⇒ Object
Returns the value of attribute tags.
39 40 41 |
# File 'lib/sweet/format/cucumber/feature.rb', line 39 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 30 31 32 33 34 35 36 |
# File 'lib/sweet/format/cucumber/feature.rb', line 8 def from_output(data) data = JSON.parse(data, symbolize_names: true) if data.is_a? String backgrounds = [] scenarios = [] data[:elements].each do |element| scenario = Scenario.from_output element scenario.file_path = data[:uri] if scenario.is_background? unless backgrounds.any? do |bg| bg.line_number == scenario.line_number end backgrounds << scenario end else scenarios << scenario end end = (data[:tags].map { |tag| tag[:name] } if data[:tags]) new file_path: data[:uri], keyword: data[:keyword], name: data[:name], description: data[:description], tags: , backgrounds: backgrounds, scenarios: scenarios end |
Instance Method Details
#duration ⇒ Object
74 75 76 77 78 |
# File 'lib/sweet/format/cucumber/feature.rb', line 74 def duration [@scenarios, @backgrounds].flatten.inject(0.0) do |sum, scenario| sum += scenario.duration end end |
#total_failed ⇒ Object
88 89 90 |
# File 'lib/sweet/format/cucumber/feature.rb', line 88 def total_failed @failed.count end |
#total_passed ⇒ Object
84 85 86 |
# File 'lib/sweet/format/cucumber/feature.rb', line 84 def total_passed @passed.count end |
#total_pending ⇒ Object
92 93 94 |
# File 'lib/sweet/format/cucumber/feature.rb', line 92 def total_pending @pending.count end |
#total_skipped ⇒ Object
96 97 98 |
# File 'lib/sweet/format/cucumber/feature.rb', line 96 def total_skipped @skipped.count end |
#total_tests ⇒ Object
80 81 82 |
# File 'lib/sweet/format/cucumber/feature.rb', line 80 def total_tests @scenarios.count end |