riddle 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. data/.gitignore +6 -0
  2. data/.travis.yml +16 -0
  3. data/Gemfile +6 -0
  4. data/HISTORY +45 -0
  5. data/LICENCE +20 -0
  6. data/README.textile +5 -3
  7. data/Rakefile +23 -0
  8. data/lib/riddle.rb +1 -0
  9. data/lib/riddle/0.9.9/configuration/searchd.rb +10 -8
  10. data/lib/riddle/auto_version.rb +2 -2
  11. data/lib/riddle/client.rb +117 -118
  12. data/lib/riddle/configuration.rb +6 -6
  13. data/lib/riddle/configuration/distributed_index.rb +16 -16
  14. data/lib/riddle/configuration/sql_source.rb +5 -5
  15. data/lib/riddle/controller.rb +28 -25
  16. data/lib/riddle/query.rb +31 -20
  17. data/lib/riddle/query/select.rb +69 -8
  18. data/lib/riddle/version.rb +3 -0
  19. data/riddle.gemspec +25 -0
  20. data/spec/fixtures/.gitignore +2 -0
  21. data/spec/fixtures/data/0.9.9/anchor.bin +0 -0
  22. data/spec/fixtures/data/0.9.9/any.bin +0 -0
  23. data/spec/fixtures/data/0.9.9/boolean.bin +0 -0
  24. data/spec/fixtures/data/0.9.9/comment.bin +0 -0
  25. data/spec/fixtures/data/0.9.9/distinct.bin +0 -0
  26. data/spec/fixtures/data/0.9.9/field_weights.bin +0 -0
  27. data/spec/fixtures/data/0.9.9/filter.bin +0 -0
  28. data/spec/fixtures/data/0.9.9/filter_array.bin +0 -0
  29. data/spec/fixtures/data/0.9.9/filter_array_exclude.bin +0 -0
  30. data/spec/fixtures/data/0.9.9/filter_boolean.bin +0 -0
  31. data/spec/fixtures/data/0.9.9/filter_floats.bin +0 -0
  32. data/spec/fixtures/data/0.9.9/filter_floats_exclude.bin +0 -0
  33. data/spec/fixtures/data/0.9.9/filter_range.bin +0 -0
  34. data/spec/fixtures/data/0.9.9/filter_range_exclude.bin +0 -0
  35. data/spec/fixtures/data/0.9.9/group.bin +0 -0
  36. data/spec/fixtures/data/0.9.9/index.bin +0 -0
  37. data/spec/fixtures/data/0.9.9/index_weights.bin +0 -0
  38. data/spec/fixtures/data/0.9.9/keywords_with_hits.bin +0 -0
  39. data/spec/fixtures/data/0.9.9/keywords_without_hits.bin +0 -0
  40. data/spec/fixtures/data/0.9.9/overrides.bin +0 -0
  41. data/spec/fixtures/data/0.9.9/phrase.bin +0 -0
  42. data/spec/fixtures/data/0.9.9/rank_mode.bin +0 -0
  43. data/spec/fixtures/data/0.9.9/select.bin +0 -0
  44. data/spec/fixtures/data/0.9.9/simple.bin +0 -0
  45. data/spec/fixtures/data/0.9.9/sort.bin +0 -0
  46. data/spec/fixtures/data/0.9.9/update_simple.bin +0 -0
  47. data/spec/fixtures/data/0.9.9/weights.bin +0 -0
  48. data/spec/fixtures/data/1.10/anchor.bin +0 -0
  49. data/spec/fixtures/data/1.10/any.bin +0 -0
  50. data/spec/fixtures/data/1.10/boolean.bin +0 -0
  51. data/spec/fixtures/data/1.10/comment.bin +0 -0
  52. data/spec/fixtures/data/1.10/distinct.bin +0 -0
  53. data/spec/fixtures/data/1.10/field_weights.bin +0 -0
  54. data/spec/fixtures/data/1.10/filter.bin +0 -0
  55. data/spec/fixtures/data/1.10/filter_array.bin +0 -0
  56. data/spec/fixtures/data/1.10/filter_array_exclude.bin +0 -0
  57. data/spec/fixtures/data/1.10/filter_boolean.bin +0 -0
  58. data/spec/fixtures/data/1.10/filter_floats.bin +0 -0
  59. data/spec/fixtures/data/1.10/filter_floats_exclude.bin +0 -0
  60. data/spec/fixtures/data/1.10/filter_range.bin +0 -0
  61. data/spec/fixtures/data/1.10/filter_range_exclude.bin +0 -0
  62. data/spec/fixtures/data/1.10/group.bin +0 -0
  63. data/spec/fixtures/data/1.10/index.bin +0 -0
  64. data/spec/fixtures/data/1.10/index_weights.bin +0 -0
  65. data/spec/fixtures/data/1.10/keywords_with_hits.bin +0 -0
  66. data/spec/fixtures/data/1.10/keywords_without_hits.bin +0 -0
  67. data/spec/fixtures/data/1.10/overrides.bin +0 -0
  68. data/spec/fixtures/data/1.10/phrase.bin +0 -0
  69. data/spec/fixtures/data/1.10/rank_mode.bin +0 -0
  70. data/spec/fixtures/data/1.10/select.bin +0 -0
  71. data/spec/fixtures/data/1.10/simple.bin +0 -0
  72. data/spec/fixtures/data/1.10/sort.bin +0 -0
  73. data/spec/fixtures/data/1.10/update_simple.bin +0 -0
  74. data/spec/fixtures/data/1.10/weights.bin +0 -0
  75. data/spec/fixtures/data/2.0.1/anchor.bin +0 -0
  76. data/spec/fixtures/data/2.0.1/any.bin +0 -0
  77. data/spec/fixtures/data/2.0.1/boolean.bin +0 -0
  78. data/spec/fixtures/data/2.0.1/comment.bin +0 -0
  79. data/spec/fixtures/data/2.0.1/distinct.bin +0 -0
  80. data/spec/fixtures/data/2.0.1/field_weights.bin +0 -0
  81. data/spec/fixtures/data/2.0.1/filter.bin +0 -0
  82. data/spec/fixtures/data/2.0.1/filter_array.bin +0 -0
  83. data/spec/fixtures/data/2.0.1/filter_array_exclude.bin +0 -0
  84. data/spec/fixtures/data/2.0.1/filter_boolean.bin +0 -0
  85. data/spec/fixtures/data/2.0.1/filter_floats.bin +0 -0
  86. data/spec/fixtures/data/2.0.1/filter_floats_exclude.bin +0 -0
  87. data/spec/fixtures/data/2.0.1/filter_range.bin +0 -0
  88. data/spec/fixtures/data/2.0.1/filter_range_exclude.bin +0 -0
  89. data/spec/fixtures/data/2.0.1/group.bin +0 -0
  90. data/spec/fixtures/data/2.0.1/index.bin +0 -0
  91. data/spec/fixtures/data/2.0.1/index_weights.bin +0 -0
  92. data/spec/fixtures/data/2.0.1/keywords_with_hits.bin +0 -0
  93. data/spec/fixtures/data/2.0.1/keywords_without_hits.bin +0 -0
  94. data/spec/fixtures/data/2.0.1/overrides.bin +0 -0
  95. data/spec/fixtures/data/2.0.1/phrase.bin +0 -0
  96. data/spec/fixtures/data/2.0.1/rank_mode.bin +0 -0
  97. data/spec/fixtures/data/2.0.1/select.bin +0 -0
  98. data/spec/fixtures/data/2.0.1/simple.bin +0 -0
  99. data/spec/fixtures/data/2.0.1/sort.bin +0 -0
  100. data/spec/fixtures/data/2.0.1/update_simple.bin +0 -0
  101. data/spec/fixtures/data/2.0.1/weights.bin +0 -0
  102. data/spec/fixtures/data_generator.0.9.8.php +208 -0
  103. data/spec/fixtures/data_generator.0.9.9.php +5 -0
  104. data/spec/fixtures/data_generator.1.10.php +5 -0
  105. data/spec/fixtures/data_generator.2.0.1.php +5 -0
  106. data/spec/fixtures/data_generator.php +223 -0
  107. data/spec/fixtures/sphinxapi.0.9.8.php +1228 -0
  108. data/spec/fixtures/sphinxapi.0.9.9.php +1646 -0
  109. data/spec/fixtures/sphinxapi.1.10.php +1728 -0
  110. data/spec/fixtures/sphinxapi.2.0.1.php +1731 -0
  111. data/spec/fixtures/sql/conf.example.yml +3 -0
  112. data/spec/fixtures/sql/data.sql +25000 -0
  113. data/spec/fixtures/sql/data.tsv +25000 -0
  114. data/spec/fixtures/sql/structure.sql +16 -0
  115. data/spec/functional/connection_spec.rb +10 -12
  116. data/spec/functional/excerpt_spec.rb +1 -1
  117. data/spec/functional/keywords_spec.rb +1 -1
  118. data/spec/functional/persistance_spec.rb +1 -1
  119. data/spec/functional/search_spec.rb +1 -1
  120. data/spec/functional/status_spec.rb +1 -1
  121. data/spec/functional/update_spec.rb +1 -1
  122. data/spec/riddle/auto_version_spec.rb +18 -10
  123. data/spec/riddle/query/select_spec.rb +78 -14
  124. data/spec/riddle/query_spec.rb +5 -3
  125. data/spec/spec_helper.rb +13 -15
  126. data/spec/support/binary_fixtures.rb +18 -0
  127. data/spec/support/sphinx.rb +135 -0
  128. data/spec/unit/client_spec.rb +150 -142
  129. data/spec/unit/configuration/distributed_index_spec.rb +15 -15
  130. data/spec/unit/configuration/searchd_spec.rb +28 -3
  131. data/spec/unit/configuration_spec.rb +6 -6
  132. metadata +254 -68
  133. data/spec/sphinx_helper.rb +0 -96
