-
Notifications
You must be signed in to change notification settings - Fork 16
/
basic_mocks.rb
89 lines (62 loc) · 1.19 KB
/
basic_mocks.rb
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# encoding: utf-8
# Basic mocks for our tests
# @author Gernot Kogler
class String
def tableize
self # not really important what we return
end
def parameterize
self # not really important what we return
end
end
class IndexedObject
attr_reader :id
def initialize(id)
@id = id
end
end
class IndexedObjectSubclass < IndexedObject
end
require 'descendants_tracker'
class IndexedObjectDT
extend DescendantsTracker
attr_reader :id
def initialize(id)
@id = id
end
end
class IndexedObjectTrackedSubclass < IndexedObjectDT
end
class OtherIndexedObject
attr_reader :id
def initialize(id)
@id = id
end
end
class ObjectReturningNilOnToS
def to_s
nil
end
end
module Namespace
class IndexedObject
attr_reader :id
def initialize(id)
@id = id
end
end
end
# Test adapter
class DemoAdapter
def self.add_class_helper_methods_to(klass)
klass.instance_eval do
# This method must be implemented by all adapters. It must
# return a string that uniquely identifies an object
define_method(:xapian_id) do
"a_unique_key_expression"
end
end
end
def self.add_doc_helper_methods_to(klass)
end
end