lib/mutant/warning_expectation.rb in mutant-0.5.24 vs lib/mutant/warning_expectation.rb in mutant-0.5.25

- old
+ new

@@ -3,20 +3,20 @@ class WarningExpectation include Adamantium::Flat, Concord.new(:expected) # Error raised on expectation miss class ExpectationError < RuntimeError - include Concord.new(:unexpected, :missing) + include Concord.new(:unexpected) # Return exception message # # @return [String] # # @api private # def message - "Unexpected warnings: #{unexpected.inspect} missing warnigns: #{missing.inspect}" + "Unexpected warnings: #{unexpected.inspect}" end end # Execute blocks with warning expectations # @@ -26,14 +26,21 @@ # def execute(&block) warnings = WarningFilter.use do block.call end - missing = expected - warnings + + missing = expected - warnings unexpected = warnings - expected - if missing.any? or unexpected.any? - fail ExpectationError.new(unexpected, missing) + + if unexpected.any? + fail ExpectationError, unexpected end + + if missing.any? + $stderr.puts("Expected but missing warnings: #{missing}") + end + self end end # WarningExpectation end # Mutant