class Cucumber::Formatter::Json::Builder
Attributes
background_hash[R]
feature_hash[R]
test_case_hash[R]
Public Class Methods
new(test_case)
click to toggle source
# 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
Public Instance Methods
background(background)
click to toggle source
# 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?()
click to toggle source
# File lib/cucumber/formatter/json.rb, line 231 def background? @background_hash != nil end
examples_table(examples_table)
click to toggle source
# 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 = create_tags_array(examples_table.tags) unless examples_table.tags.empty? @examples_table_comments = Formatter.create_comments_array(examples_table.comments) unless examples_table.comments.empty? end
examples_table_row(row)
click to toggle source
# 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)
click to toggle source
# 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.tags.empty? @feature_hash[:tags] = create_tags_array(feature.tags) 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)
click to toggle source
# 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] = create_tags_array(scenario.tags) unless scenario.tags.empty? @test_case_hash[:comments] = Formatter.create_comments_array(scenario.comments) unless scenario.comments.empty? end
scenario_outline(scenario)
click to toggle source
# 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' } tags = [] tags += create_tags_array(scenario.tags) unless scenario.tags.empty? tags += @examples_table_tags if @examples_table_tags @test_case_hash[:tags] = tags unless tags.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
Private Instance Methods
create_id(element)
click to toggle source
# File lib/cucumber/formatter/json.rb, line 316 def create_id(element) element.name.downcase.gsub(/ /, '-') end