Class: Mocha::Central
Instance Attribute Summary collapse
-
#stubba_methods ⇒ Object
Returns the value of attribute stubba_methods.
Instance Method Summary collapse
-
#initialize ⇒ Central
constructor
A new instance of Central.
- #stub(method) ⇒ Object
- #unstub(method) ⇒ Object
- #unstub_all ⇒ Object
Constructor Details
#initialize ⇒ Central
Returns a new instance of Central.
7 8 9 |
# File 'lib/mocha/central.rb', line 7 def initialize self.stubba_methods = [] end |
Instance Attribute Details
#stubba_methods ⇒ Object
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_all ⇒ Object
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 |