Sha256: a44bf7b8287806215a7e5d5b1b18d45a59cb056f5cdb1870a6c45b4aae0aa2b2

Contents?: true

Size: 833 Bytes

Versions: 41

Compression:

Stored size: 833 Bytes

Contents

module Mocha
  class Central
    class Null < self
      def initialize(&block)
        super
        @raise_not_initialized_error = block
      end

      def stub(*)
        @raise_not_initialized_error.call
      end

      def unstub(*)
        @raise_not_initialized_error.call
      end
    end

    attr_accessor :stubba_methods

    def initialize
      self.stubba_methods = []
    end

    def stub(method)
      return if stubba_methods.detect { |m| m.matches?(method) }
      method.stub
      stubba_methods.push(method)
    end

    def unstub(method)
      return unless (existing = stubba_methods.detect { |m| m.matches?(method) })
      existing.unstub
      stubba_methods.delete(existing)
    end

    def unstub_all
      while stubba_methods.any?
        unstub(stubba_methods.first)
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 3 rubygems

Version Path
mocha-2.0.0 lib/mocha/central.rb
mocha-1.16.0 lib/mocha/central.rb
mocha-2.0.0.alpha.1 lib/mocha/central.rb
mocha-2.0.0.alpha lib/mocha/central.rb
mocha-1.15.0 lib/mocha/central.rb
mocha-1.14.0 lib/mocha/central.rb
mocha-1.13.0 lib/mocha/central.rb
mocha-1.12.0 lib/mocha/central.rb
mocha-1.11.2 lib/mocha/central.rb
mocha-1.11.1 lib/mocha/central.rb
mocha-1.11.0 lib/mocha/central.rb
mocha-1.10.2 lib/mocha/central.rb
mocha-1.10.1 lib/mocha/central.rb
mocha-1.10.0 lib/mocha/central.rb
mocha-1.10.0.beta.1 lib/mocha/central.rb
mocha-1.10.0.alpha lib/mocha/central.rb
mocha-1.9.0 lib/mocha/central.rb
cocoapods-dependency-html-0.0.2 vendor/bundle/gems/mocha-1.8.0/lib/mocha/central.rb
cocoapods-dependency-html-0.0.1 vendor/bundle/gems/mocha-1.8.0/lib/mocha/central.rb
mocha-1.8.0 lib/mocha/central.rb