~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/not.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mfrom: (1.1.8 upstream) (3.1.1 lenny)
  • Revision ID: james.westby@ubuntu.com-20080726154345-c03m49twzxewdwjn
Tags: 0.24.5-2
* Fix puppetlast to work with 0.24.5
* Adjust logcheck to match against new log messages in 0.24.5
* Update standards version to 3.8.0 (no changes)
* Update changelog to reduce length of line to make lintian happy

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: Not(matcher) -> parameter_matcher
 
8
    #
 
9
    # Matches if +matcher+ does not match.
 
10
    #   object = mock()
 
11
    #   object.expects(:method_1).with(Not(includes(1)))
 
12
    #   object.method_1([0, 2, 3])
 
13
    #   # no error raised
 
14
    #
 
15
    #   object = mock()
 
16
    #   object.expects(:method_1).with(Not(includes(1)))
 
17
    #   object.method_1([0, 1, 2, 3])
 
18
    #   # error raised, because method_1 was not called with object not including 1
 
19
    def Not(matcher)
 
20
      Not.new(matcher)
 
21
    end
 
22
    
 
23
    class Not < Base # :nodoc:
 
24
      
 
25
      def initialize(matcher)
 
26
        @matcher = matcher
 
27
      end
 
28
    
 
29
      def matches?(available_parameters)
 
30
        parameter = available_parameters.shift
 
31
        !@matcher.matches?([parameter])
 
32
      end
 
33
      
 
34
      def mocha_inspect
 
35
        "Not(#{@matcher.mocha_inspect})"
 
36
      end
 
37
      
 
38
    end
 
39
    
 
40
  end
 
41
  
 
42
end
 
 
b'\\ No newline at end of file'