File: names.rb

package info (click to toggle)
ruby-mocha 0.11.3-3
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 2,300 kB
  • sloc: ruby: 9,935; makefile: 2
file content (53 lines) | stat: -rw-r--r-- 704 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
module Mocha

  class ImpersonatingName

    def initialize(object)
      @object = object
    end

    def mocha_inspect
      @object.mocha_inspect
    end

  end

  class ImpersonatingAnyInstanceName

    def initialize(klass)
      @klass = klass
    end

    def mocha_inspect
      "#<AnyInstance:#{@klass.mocha_inspect}>"
    end

  end

  class Name

    def initialize(name)
      @name = name
    end

    def mocha_inspect
      "#<Mock:#{@name}>"
    end

  end

  class DefaultName

    def initialize(mock)
      @mock = mock
    end

    def mocha_inspect
      address = @mock.__id__ * 2
      address += 0x100000000 if address < 0
      "#<Mock:0x#{'%x' % address}>"
    end

  end

end