Class: Stubba::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
- #unique_mocks ⇒ Object
- #unstub_all ⇒ Object
- #verify_all(&block) ⇒ Object
Constructor Details
#initialize ⇒ Central
Returns a new instance of Central.
7 8 9 |
# File 'lib/stubba/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/stubba/central.rb', line 5 def stubba_methods @stubba_methods end |
Instance Method Details
#stub(method) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/stubba/central.rb', line 11 def stub(method) unless stubba_methods.include?(method) method.stub stubba_methods.push method end end |
#unique_mocks ⇒ Object
22 23 24 |
# File 'lib/stubba/central.rb', line 22 def unique_mocks stubba_methods.collect { |method| method.mock }.uniq end |
#unstub_all ⇒ Object
26 27 28 29 30 31 |
# File 'lib/stubba/central.rb', line 26 def unstub_all while stubba_methods.size > 0 method = stubba_methods.pop method.unstub end end |
#verify_all(&block) ⇒ Object
18 19 20 |
# File 'lib/stubba/central.rb', line 18 def verify_all(&block) unique_mocks.each { |mock| mock.verify(&block) } end |