@@ -13,6 +13,12 @@ describe Riddle::Client do
13
13
  it "should default to port 9312" do
14
14
  Riddle::Client.new.port.should == 9312
15
15
  end
16
+
17
+ it "should accept an array of servers" do
18
+ servers = ["1.1.1.1", "2.2.2.2", "3.3.3.3"]
19
+ client = Riddle::Client.new(servers)
20
+ client.servers.should == servers
21
+ end
16
22
 
17
23
  it "should translate anchor arguments correctly" do
18
24
  client = Riddle::Client.new
@@ -32,182 +38,184 @@ describe Riddle::Client do
32
38
  client.queue.should_not be_empty
33
39
  end
34
40
 
35
- it "should build a basic search message correctly" do
36
- client = Riddle::Client.new
37
- client.append_query "test "
38
- client.queue.first.should == query_contents(:simple)
39
- end
41
+ describe 'query contents' do
42
+ it "should build a basic search message correctly" do
43
+ client = Riddle::Client.new
44
+ client.append_query "test "
45
+ client.queue.first.should == query_contents(:simple)
46
+ end
40
47
 
41
- it "should build a message with a specified index correctly" do
42
- client = Riddle::Client.new
43
- client.append_query "test ", "edition"
44
- client.queue.first.should == query_contents(:index)
45
- end
48
+ it "should build a message with a specified index correctly" do
49
+ client = Riddle::Client.new
50
+ client.append_query "test ", "edition"
51
+ client.queue.first.should == query_contents(:index)
52
+ end
46
53
 
