lib/cucumber/formatter/console.rb in aslakhellesoy-cucumber-0.3.93.1 vs lib/cucumber/formatter/console.rb in aslakhellesoy-cucumber-0.3.94

- old
+ new

@@ -4,11 +4,11 @@ module Cucumber module Formatter module Console extend ANSIColor include Duration - + FORMATS = Hash.new{|hash, format| hash[format] = method(format).to_proc} def format_step(keyword, step_match, status, source_indent) comment = if source_indent c = (' # ' + step_match.file_colon_line).indent(source_indent) @@ -57,33 +57,33 @@ STDERR.puts("The #print_counts method is deprecated and will be removed in 0.4. Use #print_stats instead") print_stats(nil) end def print_stats(features) - + @failures = step_mother.scenarios(:failed).select { |s| s.is_a?(Cucumber::Ast::Scenario) } - + if !@failures.empty? @io.puts format_string("Failing Scenarios:", :failed) @failures.each do |failure| @io.puts format_string("cucumber " + failure.file_colon_line, :failed) + format_string(" # Scenario: " + failure.name, :comment) end @io.puts end - + @io.print dump_count(step_mother.scenarios.length, "scenario") print_status_counts{|status| step_mother.scenarios(status)} @io.print dump_count(step_mother.steps.length, "step") print_status_counts{|status| step_mother.steps(status)} @io.puts(format_duration(features.duration)) if features && features.duration @io.flush end - + def print_exception(e, status, indent) @io.puts(format_string("#{e.message} (#{e.class})\n#{e.backtrace.join("\n")}".indent(indent), status)) end def print_snippets(options) @@ -112,10 +112,33 @@ @io.puts "\nThe --wip switch was used, so I didn't expect anything to pass. These scenarios passed:" print_elements(passed, :passed, "scenarios") end end + def print_tag_limit_warnings(options) + return unless tag_limit_breached?(options, @tag_occurences) + @io.puts + @io.puts format_string("Failed due to exceeding the tag limit", :failed) + options[:include_tags].each do |tag_name, limit| + tag_frequnecy = @tag_occurences[tag_name].size + if limit && tag_frequnecy > limit + @io.puts format_string("@#{tag_name} occurred:#{tag_frequnecy} limit:#{limit}", :failed) + @tag_occurences[tag_name].each {|location| @io.puts format_string(" #{location}", :failed)} + @io.flush + end + end + end + + def record_tag_occurrences(feature_element, options) + @tag_occurences ||= Hash.new{|k,v| k[v] = []} + options[:include_tags].each do |tag_name, limit| + if feature_element.tag_count(tag_name) > 0 + @tag_occurences[tag_name] << feature_element.file_colon_line + end + end + end + def announce(announcement) @io.puts @io.puts(format_string(announcement, :tag)) @io.flush end @@ -142,8 +165,17 @@ key = keys.join('_').to_sym fmt = FORMATS[key] raise "No format for #{key.inspect}: #{FORMATS.inspect}" if fmt.nil? fmt end + + def tag_limit_breached?(options, tag_occurences) + return if tag_occurences.nil? + tag_limit_breached = false + options[:include_tags].each do |tag_name, limit| + tag_limit_breached ||= limit && (tag_occurences[tag_name].size > limit) + end + tag_limit_breached + end end end -end \ No newline at end of file +end