riddle 2.1.0 → 2.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +8 -5
  3. data/Gemfile +10 -0
  4. data/HISTORY +4 -0
  5. data/README.markdown +1 -1
  6. data/lib/riddle.rb +1 -0
  7. data/lib/riddle/0.9.9/configuration/searchd.rb +1 -1
  8. data/lib/riddle/client.rb +4 -1
  9. data/lib/riddle/client/message.rb +15 -14
  10. data/lib/riddle/configuration/parser.rb +1 -0
  11. data/lib/riddle/configuration/section.rb +9 -9
  12. data/lib/riddle/configuration/source.rb +5 -5
  13. data/lib/riddle/query/select.rb +3 -2
  14. data/riddle.gemspec +2 -4
  15. metadata +4 -329
  16. data/spec/fixtures/.gitignore +0 -2
  17. data/spec/fixtures/data/0.9.9/anchor.bin +0 -0
  18. data/spec/fixtures/data/0.9.9/any.bin +0 -0
  19. data/spec/fixtures/data/0.9.9/boolean.bin +0 -0
  20. data/spec/fixtures/data/0.9.9/comment.bin +0 -0
  21. data/spec/fixtures/data/0.9.9/distinct.bin +0 -0
  22. data/spec/fixtures/data/0.9.9/field_weights.bin +0 -0
  23. data/spec/fixtures/data/0.9.9/filter.bin +0 -0
  24. data/spec/fixtures/data/0.9.9/filter_array.bin +0 -0
  25. data/spec/fixtures/data/0.9.9/filter_array_exclude.bin +0 -0
  26. data/spec/fixtures/data/0.9.9/filter_boolean.bin +0 -0
  27. data/spec/fixtures/data/0.9.9/filter_floats.bin +0 -0
  28. data/spec/fixtures/data/0.9.9/filter_floats_exclude.bin +0 -0
  29. data/spec/fixtures/data/0.9.9/filter_range.bin +0 -0
  30. data/spec/fixtures/data/0.9.9/filter_range_exclude.bin +0 -0
  31. data/spec/fixtures/data/0.9.9/group.bin +0 -0
  32. data/spec/fixtures/data/0.9.9/index.bin +0 -0
  33. data/spec/fixtures/data/0.9.9/index_weights.bin +0 -0
  34. data/spec/fixtures/data/0.9.9/keywords_with_hits.bin +0 -0
  35. data/spec/fixtures/data/0.9.9/keywords_without_hits.bin +0 -0
  36. data/spec/fixtures/data/0.9.9/overrides.bin +0 -0
  37. data/spec/fixtures/data/0.9.9/phrase.bin +0 -0
  38. data/spec/fixtures/data/0.9.9/rank_mode.bin +0 -0
  39. data/spec/fixtures/data/0.9.9/select.bin +0 -0
  40. data/spec/fixtures/data/0.9.9/simple.bin +0 -0
  41. data/spec/fixtures/data/0.9.9/sort.bin +0 -0
  42. data/spec/fixtures/data/0.9.9/update_simple.bin +0 -0
  43. data/spec/fixtures/data/0.9.9/weights.bin +0 -0
  44. data/spec/fixtures/data/1.10/anchor.bin +0 -0
  45. data/spec/fixtures/data/1.10/any.bin +0 -0
  46. data/spec/fixtures/data/1.10/boolean.bin +0 -0
  47. data/spec/fixtures/data/1.10/comment.bin +0 -0
  48. data/spec/fixtures/data/1.10/distinct.bin +0 -0
  49. data/spec/fixtures/data/1.10/field_weights.bin +0 -0
  50. data/spec/fixtures/data/1.10/filter.bin +0 -0
  51. data/spec/fixtures/data/1.10/filter_array.bin +0 -0
  52. data/spec/fixtures/data/1.10/filter_array_exclude.bin +0 -0
  53. data/spec/fixtures/data/1.10/filter_boolean.bin +0 -0
  54. data/spec/fixtures/data/1.10/filter_floats.bin +0 -0
  55. data/spec/fixtures/data/1.10/filter_floats_exclude.bin +0 -0
  56. data/spec/fixtures/data/1.10/filter_range.bin +0 -0
  57. data/spec/fixtures/data/1.10/filter_range_exclude.bin +0 -0
  58. data/spec/fixtures/data/1.10/group.bin +0 -0
  59. data/spec/fixtures/data/1.10/index.bin +0 -0
  60. data/spec/fixtures/data/1.10/index_weights.bin +0 -0
  61. data/spec/fixtures/data/1.10/keywords_with_hits.bin +0 -0
  62. data/spec/fixtures/data/1.10/keywords_without_hits.bin +0 -0
  63. data/spec/fixtures/data/1.10/overrides.bin +0 -0
  64. data/spec/fixtures/data/1.10/phrase.bin +0 -0
  65. data/spec/fixtures/data/1.10/rank_mode.bin +0 -0
  66. data/spec/fixtures/data/1.10/select.bin +0 -0
  67. data/spec/fixtures/data/1.10/simple.bin +0 -0
  68. data/spec/fixtures/data/1.10/sort.bin +0 -0
  69. data/spec/fixtures/data/1.10/update_simple.bin +0 -0
  70. data/spec/fixtures/data/1.10/weights.bin +0 -0
  71. data/spec/fixtures/data/2.0.1/anchor.bin +0 -0
  72. data/spec/fixtures/data/2.0.1/any.bin +0 -0
  73. data/spec/fixtures/data/2.0.1/boolean.bin +0 -0
  74. data/spec/fixtures/data/2.0.1/comment.bin +0 -0
  75. data/spec/fixtures/data/2.0.1/distinct.bin +0 -0
  76. data/spec/fixtures/data/2.0.1/field_weights.bin +0 -0
  77. data/spec/fixtures/data/2.0.1/filter.bin +0 -0
  78. data/spec/fixtures/data/2.0.1/filter_array.bin +0 -0
  79. data/spec/fixtures/data/2.0.1/filter_array_exclude.bin +0 -0
  80. data/spec/fixtures/data/2.0.1/filter_boolean.bin +0 -0
  81. data/spec/fixtures/data/2.0.1/filter_floats.bin +0 -0
  82. data/spec/fixtures/data/2.0.1/filter_floats_exclude.bin +0 -0
  83. data/spec/fixtures/data/2.0.1/filter_range.bin +0 -0
  84. data/spec/fixtures/data/2.0.1/filter_range_exclude.bin +0 -0
  85. data/spec/fixtures/data/2.0.1/group.bin +0 -0
  86. data/spec/fixtures/data/2.0.1/index.bin +0 -0
  87. data/spec/fixtures/data/2.0.1/index_weights.bin +0 -0
  88. data/spec/fixtures/data/2.0.1/keywords_with_hits.bin +0 -0
  89. data/spec/fixtures/data/2.0.1/keywords_without_hits.bin +0 -0
  90. data/spec/fixtures/data/2.0.1/overrides.bin +0 -0
  91. data/spec/fixtures/data/2.0.1/phrase.bin +0 -0
  92. data/spec/fixtures/data/2.0.1/rank_mode.bin +0 -0
  93. data/spec/fixtures/data/2.0.1/select.bin +0 -0
  94. data/spec/fixtures/data/2.0.1/simple.bin +0 -0
  95. data/spec/fixtures/data/2.0.1/sort.bin +0 -0
  96. data/spec/fixtures/data/2.0.1/update_simple.bin +0 -0
  97. data/spec/fixtures/data/2.0.1/weights.bin +0 -0
  98. data/spec/fixtures/data/2.1.0/anchor.bin +0 -0
  99. data/spec/fixtures/data/2.1.0/any.bin +0 -0
  100. data/spec/fixtures/data/2.1.0/boolean.bin +0 -0
  101. data/spec/fixtures/data/2.1.0/comment.bin +0 -0
  102. data/spec/fixtures/data/2.1.0/distinct.bin +0 -0
  103. data/spec/fixtures/data/2.1.0/field_weights.bin +0 -0
  104. data/spec/fixtures/data/2.1.0/filter.bin +0 -0
  105. data/spec/fixtures/data/2.1.0/filter_array.bin +0 -0
  106. data/spec/fixtures/data/2.1.0/filter_array_exclude.bin +0 -0
  107. data/spec/fixtures/data/2.1.0/filter_boolean.bin +0 -0
  108. data/spec/fixtures/data/2.1.0/filter_floats.bin +0 -0
  109. data/spec/fixtures/data/2.1.0/filter_floats_exclude.bin +0 -0
  110. data/spec/fixtures/data/2.1.0/filter_range.bin +0 -0
  111. data/spec/fixtures/data/2.1.0/filter_range_exclude.bin +0 -0
  112. data/spec/fixtures/data/2.1.0/group.bin +0 -0
  113. data/spec/fixtures/data/2.1.0/index.bin +0 -0
  114. data/spec/fixtures/data/2.1.0/index_weights.bin +0 -0
  115. data/spec/fixtures/data/2.1.0/keywords_with_hits.bin +0 -0
  116. data/spec/fixtures/data/2.1.0/keywords_without_hits.bin +0 -0
  117. data/spec/fixtures/data/2.1.0/overrides.bin +0 -0
  118. data/spec/fixtures/data/2.1.0/phrase.bin +0 -0
  119. data/spec/fixtures/data/2.1.0/rank_mode.bin +0 -0
  120. data/spec/fixtures/data/2.1.0/select.bin +0 -0
  121. data/spec/fixtures/data/2.1.0/simple.bin +0 -0
  122. data/spec/fixtures/data/2.1.0/sort.bin +0 -0
  123. data/spec/fixtures/data/2.1.0/update_simple.bin +0 -0
  124. data/spec/fixtures/data/2.1.0/weights.bin +0 -0
  125. data/spec/fixtures/data_generator.0.9.8.php +0 -208
  126. data/spec/fixtures/data_generator.0.9.9.php +0 -5
  127. data/spec/fixtures/data_generator.1.10.php +0 -5
  128. data/spec/fixtures/data_generator.2.0.1.php +0 -5
  129. data/spec/fixtures/data_generator.2.1.0.php +0 -5
  130. data/spec/fixtures/data_generator.php +0 -223
  131. data/spec/fixtures/sphinxapi.0.9.8.php +0 -1228
  132. data/spec/fixtures/sphinxapi.0.9.9.php +0 -1646
  133. data/spec/fixtures/sphinxapi.1.10.php +0 -1728
  134. data/spec/fixtures/sphinxapi.2.0.1.php +0 -1731
  135. data/spec/fixtures/sphinxapi.2.1.0.php +0 -1752
  136. data/spec/fixtures/sql/conf.example.yml +0 -3
  137. data/spec/fixtures/sql/data.sql +0 -25000
  138. data/spec/fixtures/sql/data.tsv +0 -25000
  139. data/spec/fixtures/sql/structure.sql +0 -16
  140. data/spec/functional/connection_spec.rb +0 -64
  141. data/spec/functional/escaping_spec.rb +0 -49
  142. data/spec/functional/excerpt_spec.rb +0 -139
  143. data/spec/functional/keywords_spec.rb +0 -40
  144. data/spec/functional/persistance_spec.rb +0 -17
  145. data/spec/functional/search_spec.rb +0 -67
  146. data/spec/functional/status_spec.rb +0 -21
  147. data/spec/functional/update_spec.rb +0 -41
  148. data/spec/riddle/auto_version_spec.rb +0 -95
  149. data/spec/riddle/client_spec.rb +0 -11
  150. data/spec/riddle/configuration_spec.rb +0 -28
  151. data/spec/riddle/controller_spec.rb +0 -39
  152. data/spec/riddle/query/delete_spec.rb +0 -18
  153. data/spec/riddle/query/insert_spec.rb +0 -25
  154. data/spec/riddle/query/select_spec.rb +0 -226
  155. data/spec/riddle/query_spec.rb +0 -97
  156. data/spec/riddle_spec.rb +0 -27
  157. data/spec/spec_helper.rb +0 -34
  158. data/spec/support/binary_fixtures.rb +0 -18
  159. data/spec/support/sphinx.rb +0 -137
  160. data/spec/unit/client_spec.rb +0 -290
  161. data/spec/unit/configuration/common_spec.rb +0 -60
  162. data/spec/unit/configuration/distributed_index_spec.rb +0 -58
  163. data/spec/unit/configuration/index_spec.rb +0 -124
  164. data/spec/unit/configuration/indexer_spec.rb +0 -73
  165. data/spec/unit/configuration/realtime_index_spec.rb +0 -65
  166. data/spec/unit/configuration/searchd_spec.rb +0 -228
  167. data/spec/unit/configuration/source_spec.rb +0 -5
  168. data/spec/unit/configuration/sql_source_spec.rb +0 -137
  169. data/spec/unit/configuration/template_index_spec.rb +0 -91
  170. data/spec/unit/configuration/tsv_source_spec.rb +0 -53
  171. data/spec/unit/configuration/xml_source_spec.rb +0 -51
  172. data/spec/unit/configuration_spec.rb +0 -25
  173. data/spec/unit/filter_spec.rb +0 -38
  174. data/spec/unit/message_spec.rb +0 -94
  175. data/spec/unit/response_spec.rb +0 -64
  176. data/spec/unit/riddle_spec.rb +0 -17
