lib/goodcheck/commands/test.rb in goodcheck-2.6.1 vs lib/goodcheck/commands/test.rb in goodcheck-2.7.0
- old
+ new
@@ -49,11 +49,12 @@
if duplicated_ids.empty?
stdout.puts " OK!👍"
true
else
count = duplicated_ids.size
- stdout.puts(Rainbow(" Found #{count} #{'duplication'.pluralize(count)}.😞").red)
+ duplication = count == 1 ? 'duplication' : 'duplications'
+ stdout.puts(Rainbow(" Found #{count} #{duplication}.😞").red)
duplicated_ids.each do |id|
stdout.puts " #{id}"
end
false
end
@@ -74,11 +75,11 @@
rule.triggers.each.with_index do |trigger, index|
if !trigger.passes.empty? || !trigger.fails.empty?
if trigger.by_pattern?
stdout.puts " Testing pattern..."
else
- stdout.puts " Testing #{(index+1).ordinalize} trigger..."
+ stdout.puts " #{index + 1}. Testing trigger..."
end
pass_errors = trigger.passes.each.with_index.select do |pass, _|
rule_matches_example?(rule, trigger, pass)
end
@@ -90,21 +91,21 @@
unless pass_errors.empty?
test_pass = false
rule_ok = false
pass_errors.each do |_, index|
- stdout.puts " #{(index+1).ordinalize} #{Rainbow('pass').green} example matched.😱"
+ stdout.puts " #{index + 1}. #{Rainbow('pass').green} example matched.😱"
failed_rule_ids << rule.id
end
end
unless fail_errors.empty?
test_pass = false
rule_ok = false
fail_errors.each do |_, index|
- stdout.puts " #{(index+1).ordinalize} #{Rainbow('fail').red} example didn't match.😱"
+ stdout.puts " #{index + 1}. #{Rainbow('fail').red} example didn't match.😱"
failed_rule_ids << rule.id
end
end
end
end
@@ -130,13 +131,14 @@
stdout.puts " - #{Rainbow(rule_id).background(:red)}"
end
end
rule_count = success_count + failure_count
+ rule = rule_count == 1 ? "1 rule" : "#{rule_count} rules"
+ success = Rainbow(success_count == 1 ? "1 success" : "#{success_count} successes").green
+ failure = Rainbow(failure_count == 1 ? "1 failure" : "#{failure_count} failures").red
stdout.puts ""
- stdout.puts ["Tested #{rule_count} #{'rule'.pluralize(rule_count)}",
- Rainbow("#{success_count} #{'success'.pluralize(success_count)}").green,
- Rainbow("#{failure_count} #{'failure'.pluralize(failure_count)}").red].join(", ")
+ stdout.puts "Tested #{rule}, #{success}, #{failure}"
test_pass
end
def rule_matches_example?(rule, trigger, example)