lib/cucumber/formatter/json.rb in cucumber-3.0.0.pre.1 vs lib/cucumber/formatter/json.rb in cucumber-3.0.0.pre.2
- old
+ new
@@ -64,16 +64,16 @@
add_match_and_result(test_step, result)
@any_step_failed = true if result.failed?
end
def on_test_case_finished(event)
- test_case, result = *event.attributes
+ _test_case, result = *event.attributes
result = result.with_filtered_backtrace(Cucumber::Formatter::BacktraceFilter)
add_failed_around_hook(result) if result.failed? && !@any_step_failed
end
- def on_test_run_finished(event)
+ def on_test_run_finished(_event)
@io.write(MultiJson.dump(@feature_hashes, pretty: true))
end
def puts(message)
test_step_output << message
@@ -168,11 +168,11 @@
step_hash[:rows] = create_data_table_value(step_source.multiline_arg) if step_source.multiline_arg.data_table?
step_hash
end
def create_doc_string_hash(doc_string)
- content_type = doc_string.content_type ? doc_string.content_type : ""
+ content_type = doc_string.content_type ? doc_string.content_type : ''
{
value: doc_string.content,
content_type: content_type,
line: doc_string.location.line
}
@@ -190,16 +190,16 @@
end
def add_failed_around_hook(result)
@step_or_hook_hash = {}
around_hooks << @step_or_hook_hash
- @step_or_hook_hash[:match] = { location: "unknown_hook_location:1" }
+ @step_or_hook_hash[:match] = { location: 'unknown_hook_location:1' }
@step_or_hook_hash[:result] = create_result_hash(result)
end
- def create_match_hash(test_step, result)
+ def create_match_hash(test_step, _result)
{ location: test_step.action_location.to_s }
end
def create_result_hash(result)
result_hash = {
@@ -216,11 +216,11 @@
([message] + message_element.backtrace).join("\n")
end
def encode64(data)
# strip newlines from the encoded data
- Base64.encode64(data).gsub(/\n/, '')
+ Base64.encode64(data).delete("\n")
end
class Builder
attr_reader :feature_hash, :background_hash, :test_case_hash
@@ -243,15 +243,15 @@
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
+ @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
@@ -314,10 +314,10 @@
end
private
def create_id(element)
- element.name.downcase.gsub(/ /, '-')
+ element.name.downcase.tr(' ', '-')
end
def create_tags_array(tags)
tags_array = []
tags.each { |tag| tags_array << { name: tag.name, line: tag.location.line } }