@@ -1,16 +0,0 @@
1
- DROP TABLE IF EXISTS `people`;
2
-
3
- CREATE TABLE `people` (
4
- `id` int(11) NOT NULL auto_increment,
5
- `first_name` varchar(50) NOT NULL,
6
- `middle_initial` varchar(10) NOT NULL,
7
- `last_name` varchar(50) NOT NULL,
8
- `gender` varchar(10) NOT NULL,
9
- `street_address` varchar(200) NOT NULL,
10
- `city` varchar(100) NOT NULL,
11
- `state` varchar(100) NOT NULL,
12
- `postcode` varchar(10) NOT NULL,
13
- `email` varchar(100) NOT NULL,
14
- `birthday` datetime NOT NULL,
15
- PRIMARY KEY (`id`)
16
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8
@@ -1,64 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class RiddleSpecConnectionProcError < StandardError; end
4
-
5
- describe 'Sphinx Client', :live => true do
6
- let(:client) { Riddle::Client.new 'localhost', 9313 }
7
-
8
- after :each do
9
- Riddle::Client.connection = nil
10
- end
11
-
12
- describe '.connection' do
13
- it "should use the given block" do
14
- Riddle::Client.connection = lambda { |client|
15
- TCPSocket.new(client.server, client.port)
16
- }
17
- client.query('smith').should be_kind_of(Hash)
18
- end
19
-
20
- it "should fail with errors from the given block" do
21
- Riddle::Client.connection = lambda { |client|
22
- raise RiddleSpecConnectionProcError
23
- }
24
- lambda { client.query('smith') }.
25
- should raise_error(Riddle::ResponseError)
26
- end
27
- end
28
-
29
- describe '#connection' do
30
- it "use the given block" do
31
- client.connection = lambda { |client|
32
- TCPSocket.new(client.server, client.port)
33
- }
34
- client.query('smith').should be_kind_of(Hash)
35
- end
36
-
37
- it "should fail with errors from the given block" do
38
- client.connection = lambda { |client|
39
- raise RiddleSpecConnectionProcError
40
- }
41
- lambda { client.query('smith') }.
42
- should raise_error(Riddle::ResponseError)
43
- end
44
-
45
- it "should not override OutOfBoundsError instances" do
46
- client.connection = lambda { |client|
47
- raise Riddle::OutOfBoundsError
48
- }
49
- lambda { client.query('smith') }.
50
- should raise_error(Riddle::OutOfBoundsError)
51
- end
52
-
53
- it "should prioritise instance over class connection" do
54
- Riddle::Client.connection = lambda { |client|
55
- raise RiddleSpecConnectionProcError
56
- }
57
- client.connection = lambda { |client|
58
- TCPSocket.new(client.server, client.port)
59
- }
60
-
61
- lambda { client.query('smith') }.should_not raise_error
62
- end
63
- end
64
- end
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe 'SphinxQL escaping', :live => true do
4
- let(:connection) { Mysql2::Client.new :host => '127.0.0.1', :port => 9306 }
5
-
6
- def sphinxql_matching(string)
7
- select = Riddle::Query::Select.new
8
- select.from 'people'
9
- select.matching string
10
- select.to_sql
11
- end
12
-
13
- ['@', "'", '"', '\\"', "\\'", "?"].each do |string|
14
- it "escapes #{string}" do
15
- lambda {
16
- connection.query sphinxql_matching(Riddle::Query.escape(string))
17
- }.should_not raise_error
18
- end
19
- end
20
-
21
- context 'on snippets' do
22
- def snippets_for(text, words = '', options = nil)
23
- snippets_query = Riddle::Query.snippets(text, 'people', words, options)
24
- connection.query(snippets_query).first['snippet']
25
- end
26
-
27
- it 'preserves original text with special SphinxQL escape characters' do
28
- text = 'email: john@example.com (yay!)'
29
- snippets_for(text).should == text
30
- end
31
-
32
- it 'preserves original text with special MySQL escape characters' do
33
- text = "'Dear' Susie\nAlways use {\\LaTeX}"
34
- snippets_for(text).should == text
35
- end
36
-
37
- it 'escapes match delimiters with special SphinxQL escape characters' do
38
- snippets = snippets_for('hello world', 'world',
39
- :before_match => '()|-!', :after_match => '@~"/^$')
40
- snippets.should == 'hello ()|-!world@~"/^$'
41
- end
42
-
43
- it 'escapes match delimiters with special MySQL escape characters' do
44
- snippets = snippets_for('hello world', 'world',
45
- :before_match => "'\"", :after_match => "\n\t\\")
46
- snippets.should == "hello '\"world\n\t\\"
47
- end
48
- end
49
- end unless RUBY_PLATFORM == 'java' || Riddle.loaded_version.to_i < 2
@@ -1,139 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Sphinx Excepts", :live => true do
4
- before :each do
5
- @client = Riddle::Client.new("localhost", 9313)
6
- end
7
-
8
- it "should highlight a single word multiple times in a document" do
9
- @client.excerpts(
10
- :index => "people",
11
- :words => "Mary",
12
- :docs => ["Mary, Mary, quite contrary."]
13
- ).should == [
14
- '<span class="match">Mary</span>, <span class="match">Mary</span>, quite contrary.'
15
- ]
16
- end
17
-
18
- it "should use specified word markers" do
19
- @client.excerpts(
20
- :index => "people",
21
- :words => "Mary",
22
- :docs => ["Mary, Mary, quite contrary."],
23
- :before_match => "<em>",
24
- :after_match => "</em>"
25
- ).should == [
26
- "<em>Mary</em>, <em>Mary</em>, quite contrary."
27
- ]
28
- end
29
-
30
- it "should separate matches that are far apart by an ellipsis by default" do
31
- excerpts = @client.excerpts(
32
- :index => "people",
33
- :words => "Pat",
34
- :docs => [
35
- <<-SENTENCE
36
- This is a really long sentence written by Pat. It has to be over 256
37
- characters long, between keywords. But what is the keyword? Well, I
38
- can't tell you just yet... wait patiently until we've hit the 256 mark.
39
- It'll take a bit longer than you think. We're probably just hitting the
40
- 200 mark at this point. But I think we've now arrived - so I can tell
41
- you what the keyword is. I bet you're really interested in finding out,
42
- yeah? Excerpts are particularly riveting. This keyword, however, is
43
- not. It's just my name: Pat.
44
- SENTENCE
45
- ],
46
- :before_match => "<em>",
47
- :after_match => "</em>"
48
- )
49
-
50
-
51
- case Riddle.loaded_version
52
- when '0.9.9'
53
- excerpts.should == [
54
- <<-SENTENCE
55
- This is a really long sentence written by <em>Pat</em>. It has to be over 256
56
- characters long, between keywords. But what is the &#8230; 're really interested in finding out,
57
- yeah? Excerpts are particularly riveting. This keyword, however, is
58
- not. It's just my name: <em>Pat</em>.
59
- SENTENCE
60
- ]
61
- when '1.10'
62
- excerpts.should == [" &#8230; really long sentence written by <em>Pat</em>. It has to be over &#8230; . This keyword, however, is\nnot. It's just my name: <em>Pat</em> &#8230; "]
63
- when '2.0.1', '2.1.0'
64
- excerpts.should == [" &#8230; really long sentence written by <em>Pat</em>. It has to be over &#8230; . It's just my name: <em>Pat</em>.\n"]
65
- else
66
- excerpts.should == [
67
- <<-SENTENCE
68
- This is a really long sentence written by <em>Pat</em>. It has to be over 256
69
- characters long, between keywords. But what is the keyword? &#8230; interested in finding out,
70
- yeah? Excerpts are particularly riveting. This keyword, however, is
71
- not. It's just my name: <em>Pat</em>.
72
- SENTENCE
73
- ]
74
- end
75
- end
76
-
77
- it "should use the provided separator" do
78
- excerpts = @client.excerpts(
79
- :index => "people",
80
- :words => "Pat",
81
- :docs => [
82
- <<-SENTENCE
83
- This is a really long sentence written by Pat. It has to be over 256
84
- characters long, between keywords. But what is the keyword? Well, I
85
- can't tell you just yet... wait patiently until we've hit the 256 mark.
86
- It'll take a bit longer than you think. We're probably just hitting the
87
- 200 mark at this point. But I think we've now arrived - so I can tell
88
- you what the keyword is. I bet you're really interested in finding out,
89
- yeah? Excerpts are particularly riveting. This keyword, however, is
90
- not. It's just my name: Pat.
91
- SENTENCE
92
- ],
93
- :before_match => "<em>",
94
- :after_match => "</em>",
95
- :chunk_separator => " --- "
96
- )
97
-
98
- case Riddle.loaded_version
99
- when '0.9.9'
100
- excerpts.should == [
101
- <<-SENTENCE
102
- This is a really long sentence written by <em>Pat</em>. It has to be over 256
103
- characters long, between keywords. But what is the --- 're really interested in finding out,
104
- yeah? Excerpts are particularly riveting. This keyword, however, is
105
- not. It's just my name: <em>Pat</em>.
106
- SENTENCE
107
- ]
108
- when '1.10'
109
- excerpts.should == [" --- really long sentence written by <em>Pat</em>. It has to be over --- . This keyword, however, is\nnot. It's just my name: <em>Pat</em> --- "]
110
- when '2.0.1', '2.1.0'
111
- excerpts.should == [" --- really long sentence written by <em>Pat</em>. It has to be over --- . It's just my name: <em>Pat</em>.\n"]
112
- else
113
- excerpts.should == [
114
- <<-SENTENCE
115
- This is a really long sentence written by <em>Pat</em>. It has to be over 256
116
- characters long, between keywords. But what is the keyword? --- interested in finding out,
117
- yeah? Excerpts are particularly riveting. This keyword, however, is
118
- not. It's just my name: <em>Pat</em>.
119
- SENTENCE
120
- ]
121
- end
122
- end
123
-
124
- it "should return multiple results for multiple documents" do
125
- @client.excerpts(
126
- :index => "people",
127
- :words => "Mary",
128
- :docs => [
129
- "Mary, Mary, quite contrary.",
130
- "The epithet \"Bloody Mary\" is associated with a number of historical and fictional women, most notably Queen Mary I of England"
131
- ],
132
- :before_match => "<em>",
133
- :after_match => "</em>"
134
- ).should == [
135
- "<em>Mary</em>, <em>Mary</em>, quite contrary.",
136
- "The epithet \"Bloody <em>Mary</em>\" is associated with a number of historical and fictional women, most notably Queen <em>Mary</em> I of England"
137
- ]
138
- end
139
- end
@@ -1,40 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Sphinx Keywords", :live => true do
4
- before :each do
5
- @client = Riddle::Client.new("localhost", 9313)
6
- end
7
-
8
- it "should return an array of hashes" do
9
- results = @client.keywords("pat", "people")
10
- results.should be_kind_of(Array)
11
-
12
- results.each do |result|
13
- result.should be_kind_of(Hash)
14
- end
15
- end
16
-
17
- it "should have keys for normalised and tokenised versions of the keywords" do
18
- results = @client.keywords("pat", "people")
19
- results.each do |result|
20
- result.keys.should include(:normalised)
21
- result.keys.should include(:tokenised)
22
- end
23
- end
24
-
25
- it "shouldn't have docs or hits keys if not requested" do
26
- results = @client.keywords("pat", "people")
27
- results.each do |result|
28
- result.keys.should_not include(:docs)
29
- result.keys.should_not include(:hits)
30
- end
31
- end
32
-
33
- it "should have docs and hits keys if requested" do
34
- results = @client.keywords("pat", "people", true)
35
- results.each do |result|
36
- result.keys.should include(:docs)
37
- result.keys.should include(:hits)
38
- end
39
- end
40
- end
@@ -1,17 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Sphinx Persistance Connection", :live => true do
4
- before :each do
5
- @client = Riddle::Client.new("localhost", 9313)
6
- end
7
-
8
- it "should raise errors once already opened" do
9
- @client.open
10
- lambda { @client.open }.should raise_error
11
- @client.close
12
- end
13
-
14
- it "should raise errors if closing when already closed" do
15
- lambda { @client.close }.should raise_error
16
- end
17
- end
@@ -1,67 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Sphinx Searches", :live => true do
4
- let(:client) { Riddle::Client.new 'localhost', 9313 }
5
-
6
- it "should return a single hash if a single query" do
7
- client.query("smith").should be_kind_of(Hash)
8
- end
9
-
10
- it "should return an array of hashs if multiple queries are run" do
11
- client.append_query "smith"
12
- client.append_query "jones"
13
- results = client.run
14
- results.should be_kind_of(Array)
15
- results.each { |result| result.should be_kind_of(Hash) }
16
- end
17
-
18
- it "should return an array of matches" do
19
- matches = client.query("smith")[:matches]
20
- matches.should be_kind_of(Array)
21
- matches.each { |match| match.should be_kind_of(Hash) }
22
- end
23
-
24
- it "should return an array of string fields" do
25
- fields = client.query("smith")[:fields]
26
- fields.should be_kind_of(Array)
27
- fields.each { |field| field.should be_kind_of(String) }
28
- end
29
-
30
- it "should return an array of attribute names" do
31
- attributes = client.query("smith")[:attribute_names]
32
- attributes.should be_kind_of(Array)
33
- attributes.each { |a| a.should be_kind_of(String) }
34
- end
35
-
36
- it "should return a hash of attributes" do
37
- attributes = client.query("smith")[:attributes]
38
- attributes.should be_kind_of(Hash)
39
- attributes.each do |key,value|
40
- key.should be_kind_of(String)
41
- value.should be_kind_of(Integer)
42
- end
43
- end
44
-
45
- it "should return the total number of results returned" do
46
- client.query("smith")[:total].should be_kind_of(Integer)
47
- end
48
-
49
- it "should return the total number of results available" do
50
- client.query("smith")[:total_found].should be_kind_of(Integer)
51
- end
52
-
53
- it "should return the time taken for the query as a float" do
54
- client.query("smith")[:time].should be_kind_of(Float)
55
- end
56
-
57
- it "should return a hash of the words from the query, with the number of documents and the number of hits" do
58
- words = client.query("smith victoria")[:words]
59
- words.should be_kind_of(Hash)
60
- words.each do |word,hash|
61
- word.should be_kind_of(String)
62
- hash.should be_kind_of(Hash)
63
- hash[:docs].should be_kind_of(Integer)
64
- hash[:hits].should be_kind_of(Integer)
65
- end
66
- end
67
- end
@@ -1,21 +0,0 @@
1
- require 'spec_helper'
2
-
3
- if Riddle.loaded_version == '0.9.9' || Riddle.loaded_version == '1.10'
4
- describe "Sphinx Status", :live => true do
5
- before :each do
6
- @client = Riddle::Client.new("localhost", 9313)
7
- @status = @client.status
8
- end
9
-
10
- it "should return a hash" do
11
- @status.should be_a(Hash)
12
- end
13
-
14
- it "should include the uptime, connections, and command_search keys" do
15
- # Not checking all values, but ensuring keys are being set correctly
16
- @status[:uptime].should_not be_nil
17
- @status[:connections].should_not be_nil
18
- @status[:command_search].should_not be_nil
19
- end
20
- end
21
- end
@@ -1,41 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe "Sphinx Updates", :live => true do
4
- before :each do
5
- @client = Riddle::Client.new("localhost", 9313)
6
- end
7
-
8
- it "should update a single record appropriately" do
9
- # check existing birthday
10
- result = @client.query("Ellie K Ford")
11
- result[:matches].should_not be_empty
12
- result[:matches].length.should == 1
13
- ellie = result[:matches].first
14
- ellie[:attributes]["birthday"].should == Time.local(1970, 1, 23).to_i
15
-
16
- # make Ellie younger by 6 years
17
- @client.update("people", ["birthday"], {ellie[:doc] => [Time.local(1976, 1, 23).to_i]})
18
-
19
- # check attribute's value
20
- result = @client.query("Ellie K Ford")
21
- result[:matches].should_not be_empty
22
- result[:matches].length.should == 1
23
- ellie = result[:matches].first
24
- ellie[:attributes]["birthday"].should == Time.local(1976, 1, 23).to_i
25
- end
26
-
27
- it "should update multiple records appropriately" do
28
- result = @client.query("Steele")
29
- pairs = {}
30
- result[:matches].each do |match|
31
- pairs[match[:doc]] = [match[:attributes]["birthday"] + (365*24*60*60)]
32
- end
33
-
34
- @client.update "people", ["birthday"], pairs
35
-
36
- result = @client.query("Steele")
37
- result[:matches].each do |match|
38
- match[:attributes]["birthday"].should == pairs[match[:doc]].first
39
- end
40
- end
41
- end