Sha256: 3ea5ae7af43af0fd000813ddf2fd5d34e915baf4a54192e2808430de598cff1f

Contents?: true

Size: 1.92 KB

Versions: 20

Compression:

Stored size: 1.92 KB

Contents

require 'mocha/mockery'

module Mocha

  # Integration hooks for test library authors.
  #
  # The methods in this module should be called from test libraries wishing to integrate with Mocha.
  #
  # This module is provided as part of the +Mocha::API+ module and is therefore part of the public API, but should only be used by authors of test libraries and not by typical "users" of Mocha.
  #
  # Integration with Test::Unit and MiniTest are provided as part of Mocha, because they are (or were once) part of the Ruby standard library. Integration with other test libraries is not provided as *part* of Mocha, but is supported by means of the methods in this module.
  #
  # See the code in the +Adapter+ modules for examples of how to use the methods in this module. +Mocha::ExpectationErrorFactory+ may be used if you want +Mocha+ to raise a different type of exception.
  #
  # @see Mocha::Integration::TestUnit::Adapter
  # @see Mocha::Integration::MiniTest::Adapter
  # @see Mocha::ExpectationErrorFactory
  # @see Mocha::API
  module Hooks
    # Prepares Mocha before a test (only for use by authors of test libraries).
    #
    # This method should be called before each individual test starts (including before any "setup" code).
    def mocha_setup
    end

    # Verifies that all mock expectations have been met (only for use by authors of test libraries).
    #
    # This is equivalent to a series of "assertions".
    #
    # This method should be called at the end of each individual test, before it has been determined whether or not the test has passed.
    def mocha_verify(assertion_counter = nil)
      Mockery.verify(assertion_counter)
    end

    # Resets Mocha after a test (only for use by authors of test libraries).
    #
    # This method should be called after each individual test has finished (including after any "teardown" code).
    def mocha_teardown
      Mockery.teardown
    ensure
      Mockery.reset_instance
    end
  end
end

Version data entries

20 entries across 17 versions & 4 rubygems

Version Path
mocha-1.4.0 lib/mocha/hooks.rb
mocha-1.3.0 lib/mocha/hooks.rb
mocha-1.2.1 lib/mocha/hooks.rb
mocha-1.2.0 lib/mocha/hooks.rb
apl-library-0.0.90 vendor/bundle/ruby/2.1.0/gems/mocha-1.0.0/lib/mocha/hooks.rb
apl-library-0.0.90 vendor/bundle/ruby/1.9.1/gems/mocha-1.0.0/lib/mocha/hooks.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/hooks.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/hooks.rb
mocha-1.1.0 lib/mocha/hooks.rb
mocha-1.0.0 lib/mocha/hooks.rb
mocha-1.0.0.alpha lib/mocha/hooks.rb
tnargav-1.3.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/lib/mocha/hooks.rb
challah-1.0.0 vendor/bundle/gems/mocha-0.14.0/lib/mocha/hooks.rb
tnargav-1.2.3 vendor/bundle/ruby/1.9.1/gems/mocha-0.14.0/lib/mocha/hooks.rb
mocha-0.14.0 lib/mocha/hooks.rb
challah-1.0.0.beta3 vendor/bundle/gems/mocha-0.13.3/lib/mocha/hooks.rb
mocha-0.14.0.alpha lib/mocha/hooks.rb
challah-1.0.0.beta2 vendor/bundle/gems/mocha-0.13.3/lib/mocha/hooks.rb
challah-1.0.0.beta vendor/bundle/gems/mocha-0.13.3/lib/mocha/hooks.rb
mocha-0.13.3 lib/mocha/hooks.rb