lib/cucumber/formatter/json.rb in cucumber-3.0.0.pre.2 vs lib/cucumber/formatter/json.rb in cucumber-3.0.0
- old
+ new
@@ -12,18 +12,19 @@
include Io
def initialize(config)
@io = ensure_io(config.out_stream)
@feature_hashes = []
- config.on_event :test_case_starting, &method(:on_test_case_starting)
+ @step_or_hook_hash = {}
+ config.on_event :test_case_started, &method(:on_test_case_started)
config.on_event :test_case_finished, &method(:on_test_case_finished)
- config.on_event :test_step_starting, &method(:on_test_step_starting)
+ config.on_event :test_step_started, &method(:on_test_step_started)
config.on_event :test_step_finished, &method(:on_test_step_finished)
config.on_event :test_run_finished, &method(:on_test_run_finished)
end
- def on_test_case_starting(event)
+ def on_test_case_started(event)
test_case = event.test_case
builder = Builder.new(test_case)
unless same_feature_as_previous_test_case?(test_case.feature)
@feature_hash = builder.feature_hash
@feature_hashes << @feature_hash
@@ -37,11 +38,11 @@
@element_hash = @test_case_hash
end
@any_step_failed = false
end
- def on_test_step_starting(event)
+ def on_test_step_started(event)
test_step = event.test_step
return if internal_hook?(test_step)
hook_query = HookQueryVisitor.new(test_step)
if hook_query.hook?
@step_or_hook_hash = {}
@@ -99,11 +100,11 @@
def same_feature_as_previous_test_case?(feature)
current_feature[:uri] == feature.file && current_feature[:line] == feature.location.line
end
def first_step_after_background?(test_step)
- test_step.source[1].name != @element_hash[:name]
+ test_step.source[1].to_s != @element_hash[:name]
end
def internal_hook?(test_step)
test_step.source.last.location.file.include?('lib/cucumber/')
end
@@ -127,11 +128,11 @@
when :after
return after_hooks
when :after_step
return after_step_hooks
else
- fail 'Unkown hook type ' + hook_query.type.to_s
+ fail 'Unknown hook type ' + hook_query.type.to_s
end
end
def before_hooks
@element_hash[:before] ||= []
@@ -158,11 +159,11 @@
end
def create_step_hash(step_source)
step_hash = {
keyword: step_source.keyword,
- name: step_source.name,
+ name: step_source.to_s,
line: step_source.location.line
}
step_hash[:comments] = Formatter.create_comments_array(step_source.comments) unless step_source.comments.empty?
step_hash[:doc_string] = create_doc_string_hash(step_source.multiline_arg) if step_source.multiline_arg.doc_string?
step_hash[:rows] = create_data_table_value(step_source.multiline_arg) if step_source.multiline_arg.data_table?
@@ -237,11 +238,11 @@
def feature(feature)
@feature_hash = {
uri: feature.file,
id: create_id(feature),
keyword: feature.keyword,
- name: feature.name,
+ name: feature.to_s,
description: feature.description,
line: feature.location.line
}
unless feature.tags.empty?
@feature_hash[:tags] = create_tags_array(feature.tags)
@@ -256,11 +257,11 @@
end
def background(background)
@background_hash = {
keyword: background.keyword,
- name: background.name,
+ 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?
@@ -268,11 +269,11 @@
def scenario(scenario)
@test_case_hash = {
id: create_id(scenario),
keyword: scenario.keyword,
- name: scenario.name,
+ 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?
@@ -281,11 +282,11 @@
def scenario_outline(scenario)
@test_case_hash = {
id: create_id(scenario) + ';' + @example_id,
keyword: scenario.keyword,
- name: scenario.name,
+ name: scenario.to_s,
description: scenario.description,
line: @row.location.line,
type: 'scenario'
}
tags = []
@@ -314,10 +315,10 @@
end
private
def create_id(element)
- element.name.downcase.tr(' ', '-')
+ element.to_s.downcase.tr(' ', '-')
end
def create_tags_array(tags)
tags_array = []
tags.each { |tag| tags_array << { name: tag.name, line: tag.location.line } }