47
- it "should build a message using match mode :any correctly" do
48
- client = Riddle::Client.new
49
- client.match_mode = :any
50
- client.append_query "test this "
51
- client.queue.first.should == query_contents(:any)
52
- end
54
+ it "should build a message using match mode :any correctly" do
55
+ client = Riddle::Client.new
56
+ client.match_mode = :any
57
+ client.append_query "test this "
58
+ client.queue.first.should == query_contents(:any)
59
+ end
53
60
 
54
- it "should build a message using sort by correctly" do
55
- client = Riddle::Client.new
56
- client.sort_by = 'id'
57
- client.sort_mode = :extended
58
- client.append_query "testing "
59
- client.queue.first.should == query_contents(:sort)
60
- end
61
+ it "should build a message using sort by correctly" do
62
+ client = Riddle::Client.new
63
+ client.sort_by = 'id'
64
+ client.sort_mode = :extended
65
+ client.append_query "testing "
66
+ client.queue.first.should == query_contents(:sort)
67
+ end
61
68
 
62
- it "should build a message using match mode :boolean correctly" do
63
- client = Riddle::Client.new
64
- client.match_mode = :boolean
65
- client.append_query "test "
66
- client.queue.first.should == query_contents(:boolean)
67
- end
69
+ it "should build a message using match mode :boolean correctly" do
70
+ client = Riddle::Client.new
71
+ client.match_mode = :boolean
72
+ client.append_query "test "
73
+ client.queue.first.should == query_contents(:boolean)
74
+ end
68
75
 
