Sha256: 190cd71024441ebca67eb04971221472722e28c21359a45ce693bae8c60b34d7

Contents?: true

Size: 1.09 KB

Versions: 5

Compression:

Stored size: 1.09 KB

Contents

require 'mocha/mock'
require 'stubba/instance_method'
require 'stubba/class_method'
require 'stubba/any_instance_method'

class Object
  
  def mocha
    @mocha ||= Mocha::Mock.new
  end
  
  def reset_mocha
    @mocha = nil
  end
  
  def stubba_method
    Stubba::InstanceMethod
  end
  
  def stubba_object
    self
  end

  def expects(symbol) 
    method = stubba_method.new(stubba_object, symbol)
    $stubba.stub(method)
    mocha.expects(symbol)
  end
  
  def stubs(symbol) 
    method = stubba_method.new(stubba_object, symbol)
    $stubba.stub(method)
    mocha.stubs(symbol)
  end
  
  def verify(*method_names)
    mocha.verify(*method_names)
  end
  
end

class Module
  
  def stubba_method
    Stubba::ClassMethod
  end
    
end
  
class Class
  
  def stubba_method
    Stubba::ClassMethod
  end

  class AnyInstance
    
    def initialize(klass)
      @stubba_object = klass
    end
    
    def stubba_method
      Stubba::AnyInstanceMethod
    end
    
    def stubba_object
      @stubba_object
    end
    
  end
  
  def any_instance
    @any_instance ||= AnyInstance.new(self)
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
mocha-0.2.1 lib/stubba/object.rb
mocha-0.1.1 lib/stubba/object.rb
mocha-0.1.2 lib/stubba/object.rb
mocha-0.2.0 lib/stubba/object.rb
mocha-0.1 lib/stubba/object.rb