~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to vendor/gems/mocha-0.5.6/lib/mocha/central.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
module Mocha
 
2
  
 
3
  class Central
 
4
  
 
5
    attr_accessor :stubba_methods
 
6
  
 
7
    def initialize
 
8
      self.stubba_methods = []
 
9
    end
 
10
   
 
11
    def stub(method)
 
12
      unless stubba_methods.include?(method)
 
13
        method.stub 
 
14
        stubba_methods.push method
 
15
      end
 
16
    end
 
17
    
 
18
    def verify_all(&block)
 
19
      unique_mocks.each { |mock| mock.verify(&block) }
 
20
    end
 
21
    
 
22
    def unique_mocks
 
23
      stubba_methods.inject({}) { |mocks, method| mocks[method.mock.__id__] = method.mock; mocks }.values
 
24
    end
 
25
  
 
26
    def unstub_all
 
27
      while stubba_methods.length > 0
 
28
        method = stubba_methods.pop
 
29
        method.unstub
 
30
      end
 
31
    end
 
32
 
 
33
  end
 
34
 
 
35
end
 
 
b'\\ No newline at end of file'