69
- it "should build a message using match mode :phrase correctly" do
70
- client = Riddle::Client.new
71
- client.match_mode = :phrase
72
- client.append_query "testing this "
73
- client.queue.first.should == query_contents(:phrase)
74
- end
76
+ it "should build a message using match mode :phrase correctly" do
77
+ client = Riddle::Client.new
78
+ client.match_mode = :phrase
79
+ client.append_query "testing this "
80
+ client.queue.first.should == query_contents(:phrase)
81
+ end
75
82
 
76
- it "should build a message with a filter correctly" do
77
- client = Riddle::Client.new
78
- client.filters << Riddle::Client::Filter.new("id", [10, 100, 1000])
79
- client.append_query "test "
80
- client.queue.first.should == query_contents(:filter)
81
- end
83
+ it "should build a message with a filter correctly" do
84
+ client = Riddle::Client.new
85
+ client.filters << Riddle::Client::Filter.new("id", [10, 100, 1000])
86
+ client.append_query "test "
87
+ client.queue.first.should == query_contents(:filter)
88
+ end
82
89
 
83
- it "should build a message with group values correctly" do
84
- client = Riddle::Client.new
85
- client.group_by = "id"
86
- client.group_function = :attr
87
- client.group_clause = "id"
88
- client.append_query "test "
89
- client.queue.first.should == query_contents(:group)
90
- end
90
+ it "should build a message with group values correctly" do
91
+ client = Riddle::Client.new
92
+ client.group_by = "id"
93
+ client.group_function = :attr
94
+ client.group_clause = "id"
95
+ client.append_query "test "
96
+ client.queue.first.should == query_contents(:group)
97
+ end
91
98
 
92
- it "should build a message with group distinct value correctly" do
93
- client = Riddle::Client.new
94
- client.group_distinct = "id"
95
- client.append_query "test "
96
- client.queue.first.should == query_contents(:distinct)
97
- end
99
+ it "should build a message with group distinct value correctly" do
100
+ client = Riddle::Client.new
101
+ client.group_distinct = "id"
102
+ client.append_query "test "
103
+ client.queue.first.should == query_contents(:distinct)
104
+ end
98
105
 
99
- it "should build a message with weights correctly" do
100
- client = Riddle::Client.new
101
- client.weights = [100, 1]
102
- client.append_query "test "
103
- client.queue.first.should == query_contents(:weights)
104
- end
106
+ it "should build a message with weights correctly" do
107
+ client = Riddle::Client.new
108
+ client.weights = [100, 1]
109
+ client.append_query "test "
110
+ client.queue.first.should == query_contents(:weights)
111
+ end
105
112
 
