Class: Cucumber::Formatter::Json::Builder
- Inherits:
-
Object
- Object
- Cucumber::Formatter::Json::Builder
- Defined in:
- lib/cucumber/formatter/json.rb
Instance Attribute Summary collapse
-
#background_hash ⇒ Object
readonly
Returns the value of attribute background_hash.
-
#feature_hash ⇒ Object
readonly
Returns the value of attribute feature_hash.
-
#test_case_hash ⇒ Object
readonly
Returns the value of attribute test_case_hash.
Instance Method Summary collapse
- #background(background) ⇒ Object
- #background? ⇒ Boolean
- #examples_table(examples_table) ⇒ Object
- #examples_table_row(row) ⇒ Object
- #feature(feature) ⇒ Object
-
#initialize(test_case) ⇒ Builder
constructor
A new instance of Builder.
- #scenario(scenario) ⇒ Object
- #scenario_outline(scenario) ⇒ Object
Constructor Details
#initialize(test_case) ⇒ Builder
Returns a new instance of Builder.
228 229 230 231 232 |
# File 'lib/cucumber/formatter/json.rb', line 228 def initialize(test_case) @background_hash = nil test_case.describe_source_to(self) test_case.feature.background.describe_to(self) end |
Instance Attribute Details
#background_hash ⇒ Object (readonly)
Returns the value of attribute background_hash.
226 227 228 |
# File 'lib/cucumber/formatter/json.rb', line 226 def background_hash @background_hash end |
#feature_hash ⇒ Object (readonly)
Returns the value of attribute feature_hash.
226 227 228 |
# File 'lib/cucumber/formatter/json.rb', line 226 def feature_hash @feature_hash end |
#test_case_hash ⇒ Object (readonly)
Returns the value of attribute test_case_hash.
226 227 228 |
# File 'lib/cucumber/formatter/json.rb', line 226 def test_case_hash @test_case_hash end |
Instance Method Details
#background(background) ⇒ Object
259 260 261 262 263 264 265 266 267 268 |
# File 'lib/cucumber/formatter/json.rb', line 259 def background(background) @background_hash = { keyword: background.keyword, name: background.to_s, description: background.description, line: background.location.line, type: 'background' } @background_hash[:comments] = Formatter.create_comments_array(background.comments) unless background.comments.empty? end |
#background? ⇒ Boolean
234 235 236 |
# File 'lib/cucumber/formatter/json.rb', line 234 def background? @background_hash != nil end |
#examples_table(examples_table) ⇒ Object
303 304 305 306 307 308 309 310 |
# File 'lib/cucumber/formatter/json.rb', line 303 def examples_table(examples_table) # the json file have traditionally used the header row as row 1, # wheras cucumber-ruby-core used the first example row as row 1. @example_id = create_id(examples_table) + ";#{@row.number + 1}" @examples_table_tags = (examples_table.) unless examples_table..empty? @examples_table_comments = Formatter.create_comments_array(examples_table.comments) unless examples_table.comments.empty? end |
#examples_table_row(row) ⇒ Object
312 313 314 315 |
# File 'lib/cucumber/formatter/json.rb', line 312 def examples_table_row(row) @row = row @row_comments = Formatter.create_comments_array(row.comments) unless row.comments.empty? end |
#feature(feature) ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 |
# File 'lib/cucumber/formatter/json.rb', line 238 def feature(feature) @feature_hash = { uri: feature.file, id: create_id(feature), keyword: feature.keyword, name: feature.to_s, description: feature.description, line: feature.location.line } unless feature..empty? @feature_hash[:tags] = (feature.) @test_case_hash[:tags] = if @test_case_hash[:tags] @feature_hash[:tags] + @test_case_hash[:tags] else @feature_hash[:tags] end end @feature_hash[:comments] = Formatter.create_comments_array(feature.comments) unless feature.comments.empty? @test_case_hash[:id].insert(0, @feature_hash[:id] + ';') end |
#scenario(scenario) ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/cucumber/formatter/json.rb', line 270 def scenario(scenario) @test_case_hash = { id: create_id(scenario), keyword: scenario.keyword, name: scenario.to_s, description: scenario.description, line: scenario.location.line, type: 'scenario' } @test_case_hash[:tags] = (scenario.) unless scenario..empty? @test_case_hash[:comments] = Formatter.create_comments_array(scenario.comments) unless scenario.comments.empty? end |
#scenario_outline(scenario) ⇒ Object
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 |
# File 'lib/cucumber/formatter/json.rb', line 283 def scenario_outline(scenario) @test_case_hash = { id: create_id(scenario) + ';' + @example_id, keyword: scenario.keyword, name: scenario.to_s, description: scenario.description, line: @row.location.line, type: 'scenario' } = [] += (scenario.) unless scenario..empty? += @examples_table_tags if @examples_table_tags @test_case_hash[:tags] = unless .empty? comments = [] comments += Formatter.create_comments_array(scenario.comments) unless scenario.comments.empty? comments += @examples_table_comments if @examples_table_comments comments += @row_comments if @row_comments @test_case_hash[:comments] = comments unless comments.empty? end |