Class: Mocha::Central

Inherits:
Object show all
Defined in:
lib/mocha/central.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCentral


7
8
9
# File 'lib/mocha/central.rb', line 7

def initialize
  self.stubba_methods = []
end

Instance Attribute Details

#stubba_methodsObject

Returns the value of attribute stubba_methods


5
6
7
# File 'lib/mocha/central.rb', line 5

def stubba_methods
  @stubba_methods
end

Instance Method Details

#stub(method) ⇒ Object


11
12
13
14
15
16
# File 'lib/mocha/central.rb', line 11

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

#unstub(method) ⇒ Object


18
19
20
21
22
23
# File 'lib/mocha/central.rb', line 18

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

#unstub_allObject


25
26
27
28
29
# File 'lib/mocha/central.rb', line 25

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