Sha256: 865ddc02207115e9406f46d16466abc2bd192f0ff5f2254de9037b74a0164e4f

Contents?: true

Size: 978 Bytes

Versions: 14

Compression:

Stored size: 978 Bytes

Contents

module Mutant
  # A class to expect some warning message raising on absence of unexpected warnings
  class WarningExpectation
    include Adamantium::Flat, Concord.new(:expected)

    # Error raised on expectation miss
    class ExpectationError < RuntimeError
      include Concord.new(:unexpected, :missing)

      # Return exception message
      #
      # @return [String]
      #
      # @api private
      #
      def message
        "Unexpected warnings: #{unexpected.inspect} missing warnigns: #{missing.inspect}"
      end
    end

    # Execute blocks with warning expectations
    #
    # @return [self]
    #
    # @api private
    #
    def execute(&block)
      warnings = WarningFilter.use do
        block.call
      end
      missing = expected - warnings
      unexpected = warnings - expected
      if missing.any? or unexpected.any?
        fail ExpectationError.new(unexpected, missing)
      end
      self
    end

  end # WarningExpectation
end # Mutant

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
mutant-0.5.24 lib/mutant/warning_expectation.rb
mutant-0.5.23 lib/mutant/warning_expectation.rb
mutant-0.5.22 lib/mutant/warning_expectation.rb
mutant-0.5.21 lib/mutant/warning_expectation.rb
mutant-0.5.20 lib/mutant/warning_expectation.rb
mutant-0.5.19 lib/mutant/warning_expectation.rb
mutant-0.5.18 lib/mutant/warning_expectation.rb
mutant-0.5.17 lib/mutant/warning_expectation.rb
mutant-0.5.16 lib/mutant/warning_expectation.rb
mutant-0.5.15 lib/mutant/warning_expectation.rb
mutant-0.5.14 lib/mutant/warning_expectation.rb
mutant-0.5.13 lib/mutant/warning_expectation.rb
mutant-0.5.12 lib/mutant/warning_expectation.rb
mutant-0.5.11 lib/mutant/warning_expectation.rb