lib/cucumber/formatter/usage.rb in kosmas58-cucumber-0.2.2.1 vs lib/cucumber/formatter/usage.rb in kosmas58-cucumber-0.2.3.3
- old
+ new
@@ -8,10 +8,11 @@
def initialize(step_mother, io, options)
super(step_mother)
@io = io
@options = options
@step_definitions = Hash.new { |h,step_definition| h[step_definition] = [] }
+ @all_step_definitions = step_mother.step_definitions.dup
@locations = []
end
def visit_features(features)
super
@@ -30,10 +31,11 @@
@locations << location
description = format_step(keyword, step_match, status, nil)
length = (keyword + step_match.format_args).jlength
@step_definitions[step_match.step_definition] << [step_match, description, length, location]
+ @all_step_definitions.delete(step_match.step_definition)
end
end
def print_summary
sorted_defs = @step_definitions.keys.sort_by{|step_definition| step_definition.backtrace_line}
@@ -59,9 +61,23 @@
description = step_match_and_description[1]
length = step_match_and_description[2]
file_colon_line = step_match_and_description[3]
@io.print " #{description}"
@io.puts format_string(" # #{file_colon_line}".indent(max_length - length), :comment)
+ end
+ end
+
+ print_unused_step_definitions
+ end
+
+ def print_unused_step_definitions
+ if @all_step_definitions.any?
+ max_length = @all_step_definitions.map{|step_definition| step_definition.text_length}.max
+
+ @io.puts format_string("(::) UNUSED (::)", :failed)
+ @all_step_definitions.each do |step_definition|
+ @io.print format_string(step_definition.regexp.inspect, :failed)
+ @io.puts format_string(" # #{step_definition.file_colon_line}".indent(max_length - step_definition.text_length), :comment)
end
end
end
end
end