Sha256: ffbf917a9add15484963760f4d5e59ac8cde993e78560480b1764279f3394c08

Contents?: true

Size: 1.81 KB

Versions: 2594

Compression:

Stored size: 1.81 KB

Contents

require 'rspec/mocks'

module RSpec
  module Mocks
    # @private
    module MinitestIntegration
      include ::RSpec::Mocks::ExampleMethods

      def before_setup
        ::RSpec::Mocks.setup
        super
      end

      def after_teardown
        super

        # Only verify if there's not already an error. Otherwise
        # we risk getting the same failure twice, since negative
        # expectation violations raise both when the message is
        # unexpectedly received, and also during `verify` (in case
        # the first failure was caught by user code via a
        # `rescue Exception`).
        ::RSpec::Mocks.verify unless failures.any?
      ensure
        ::RSpec::Mocks.teardown
      end
    end
  end
end

Minitest::Test.send(:include, RSpec::Mocks::MinitestIntegration)

if defined?(::Minitest::Expectation)
  if defined?(::RSpec::Expectations) && ::Minitest::Expectation.method_defined?(:to)
    # rspec/expectations/minitest_integration has already been loaded and
    # has defined `to`/`not_to`/`to_not` on `Minitest::Expectation` so we do
    # not want to here (or else we would interfere with rspec-expectations' definition).
  else
    # ...otherwise, define those methods now. If `rspec/expectations/minitest_integration`
    # is loaded after this file, it'll overide the defintion here.
    Minitest::Expectation.class_eval do
      include RSpec::Mocks::ExpectationTargetMethods

      def to(*args)
        ctx.assertions += 1
        super
      end

      def not_to(*args)
        ctx.assertions += 1
        super
      end

      def to_not(*args)
        ctx.assertions += 1
        super
      end
    end
  end
end

module RSpec
  module Mocks
    remove_const :MockExpectationError
    # Raised when a message expectation is not satisfied.
    MockExpectationError = ::Minitest::Assertion
  end
end

Version data entries

2,594 entries across 2,509 versions & 94 rubygems

Version Path
mux_ruby-3.20.0 vendor/bundle/ruby/3.2.0/gems/rspec-mocks-3.11.1/lib/rspec/mocks/minitest_integration.rb
mux_ruby-3.19.0 vendor/bundle/ruby/3.2.0/gems/rspec-mocks-3.11.1/lib/rspec/mocks/minitest_integration.rb
mux_ruby-3.18.0 vendor/bundle/ruby/3.2.0/gems/rspec-mocks-3.11.1/lib/rspec/mocks/minitest_integration.rb
mux_ruby-3.17.0 vendor/bundle/ruby/3.2.0/gems/rspec-mocks-3.11.1/lib/rspec/mocks/minitest_integration.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/rspec-mocks-3.10.2/lib/rspec/mocks/minitest_integration.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/rspec-mocks-3.10.2/lib/rspec/mocks/minitest_integration.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/rspec-mocks-3.10.2/lib/rspec/mocks/minitest_integration.rb
mux_ruby-3.15.0 vendor/bundle/ruby/3.2.0/gems/rspec-mocks-3.11.1/lib/rspec/mocks/minitest_integration.rb
avalara_sdk-24.2.29 vendor/bundle/ruby/2.7.0/gems/rspec-mocks-3.11.1/lib/rspec/mocks/minitest_integration.rb
mux_ruby-3.14.0 vendor/bundle/ruby/3.2.0/gems/rspec-mocks-3.11.1/lib/rspec/mocks/minitest_integration.rb
mux_ruby-3.13.0 vendor/bundle/ruby/3.2.0/gems/rspec-mocks-3.11.1/lib/rspec/mocks/minitest_integration.rb
mux_ruby-3.12.0 vendor/bundle/ruby/3.2.0/gems/rspec-mocks-3.11.1/lib/rspec/mocks/minitest_integration.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rspec-mocks-3.11.0/lib/rspec/mocks/minitest_integration.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/rspec-mocks-3.11.1/lib/rspec/mocks/minitest_integration.rb
mux_ruby-3.11.1 vendor/bundle/ruby/3.2.0/gems/rspec-mocks-3.11.1/lib/rspec/mocks/minitest_integration.rb
mux_ruby-3.11.0 vendor/bundle/ruby/3.2.0/gems/rspec-mocks-3.11.1/lib/rspec/mocks/minitest_integration.rb
opal-rspec-1.1.0.alpha3 rspec-mocks/upstream/lib/rspec/mocks/minitest_integration.rb
opal-rspec-1.1.0.alpha2 rspec-mocks/upstream/lib/rspec/mocks/minitest_integration.rb
opal-rspec-1.1.0.alpha1 rspec-mocks/upstream/lib/rspec/mocks/minitest_integration.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/rspec-mocks-3.11.0/lib/rspec/mocks/minitest_integration.rb