Sha256: 6319eed259f55408939c9f3ed9d4c00926e6fd26a1fff0c97daad36fc9662955

Contents?: true

Size: 1.44 KB

Versions: 23

Compression:

Stored size: 1.44 KB

Contents

require 'mocha/backtrace_filter'
require 'mocha/expectation_error'

module Mocha

  # This factory determines what class of exception should be raised when Mocha detects a test failure.
  #
  # This class should only be used by authors of test libraries and not by typical "users" of Mocha.
  #
  # For example, it is used by +Mocha::Integration::MiniTest::Adapter+ in order to have Mocha raise a +MiniTest::Assertion+ which can then be sensibly handled by +MiniTest::Unit::TestCase+.
  #
  # @see Mocha::Integration::MiniTest::Adapter
  class ExpectationErrorFactory
    class << self
      # @!attribute exception_class
      #   Determines what class of exception should be raised when Mocha detects a test failure.
      #
      #   This attribute may be set by authors of test libraries in order to have Mocha raise exceptions of a specific class when there is an unexpected invocation or an unsatisfied expectation.
      #
      #   By default a +Mocha::ExpectationError+ will be raised.
      #
      #   @return [Exception] class of exception to be raised when an expectation error occurs
      #   @see Mocha::ExpectationError
      attr_accessor :exception_class

      # @private
      def build(message = nil, backtrace = [])
        exception = exception_class.new(message)
        filter = BacktraceFilter.new
        exception.set_backtrace(filter.filtered(backtrace))
        exception
      end
    end
    self.exception_class = ExpectationError
  end
end

Version data entries

23 entries across 20 versions & 4 rubygems

Version Path
mocha-1.6.0 lib/mocha/expectation_error_factory.rb
mocha-1.5.0 lib/mocha/expectation_error_factory.rb
mocha-1.4.0 lib/mocha/expectation_error_factory.rb
mocha-1.3.0 lib/mocha/expectation_error_factory.rb
mocha-1.2.1 lib/mocha/expectation_error_factory.rb
mocha-1.2.0 lib/mocha/expectation_error_factory.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/lib/mocha/expectation_error_factory.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/lib/mocha/expectation_error_factory.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/lib/mocha/expectation_error_factory.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/apl-library-0.0.90/vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/lib/mocha/expectation_error_factory.rb
mocha-1.1.0 lib/mocha/expectation_error_factory.rb
mocha-1.0.0 lib/mocha/expectation_error_factory.rb
mocha-1.0.0.alpha lib/mocha/expectation_error_factory.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/lib/mocha/expectation_error_factory.rb
challah-1.0.0 vendor/bundle/gems/mocha-0.14.0/lib/mocha/expectation_error_factory.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/lib/mocha/expectation_error_factory.rb
mocha-0.14.0 lib/mocha/expectation_error_factory.rb
challah-1.0.0.beta3 vendor/bundle/gems/mocha-0.13.3/lib/mocha/expectation_error_factory.rb
mocha-0.14.0.alpha lib/mocha/expectation_error_factory.rb
challah-1.0.0.beta2 vendor/bundle/gems/mocha-0.13.3/lib/mocha/expectation_error_factory.rb