Sha256: 3e567ae5967f3bb6af25af39e2dc71c1f7c15951b0c7ec69843877a6ac8987f6

Contents?: true

Size: 1.19 KB

Versions: 9

Compression:

Stored size: 1.19 KB

Contents

require 'spy'

module Spy
  if defined?(::MiniTest::Unit::TestCase) || defined?(::Minitest::Test)
    module MiniTestAdapter
      include API
      def after_teardown
        super
        Spy.teardown
      end
    end

    if defined?(::MiniTest::Unit::TestCase) && !::MiniTest::Unit::TestCase.include?(MiniTestAdapter)
      ::MiniTest::Unit::TestCase.send(:include, MiniTestAdapter)
    end

    if defined?(::Minitest::Test) && !::Minitest::Test.include?(MiniTestAdapter)
     ::Minitest::Test.send(:include, MiniTestAdapter)
    end
  end

  if defined?(::Test::Unit::TestCase) && !(defined?(::MiniTest::Unit::TestCase) && (::Test::Unit::TestCase < ::MiniTest::Unit::TestCase)) && !(defined?(::MiniTest::Spec) && (::Test::Unit::TestCase < ::MiniTest::Spec))

    module TestUnitAdapter
      include API
      def self.included(mod)
        mod.teardown :spy_teardown, :after => :append
      end

      def spy_teardown
        Spy.teardown
      end
    end

    ::Test::Unit::TestCase.send(:include, TestUnitAdapter)
  end

  class RspecAdapter
    include API
    def setup_mocks_for_rspec
    end
    def verify_mocks_for_rspec
    end
    def teardown_mocks_for_rspec
      Spy.teardown
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
spy-1.0.5 lib/spy/integration.rb
spy-1.0.4 lib/spy/integration.rb
spy-1.0.3 lib/spy/integration.rb
spy-1.0.2 lib/spy/integration.rb
spy-1.0.1 lib/spy/integration.rb
spy-1.0.0 lib/spy/integration.rb
spy-0.4.5 lib/spy/integration.rb
spy-0.4.3 lib/spy/integration.rb
spy-0.4.2 lib/spy/integration.rb