106
- it "should build a message with an anchor correctly" do
107
- client = Riddle::Client.new
108
- client.set_anchor "latitude", 10.0, "longitude", 95.0
109
- client.append_query "test "
110
- client.queue.first.should == query_contents(:anchor)
111
- end
113
+ it "should build a message with an anchor correctly" do
114
+ client = Riddle::Client.new
115
+ client.set_anchor "latitude", 10.0, "longitude", 95.0
116
+ client.append_query "test "
117
+ client.queue.first.should == query_contents(:anchor)
118
+ end
112
119
 
113
- it "should build a message with index weights correctly" do
114
- client = Riddle::Client.new
115
- client.index_weights = {"people" => 101}
116
- client.append_query "test "
117
- client.queue.first.should == query_contents(:index_weights)
118
- end
120
+ it "should build a message with index weights correctly" do
121
+ client = Riddle::Client.new
122
+ client.index_weights = {"people" => 101}
123
+ client.append_query "test "
124
+ client.queue.first.should == query_contents(:index_weights)
125
+ end
119
126
 
120
- it "should build a message with field weights correctly" do
121
- client = Riddle::Client.new
122
- client.field_weights = {"city" => 101}
123
- client.append_query "test "
124
- client.queue.first.should == query_contents(:field_weights)
125
- end
127
+ it "should build a message with field weights correctly" do
128
+ client = Riddle::Client.new
129
+ client.field_weights = {"city" => 101}
130
+ client.append_query "test "
131
+ client.queue.first.should == query_contents(:field_weights)
132
+ end
126
133
 
127
- it "should build a message with a comment correctly" do
128
- client = Riddle::Client.new
129
- client.append_query "test ", "*", "commenting"
130
- client.queue.first.should == query_contents(:comment)
131
- end
134
+ it "should build a message with a comment correctly" do
135
+ client = Riddle::Client.new
136
+ client.append_query "test ", "*", "commenting"
137
+ client.queue.first.should == query_contents(:comment)
138
+ end
139
+
140
+ if Riddle.loaded_version == '0.9.9' || Riddle.loaded_version == '1.10'
141
+ it "should build a message with overrides correctly" do
142
+ client = Riddle::Client.new
143
+ client.add_override("rating", :float, {1 => 10.0})
144
+ client.append_query "test "
145
+ client.queue.first.should == query_contents(:overrides)
146
+ end
147
+
148
+ it "should build a message with selects correctly" do
149
+ client = Riddle::Client.new
150
+ client.select = "selecting"
151
+ client.append_query "test "
152
+ client.queue.first.should == query_contents(:select)
153
+ end
154
+ end
132
155
 
133
- if Riddle.loaded_version == '0.9.9' || Riddle.loaded_version == '1.10'
134
- it "should build a message with overrides correctly" do
156
+ it "should keep multiple messages in the queue" do
135
157
  client = Riddle::Client.new
136
- client.add_override("rating", :float, {1 => 10.0})
158
+ client.weights = [100, 1]
159
+ client.append_query "test "
137
160
  client.append_query "test "
138
- client.queue.first.should == query_contents(:overrides)
161
+ client.queue.length.should == 2
162
+ client.queue.each { |item| item.should == query_contents(:weights) }
139
163
  end
140
164
 
141
- it "should build a message with selects correctly" do
165
+ it "should keep multiple messages in the queue with different params" do
142
166
  client = Riddle::Client.new
143
- client.select = "selecting"
167
+ client.weights = [100, 1]
144
168
  client.append_query "test "
145
- client.queue.first.should == query_contents(:select)
169
+ client.weights = []
170
+ client.append_query "test ", "edition"
171
+ client.queue.first.should == query_contents(:weights)
172
+ client.queue.last.should == query_contents(:index)
146
173
  end
147
- end
148
-
149
- it "should keep multiple messages in the queue" do
150
- client = Riddle::Client.new
151
- client.weights = [100, 1]
152
- client.append_query "test "
153
- client.append_query "test "
154
- client.queue.length.should == 2
155
- client.queue.each { |item| item.should == query_contents(:weights) }
156
- end
157
174
 
