Class: 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.
225 226 227 228 229 |
# File 'lib/cucumber/formatter/json.rb', line 225 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.
223 224 225 |
# File 'lib/cucumber/formatter/json.rb', line 223 def background_hash @background_hash end |
#feature_hash ⇒ Object (readonly)
Returns the value of attribute feature_hash.
223 224 225 |
# File 'lib/cucumber/formatter/json.rb', line 223 def feature_hash @feature_hash end |
#test_case_hash ⇒ Object (readonly)
Returns the value of attribute test_case_hash.
223 224 225 |
# File 'lib/cucumber/formatter/json.rb', line 223 def test_case_hash @test_case_hash end |
Instance Method Details
#background(background) ⇒ Object
256 257 258 259 260 261 262 263 264 265 |
# File 'lib/cucumber/formatter/json.rb', line 256 def background(background) @background_hash = { keyword: background.keyword, name: background.name, 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
231 232 233 |
# File 'lib/cucumber/formatter/json.rb', line 231 def background? @background_hash != nil end |
#examples_table(examples_table) ⇒ Object
300 301 302 303 304 305 306 307 |
# File 'lib/cucumber/formatter/json.rb', line 300 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
309 310 311 312 |
# File 'lib/cucumber/formatter/json.rb', line 309 def examples_table_row(row) @row = row @row_comments = Formatter.create_comments_array(row.comments) unless row.comments.empty? end |
#feature(feature) ⇒ Object
235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 |
# File 'lib/cucumber/formatter/json.rb', line 235 def feature(feature) @feature_hash = { uri: feature.file, id: create_id(feature), keyword: feature.keyword, name: feature.name, description: feature.description, line: feature.location.line } unless feature..empty? @feature_hash[:tags] = (feature.) if @test_case_hash[:tags] @test_case_hash[:tags] = @feature_hash[:tags] + @test_case_hash[:tags] else @test_case_hash[:tags] = @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
267 268 269 270 271 272 273 274 275 276 277 278 |
# File 'lib/cucumber/formatter/json.rb', line 267 def scenario(scenario) @test_case_hash = { id: create_id(scenario), keyword: scenario.keyword, name: scenario.name, 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
280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 |
# File 'lib/cucumber/formatter/json.rb', line 280 def scenario_outline(scenario) @test_case_hash = { id: create_id(scenario) + ';' + @example_id, keyword: scenario.keyword, name: scenario.name, 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 |