~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/parameter_matchers/equals.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
require 'mocha/parameter_matchers/base'
 
2
 
 
3
module Mocha
 
4
  
 
5
  module ParameterMatchers
 
6
 
 
7
    # :call-seq: equals(value) -> parameter_matcher
 
8
    #
 
9
    # Matches +Object+ equalling +value+.
 
10
    #   object = mock()
 
11
    #   object.expects(:method_1).with(equals(2))
 
12
    #   object.method_1(2)
 
13
    #   # no error raised
 
14
    #
 
15
    #   object = mock()
 
16
    #   object.expects(:method_1).with(equals(2))
 
17
    #   object.method_1(3)
 
18
    #   # error raised, because method_1 was not called with Object equalling 3
 
19
    def equals(value)
 
20
      Equals.new(value)
 
21
    end
 
22
 
 
23
    class Equals < Base # :nodoc:
 
24
      
 
25
      def initialize(value)
 
26
        @value = value
 
27
      end
 
28
      
 
29
      def matches?(available_parameters)
 
30
        parameter = available_parameters.shift
 
31
        parameter == @value
 
32
      end
 
33
      
 
34
      def mocha_inspect
 
35
        @value.mocha_inspect
 
36
      end
 
37
      
 
38
    end
 
39
    
 
40
  end
 
41
  
 
42
end
 
 
b'\\ No newline at end of file'