158
- it "should keep multiple messages in the queue with different params" do
159
- client = Riddle::Client.new
160
- client.weights = [100, 1]
161
- client.append_query "test "
162
- client.weights = []
163
- client.append_query "test ", "edition"
164
- client.queue.first.should == query_contents(:weights)
165
- client.queue.last.should == query_contents(:index)
166
- end
167
-
168
- it "should build a basic update message correctly" do
169
- client = Riddle::Client.new
170
- client.send(
171
- :update_message,
172
- "people",
173
- ["birthday"],
174
- {1 => [191163600]}
175
- ).should == query_contents(:update_simple)
176
- end
175
+ it "should build a basic update message correctly" do
176
+ client = Riddle::Client.new
177
+ client.send(
178
+ :update_message,
179
+ "people",
180
+ ["birthday"],
181
+ {1 => [191163600]}
182
+ ).should == query_contents(:update_simple)
183
+ end
177
184
 
178
- it "should build a keywords request without hits correctly" do
179
- client = Riddle::Client.new
180
- client.send(
181
- :keywords_message,
182
- "pat",
183
- "people",
184
- false
185
- ).should == query_contents(:keywords_without_hits)
186
- end
185
+ it "should build a keywords request without hits correctly" do
186
+ client = Riddle::Client.new
187
+ client.send(
188
+ :keywords_message,
189
+ "pat",
190
+ "people",
191
+ false
192
+ ).should == query_contents(:keywords_without_hits)
193
+ end
187
194
 
188
- it "should build a keywords request with hits correctly" do
189
- client = Riddle::Client.new
190
- client.send(
191
- :keywords_message,
192
- "pat",
193
- "people",
194
- true
195
- ).should == query_contents(:keywords_with_hits)
195
+ it "should build a keywords request with hits correctly" do
196
+ client = Riddle::Client.new
197
+ client.send(
198
+ :keywords_message,
199
+ "pat",
200
+ "people",
201
+ true
202
+ ).should == query_contents(:keywords_with_hits)
203
+ end
196
204
  end
197
205
 
198
206
  it "should timeout after a specified time" do
199
207
  client = Riddle::Client.new
200
- client.port = 3314
208
+ client.port = 9314
201
209
  client.timeout = 1
202
210
 
203
- server = TCPServer.new "localhost", 3314
211
+ server = TCPServer.new "localhost", 9314
204
212
 
205
213
  lambda {
206
214
  client.send(:connect) { |socket| }
207
215
  }.should raise_error(Riddle::ConnectionError)
208
216
 
209
217
  server.close
210
- end
218
+ end unless RUBY_PLATFORM == 'java' # JRuby doesn't like Timeout
211
219
 
212
220
  context "connection retrying" do
213
221
  it "should try fives time when connection refused" do
@@ -237,7 +245,7 @@ describe Riddle::Client do
237
245
  lambda {
238
246
  client.send(:connect) { |socket| }
239
247
  }.should raise_error(Riddle::ConnectionError)
240
- end
248
+ end unless RUBY_PLATFORM == 'java' # JRuby doesn't like Timeout
241
249
 
242
250
  it "should try each of several server addresses after a connection refused" do
243
251
  client = Riddle::Client.new
@@ -255,6 +263,6 @@ describe Riddle::Client do
255
263
  lambda {
256
264
  client.send(:connect) { |socket| }
257
265
  }.should raise_error(Riddle::ConnectionError)
258
- end
266
+ end unless RUBY_PLATFORM == 'java' # JRuby doesn't like Timeout
259
267
  end
260
268
  end
@@ -1,46 +1,46 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Riddle::Configuration::DistributedIndex do
4
- it "should not be valid without any indexes" do
4
+ it "should not be valid without any indices" do
5
5
  index = Riddle::Configuration::DistributedIndex.new("dist1")
6
6
  index.should_not be_valid
7
7
  end
