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 228 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 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?()
click to toggle source
# File lib/cucumber/formatter/json.rb, line 234 def background? @background_hash != nil end
examples_table(examples_table)
click to toggle source
# 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 = 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 312 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 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.tags.empty? @feature_hash[:tags] = create_tags_array(feature.tags) @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)
click to toggle source
# 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] = 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 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' } 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 319 def create_id(element) element.to_s.downcase.tr(' ', '-') end