Sha256: 195b39cee748fca0b2dc8cd4b31c34d1602ceedcb5c51c708312d9fc07e97ff8

Contents?: true

Size: 1.3 KB

Versions: 3

Compression:

Stored size: 1.3 KB

Contents

require 'mocha/integration/mini_test/assertion_counter'
require 'mocha/expectation_error'

module Mocha
  
  module Integration
    
    module MiniTest
      
      def self.translate(exception)
        return exception unless exception.kind_of?(::Mocha::ExpectationError)
        translated_exception = ::MiniTest::Assertion.new(exception.message)
        translated_exception.set_backtrace(exception.backtrace)
        translated_exception
      end
      
      module Version131AndAbove
        def run runner
          assertion_counter = AssertionCounter.new(self)
          result = '.'
          begin
            begin
              @passed = nil
              self.setup
              self.__send__ self.name
              mocha_verify(assertion_counter)
              @passed = true
            rescue Exception => e
              @passed = false
              result = runner.puke(self.class, self.name, Mocha::Integration::MiniTest.translate(e))
            ensure
              begin
                self.teardown
              rescue Exception => e
                result = runner.puke(self.class, self.name, Mocha::Integration::MiniTest.translate(e))
              end
            end
          ensure
            mocha_teardown
          end
          result
        end
      end
      
    end
    
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
jferris-mocha-0.9.5.0.1240002286 lib/mocha/integration/mini_test/version_131_and_above.rb
jferris-mocha-0.9.5.0.1240351621 lib/mocha/integration/mini_test/version_131_and_above.rb
jferris-mocha-0.9.5.0.1241126838 lib/mocha/integration/mini_test/version_131_and_above.rb