8
-
9
- it "should be valid with just local indexes" do
8
+
9
+ it "should be valid with just local indices" do
10
10
  index = Riddle::Configuration::DistributedIndex.new("dist1")
11
- index.local_indexes << "local_one"
11
+ index.local_indices << "local_one"
12
12
  index.should be_valid
13
13
  end
14
-
15
- it "should be valid with just remote indexes" do
14
+
15
+ it "should be valid with just remote indices" do
16
16
  index = Riddle::Configuration::DistributedIndex.new("dist1")
17
- index.remote_indexes << Riddle::Configuration::RemoteIndex.new("local", 3312, "remote_one")
17
+ index.remote_indices << Riddle::Configuration::RemoteIndex.new("local", 3312, "remote_one")
18
18
  index.should be_valid
19
19
  end
20
-
20
+
21
21
  it "should be of type 'distributed'" do
22
22
  index = Riddle::Configuration::DistributedIndex.new("dist1")
23
23
  index.type.should == 'distributed'
24
24
  end
25
-
25
+
26
26
  it "should raise a ConfigurationError if rendering when not valid" do
27
27
  index = Riddle::Configuration::DistributedIndex.new("dist1")
28
28
  lambda { index.render }.should raise_error(Riddle::Configuration::ConfigurationError)
29
29
  end
30
-
30
+
31
31
  it "should render correctly if supplied settings are valid" do
32
32
  index = Riddle::Configuration::DistributedIndex.new("dist1")
33
-
34
- index.local_indexes << "test1" << "test1stemmed"
35
- index.remote_indexes <<
33
+
34
+ index.local_indices << "test1" << "test1stemmed"
35
+ index.remote_indices <<
36
36
  Riddle::Configuration::RemoteIndex.new("localhost", 3313, "remote1") <<
37
37
  Riddle::Configuration::RemoteIndex.new("localhost", 3314, "remote2") <<
38
38
  Riddle::Configuration::RemoteIndex.new("localhost", 3314, "remote3")
39
39
  index.agent_blackhole << "testbox:3312:testindex1,testindex2"
40
-
40
+
41
41
  index.agent_connect_timeout = 1000
42
42
  index.agent_query_timeout = 3000
43
-
43
+
44
44
  index.render.should == <<-DISTINDEX
45
45
  index dist1
46
46
  {
@@ -54,12 +54,37 @@ describe Riddle::Configuration::Searchd do
54
54
  searchd.should respond_to("#{setting}=".to_sym)
55
55
  end
56
56
  end
57
-
57
+
58
+ it "should support setting listen to a port number" do
59
+ searchd = Riddle::Configuration::Searchd.new
60
+ searchd.port = 3312
61
+ searchd.pid_file = "file.pid"
62
+ searchd.listen = 3312
63
+
64
+ if Riddle.loaded_version.to_f >= 0.9
65
+ searchd.render.should == <<-SEARCHD
66
+ searchd
67
+ {
68
+ listen = 3312
69
+ pid_file = file.pid
70
+ }
71
+ SEARCHD
72
+ else
73
+ searchd.render.should == <<-SEARCHD
74
+ searchd
75
+ {
76
+ port = 3312
77
+ pid_file = file.pid
78
+ }
79
+ SEARCHD
80
+ end
81
+ end
82
+
58
83
  it "should render a correct configuration with valid settings" do
59
84
  searchd = Riddle::Configuration::Searchd.new
60
85
  searchd.port = 3312
61
86
  searchd.pid_file = "file.pid"
62
-
87
+
63
88
  if Riddle.loaded_version.to_f >= 0.9
64
89
  searchd.render.should == <<-SEARCHD
65
90
  searchd
@@ -78,7 +103,7 @@ searchd
78
103
  SEARCHD
79
104
  end
80
105
  end
81
-
106
+
82
107
  it "should render with a client key if one is provided" do
83
108
  searchd = Riddle::Configuration::Searchd.new
84
109
  searchd.port = 3312