scoped_search 2.7.1 → 3.0.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.
- checksums.yaml +4 -4
- data/.travis.yml +14 -23
- data/CHANGELOG.rdoc +193 -0
- data/CONTRIBUTING.rdoc +38 -0
- data/{Gemfile.activerecord4 → Gemfile.activerecord40} +1 -1
- data/{Gemfile.activerecord2 → Gemfile.activerecord41} +2 -2
- data/README.rdoc +15 -20
- data/app/assets/stylesheets/scoped_search.scss +0 -4
- data/lib/scoped_search.rb +2 -27
- data/lib/scoped_search/auto_complete_builder.rb +40 -34
- data/lib/scoped_search/definition.rb +7 -5
- data/lib/scoped_search/query_builder.rb +3 -34
- data/lib/scoped_search/query_language.rb +0 -3
- data/lib/scoped_search/rails_helper.rb +45 -46
- data/lib/scoped_search/railtie.rb +11 -6
- data/lib/scoped_search/version.rb +1 -1
- data/scoped_search.gemspec +8 -7
- data/spec/integration/api_spec.rb +2 -41
- data/spec/integration/auto_complete_spec.rb +5 -5
- data/spec/integration/key_value_querying_spec.rb +9 -9
- data/spec/integration/ordinal_querying_spec.rb +46 -48
- data/spec/integration/relation_querying_spec.rb +30 -30
- data/spec/integration/set_query_spec.rb +7 -7
- data/spec/integration/string_querying_spec.rb +48 -50
- data/spec/lib/matchers.rb +2 -2
- data/spec/spec_helper.rb +8 -0
- data/spec/unit/ast_spec.rb +3 -3
- metadata +26 -22
- data/init.rb +0 -1
@@ -131,7 +131,7 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
131
131
|
|
132
132
|
context 'value auto complete' do
|
133
133
|
it "should complete values list of values " do
|
134
|
-
Foo.complete_for('explicit = ').should
|
134
|
+
Foo.complete_for('explicit = ').length.should == 1
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should complete values should contain baz" do
|
@@ -179,7 +179,7 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
179
179
|
context 'exceptional search strings' do
|
180
180
|
|
181
181
|
it "query that starts with 'or'" do
|
182
|
-
Foo.complete_for('or ').should
|
182
|
+
Foo.complete_for('or ').length.should == 9
|
183
183
|
end
|
184
184
|
|
185
185
|
it "value completion with quotes" do
|
@@ -201,15 +201,15 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
201
201
|
# the string.
|
202
202
|
context 'dotted options in the completion list' do
|
203
203
|
it "query that starts with space should not include the dotted options" do
|
204
|
-
Foo.complete_for(' ').should
|
204
|
+
Foo.complete_for(' ').length.should == 9
|
205
205
|
end
|
206
206
|
|
207
207
|
it "query that starts with the dotted string should include the dotted options" do
|
208
|
-
Foo.complete_for('bars.').should
|
208
|
+
Foo.complete_for('bars.').length.should == 4
|
209
209
|
end
|
210
210
|
|
211
211
|
it "query that starts with part of the dotted string should include the dotted options" do
|
212
|
-
Foo.complete_for('b').should
|
212
|
+
Foo.complete_for('b').length.should == 4
|
213
213
|
end
|
214
214
|
|
215
215
|
end
|
@@ -31,7 +31,7 @@ require "spec_helper"
|
|
31
31
|
class ::Item < ActiveRecord::Base
|
32
32
|
has_many :facts
|
33
33
|
has_many :keys, :through => :facts
|
34
|
-
|
34
|
+
|
35
35
|
scoped_search :in => :facts, :on => :value, :rename => :facts, :in_key => :keys, :on_key => :name, :complete_value => true
|
36
36
|
end
|
37
37
|
class ::MyItem < ::Item
|
@@ -60,7 +60,7 @@ require "spec_helper"
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "should find all bars with a fact name color and fact value green" do
|
63
|
-
Item.search_for('facts.color = green').should
|
63
|
+
Item.search_for('facts.color = green').length.should == 1
|
64
64
|
end
|
65
65
|
|
66
66
|
it "should find all bars with a fact name color and fact value gold" do
|
@@ -68,31 +68,31 @@ require "spec_helper"
|
|
68
68
|
end
|
69
69
|
|
70
70
|
it "should find all bars with a fact name size and fact value 5" do
|
71
|
-
Item.search_for('facts.size = 5').should
|
71
|
+
Item.search_for('facts.size = 5').length.should == 1
|
72
72
|
end
|
73
73
|
|
74
74
|
it "should find all bars with a fact color green and fact size 5" do
|
75
|
-
Item.search_for('facts.color = green and facts.size = 5').should
|
75
|
+
Item.search_for('facts.color = green and facts.size = 5').length.should == 1
|
76
76
|
end
|
77
77
|
|
78
78
|
it "should find all bars with a fact color gold or green" do
|
79
|
-
Item.search_for('facts.color = gold or facts.color = green').should
|
79
|
+
Item.search_for('facts.color = gold or facts.color = green').length.should == 2
|
80
80
|
end
|
81
81
|
|
82
82
|
it "should find all bars that has size value" do
|
83
|
-
Item.search_for('has facts.size').should
|
83
|
+
Item.search_for('has facts.size').length.should == 1
|
84
84
|
end
|
85
85
|
|
86
86
|
it "should find all bars that has color value" do
|
87
|
-
Item.search_for('has facts.color').should
|
87
|
+
Item.search_for('has facts.color').length.should == 2
|
88
88
|
end
|
89
89
|
|
90
90
|
it "should complete facts names" do
|
91
|
-
Item.complete_for('facts.').should
|
91
|
+
Item.complete_for('facts.').length.should == 2
|
92
92
|
end
|
93
93
|
|
94
94
|
it "should complete values for fact name = color" do
|
95
|
-
Item.complete_for('facts.color = ').should
|
95
|
+
Item.complete_for('facts.color = ').length.should == 2
|
96
96
|
end
|
97
97
|
|
98
98
|
it "should find all bars with a fact name color and fact value gold of descendant class" do
|
@@ -3,7 +3,7 @@ require "spec_helper"
|
|
3
3
|
# These specs will run on all databases that are defined in the spec/database.yml file.
|
4
4
|
# Comment out any databases that you do not have available for testing purposes if needed.
|
5
5
|
ScopedSearch::RSpec::Database.test_databases.each do |db|
|
6
|
-
|
6
|
+
|
7
7
|
describe ScopedSearch, "using a #{db} database" do
|
8
8
|
|
9
9
|
before(:all) do
|
@@ -31,39 +31,39 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
31
31
|
end
|
32
32
|
|
33
33
|
it "should find the record with an exact integer match" do
|
34
|
-
@class.search_for('9').should
|
34
|
+
@class.search_for('9').length.should == 1
|
35
35
|
end
|
36
36
|
|
37
37
|
it "should find the record with an exact decimal match" do
|
38
|
-
@class.search_for('1.23').should
|
38
|
+
@class.search_for('1.23').length.should == 1
|
39
39
|
end
|
40
40
|
|
41
41
|
it "should find the record with an exact integer match with an explicit operator" do
|
42
|
-
@class.search_for('= 9').should
|
42
|
+
@class.search_for('= 9').length.should == 1
|
43
43
|
end
|
44
44
|
|
45
45
|
it "should find the record with an exact integer match with an explicit field name" do
|
46
|
-
@class.search_for('int = 9').should
|
46
|
+
@class.search_for('int = 9').length.should == 1
|
47
47
|
end
|
48
48
|
|
49
49
|
it "should find the record with an exact integer match with an explicit field name" do
|
50
|
-
@class.search_for('int > 8').should
|
50
|
+
@class.search_for('int > 8').length.should == 1
|
51
51
|
end
|
52
52
|
|
53
53
|
it "should find the record with a grater than operator and explicit field" do
|
54
|
-
@class.search_for('int > 9').should
|
54
|
+
@class.search_for('int > 9').length.should == 0
|
55
55
|
end
|
56
56
|
|
57
57
|
it "should find the record with an >= operator with an implicit field name" do
|
58
|
-
@class.search_for('>= 9').should
|
58
|
+
@class.search_for('>= 9').length.should == 1
|
59
59
|
end
|
60
60
|
|
61
61
|
it "should not return the record if only one predicate is true and AND is used (by default)" do
|
62
|
-
@class.search_for('int <= 8, int > 8').should
|
62
|
+
@class.search_for('int <= 8, int > 8').length.should == 0
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should return the record in only one predicate is true and OR is used as operator" do
|
66
|
-
@class.search_for('int <= 8 || int > 8').should
|
66
|
+
@class.search_for('int <= 8 || int > 8').length.should == 1
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
@@ -81,18 +81,16 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
81
81
|
lambda { @class.search_for('unindexed = 10') }.should raise_error(ScopedSearch::Exception)
|
82
82
|
end
|
83
83
|
|
84
|
-
# Before Ruby 2.0 if a string had forced encoding and a nil was extracted from it during
|
84
|
+
# Before Ruby 2.0 if a string had forced encoding and a nil was extracted from it during
|
85
85
|
# any implicit type conversions to a string (+ or << operators) a TypeError would be raised.
|
86
86
|
# https://github.com/wvanbergen/scoped_search/issues/33 for more details
|
87
87
|
it "encoded string should not raise TypeError when querying non-indexed column without a value" do
|
88
|
-
|
89
|
-
|
90
|
-
lambda { @class.search_for(query) }.should_not raise_error
|
91
|
-
end
|
88
|
+
query = 'unindexed ='.force_encoding(Encoding::UTF_8).encode
|
89
|
+
lambda { @class.search_for(query) }.should_not raise_error
|
92
90
|
end
|
93
91
|
|
94
92
|
it "should not return records for which the query matches unindex records" do
|
95
|
-
@class.search_for('= 10').should
|
93
|
+
@class.search_for('= 10').length.should == 0
|
96
94
|
end
|
97
95
|
end
|
98
96
|
|
@@ -109,65 +107,65 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
109
107
|
end
|
110
108
|
|
111
109
|
it "should accept YYYY-MM-DD as date format" do
|
112
|
-
@class.search_for('date = 2009-01-02').should
|
110
|
+
@class.search_for('date = 2009-01-02').length.should == 1
|
113
111
|
end
|
114
112
|
|
115
113
|
it "should accept YY-MM-DD as date format" do
|
116
|
-
@class.search_for('date = 09-01-02').should
|
114
|
+
@class.search_for('date = 09-01-02').length.should == 1
|
117
115
|
end
|
118
116
|
|
119
117
|
if RUBY_VERSION.to_f == 1.8
|
120
118
|
it "should accept MM/DD/YY as date format" do
|
121
|
-
@class.search_for('date = 01/02/09').should
|
119
|
+
@class.search_for('date = 01/02/09').length.should == 1
|
122
120
|
end
|
123
121
|
|
124
122
|
it "should accept MM/DD/YYYY as date format" do
|
125
|
-
@class.search_for('date = 01/02/2009').should
|
123
|
+
@class.search_for('date = 01/02/2009').length.should == 1
|
126
124
|
end
|
127
|
-
end
|
128
|
-
|
125
|
+
end
|
126
|
+
|
129
127
|
it "should accept YYYY/MM/DD as date format" do
|
130
|
-
@class.search_for('date = 2009/01/02').should
|
131
|
-
end
|
128
|
+
@class.search_for('date = 2009/01/02').length.should == 1
|
129
|
+
end
|
132
130
|
|
133
131
|
it "should ignore an invalid date and thus return all records" do
|
134
|
-
@class.search_for('>= 2009-14-57').should
|
132
|
+
@class.search_for('>= 2009-14-57').count.should == 2
|
135
133
|
end
|
136
134
|
|
137
135
|
it "should find the records with a timestamp set some point on the provided date" do
|
138
|
-
@class.search_for('>= 2009-01-02').should
|
136
|
+
@class.search_for('>= 2009-01-02').length.should == 1
|
139
137
|
end
|
140
138
|
|
141
139
|
it "should support full timestamps" do
|
142
|
-
@class.search_for('> "2009-01-02 02:02:02"').should
|
140
|
+
@class.search_for('> "2009-01-02 02:02:02"').length.should == 1
|
143
141
|
end
|
144
142
|
|
145
143
|
it "should find no record with a timestamp in the past" do
|
146
|
-
@class.search_for('< 2009-01-02').should
|
144
|
+
@class.search_for('< 2009-01-02').length.should == 0
|
147
145
|
end
|
148
146
|
|
149
147
|
it "should find all timestamps on a date if no time is given using the = operator" do
|
150
|
-
@class.search_for('= 2009-01-02').should
|
148
|
+
@class.search_for('= 2009-01-02').length.should == 1
|
151
149
|
end
|
152
150
|
|
153
151
|
it "should find all timestamps on a date if no time is when no operator is given" do
|
154
|
-
@class.search_for('2009-01-02').should
|
152
|
+
@class.search_for('2009-01-02').length.should == 1
|
155
153
|
end
|
156
154
|
|
157
155
|
it "should find all timestamps not on a date if no time is given using the != operator" do
|
158
|
-
@class.search_for('!= 2009-01-02').should
|
156
|
+
@class.search_for('!= 2009-01-02').length.should == 0
|
159
157
|
end
|
160
158
|
|
161
159
|
it "should find the records when the date part of a timestamp matches a date" do
|
162
|
-
@class.search_for('>= 2009-01-02').should
|
160
|
+
@class.search_for('>= 2009-01-02').length.should == 1
|
163
161
|
end
|
164
162
|
|
165
163
|
it "should find the record with the timestamp today or in the past" do
|
166
|
-
@class.search_for('<= 2009-01-02').should
|
164
|
+
@class.search_for('<= 2009-01-02').length.should == 1
|
167
165
|
end
|
168
166
|
|
169
167
|
it "should find no record with a timestamp later than today" do
|
170
|
-
@class.search_for('> 2009-01-02').should
|
168
|
+
@class.search_for('> 2009-01-02').length.should == 0
|
171
169
|
end
|
172
170
|
|
173
171
|
end
|
@@ -191,35 +189,35 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
191
189
|
end
|
192
190
|
|
193
191
|
it "should accept Today as date format" do
|
194
|
-
@class.search_for('date = Today').should
|
192
|
+
@class.search_for('date = Today').length.should == 2
|
195
193
|
end
|
196
194
|
|
197
195
|
it "should accept Yesterday as date format" do
|
198
|
-
@class.search_for('date = yesterday').should
|
196
|
+
@class.search_for('date = yesterday').length.should == 1
|
199
197
|
end
|
200
198
|
|
201
199
|
it "should find all timestamps and date from today using the = operator" do
|
202
|
-
@class.search_for('= Today').should
|
200
|
+
@class.search_for('= Today').length.should == 2
|
203
201
|
end
|
204
202
|
|
205
203
|
it "should find all timestamps and date from today no operator" do
|
206
|
-
@class.search_for('Today').should
|
204
|
+
@class.search_for('Today').length.should == 2
|
207
205
|
end
|
208
206
|
|
209
207
|
it "should accept 2 days ago as date format" do
|
210
|
-
@class.search_for('date < "2 days ago"').should
|
208
|
+
@class.search_for('date < "2 days ago"').length.should == 2
|
211
209
|
end
|
212
210
|
|
213
211
|
it "should accept 3 hours ago as date format" do
|
214
|
-
@class.search_for('timestamp > "3 hours ago"').should
|
212
|
+
@class.search_for('timestamp > "3 hours ago"').length.should == 2
|
215
213
|
end
|
216
214
|
|
217
215
|
it "should accept 1 month ago as date format" do
|
218
|
-
@class.search_for('date > "1 month ago"').should
|
216
|
+
@class.search_for('date > "1 month ago"').length.should == 3
|
219
217
|
end
|
220
218
|
|
221
219
|
it "should accept 1 year ago as date format" do
|
222
|
-
@class.search_for('date > "1 year ago"').should
|
220
|
+
@class.search_for('date > "1 year ago"').length.should == 4
|
223
221
|
end
|
224
222
|
|
225
223
|
end
|
@@ -240,27 +238,27 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
240
238
|
end
|
241
239
|
|
242
240
|
it "should not find any record because first equal = 2" do
|
243
|
-
@foo.search_for('first = 4').should
|
241
|
+
@foo.search_for('first = 4').length.should == 0
|
244
242
|
end
|
245
243
|
|
246
244
|
it "should find the record" do
|
247
|
-
@foo.search_for('first = 2').should
|
245
|
+
@foo.search_for('first = 2').length.should == 1
|
248
246
|
end
|
249
247
|
|
250
248
|
it "should not find any record with a grater than operator" do
|
251
|
-
@foo.search_for('first > 9').should
|
249
|
+
@foo.search_for('first > 9').length.should == 0
|
252
250
|
end
|
253
251
|
|
254
252
|
it "should find the record with an >= operator" do
|
255
|
-
@foo.search_for('sec >= 4').should
|
253
|
+
@foo.search_for('sec >= 4').length.should == 1
|
256
254
|
end
|
257
255
|
|
258
256
|
it "should find the record with AND operator is used" do
|
259
|
-
@foo.search_for('sec <= 8 and first = 2').should
|
257
|
+
@foo.search_for('sec <= 8 and first = 2').length.should == 1
|
260
258
|
end
|
261
259
|
|
262
260
|
it "should return the record in if one predicate is true and OR is used as operator" do
|
263
|
-
@foo.search_for('sec <= 8 || first > 8').should
|
261
|
+
@foo.search_for('sec <= 8 || first > 8').length.should == 1
|
264
262
|
end
|
265
263
|
end
|
266
264
|
end
|
@@ -30,14 +30,14 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should find records when searching the subclass" do
|
33
|
-
Sub.search_for('test').should
|
33
|
+
Sub.search_for('test').length.should == 1
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
37
|
context 'querying a :belongs_to relation' do
|
38
38
|
|
39
39
|
before do
|
40
|
-
|
40
|
+
|
41
41
|
# The related class
|
42
42
|
ActiveRecord::Migration.create_table(:hars) { |t| t.string :related }
|
43
43
|
class Har < ActiveRecord::Base; has_many :loos; end
|
@@ -63,15 +63,15 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
63
63
|
end
|
64
64
|
|
65
65
|
it "should find all records with a related bar record containing bar" do
|
66
|
-
Loo.search_for('bar').should
|
66
|
+
Loo.search_for('bar').length.should == 3
|
67
67
|
end
|
68
68
|
|
69
69
|
it "should find all records with a related bar record having an exact value of bar with an explicit field" do
|
70
|
-
Loo.search_for('related = bar').should
|
70
|
+
Loo.search_for('related = bar').length.should == 2
|
71
71
|
end
|
72
72
|
|
73
73
|
it "should find records for which the bar relation is not set using null?" do
|
74
|
-
Loo.search_for('null? related').should
|
74
|
+
Loo.search_for('null? related').length.should == 1
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should find records for which the bar relation is not set using null?" do
|
@@ -111,35 +111,35 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
111
111
|
end
|
112
112
|
|
113
113
|
it "should find all records with at least one bar record containing 'bar'" do
|
114
|
-
::Goo.search_for('bar').should
|
114
|
+
::Goo.search_for('bar').length.should == 2
|
115
115
|
end
|
116
116
|
|
117
117
|
it "should find the only record with at least one bar record having the exact value 'bar'" do
|
118
|
-
::Goo.search_for('= bar').should
|
118
|
+
::Goo.search_for('= bar').length.should == 1
|
119
119
|
end
|
120
120
|
|
121
121
|
it "should find all records for which at least one related bar record exists" do
|
122
|
-
::Goo.search_for('set? related').should
|
122
|
+
::Goo.search_for('set? related').length.should == 2
|
123
123
|
end
|
124
124
|
|
125
125
|
it "should find all records for which none related bar records exist" do
|
126
|
-
::Goo.search_for('null? related').should
|
126
|
+
::Goo.search_for('null? related').length.should == 1
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
it "should find all records which has relation with both related values" do
|
130
|
-
::Goo.search_for('related=bar AND related="another bar"').should
|
130
|
+
::Goo.search_for('related=bar AND related="another bar"').length.should == 1
|
131
131
|
end
|
132
132
|
|
133
133
|
it "should find all records searching with both parent and child fields" do
|
134
|
-
::Goo.search_for('foo bar').should
|
134
|
+
::Goo.search_for('foo bar').length.should == 2
|
135
135
|
end
|
136
136
|
|
137
137
|
it "should find the only record with two Jars" do
|
138
|
-
::Goo.search_for('foo bar "another bar"').should
|
138
|
+
::Goo.search_for('foo bar "another bar"').length.should == 1
|
139
139
|
end
|
140
140
|
|
141
141
|
it "shouldn't find any records as there isn't an intersect" do
|
142
|
-
::Goo.search_for('too another').should
|
142
|
+
::Goo.search_for('too another').length.should == 0
|
143
143
|
end
|
144
144
|
|
145
145
|
end
|
@@ -175,19 +175,19 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
175
175
|
end
|
176
176
|
|
177
177
|
it "should find all records with a car record containing 'bar" do
|
178
|
-
Hoo.search_for('bar').should
|
178
|
+
Hoo.search_for('bar').length.should == 2
|
179
179
|
end
|
180
180
|
|
181
181
|
it "should find the only record with the bar record has the exact value 'bar" do
|
182
|
-
Hoo.search_for('= bar').should
|
182
|
+
Hoo.search_for('= bar').length.should == 1
|
183
183
|
end
|
184
184
|
|
185
185
|
it "should find all records for which the related bar record exists" do
|
186
|
-
Hoo.search_for('set? related').should
|
186
|
+
Hoo.search_for('set? related').length.should == 2
|
187
187
|
end
|
188
188
|
|
189
189
|
it "should find all records for which the related bar record does not exist" do
|
190
|
-
Hoo.search_for('null? related').should
|
190
|
+
Hoo.search_for('null? related').length.should == 1
|
191
191
|
end
|
192
192
|
end
|
193
193
|
|
@@ -228,19 +228,19 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
228
228
|
end
|
229
229
|
|
230
230
|
it "should find all records with at least one associated bar record containing 'bar'" do
|
231
|
-
Joo.search_for('bar').should
|
231
|
+
Joo.search_for('bar').length.should == 2
|
232
232
|
end
|
233
233
|
|
234
234
|
it "should find record which is related to @bar_1" do
|
235
|
-
Joo.search_for('= bar').should
|
235
|
+
Joo.search_for('= bar').length.should == 1
|
236
236
|
end
|
237
237
|
|
238
238
|
it "should find the only record related to @bar_3" do
|
239
|
-
Joo.search_for('last').should
|
239
|
+
Joo.search_for('last').length.should == 1
|
240
240
|
end
|
241
241
|
|
242
242
|
it "should find all records that are related to @bar_2" do
|
243
|
-
Joo.search_for('other').should
|
243
|
+
Joo.search_for('other').length.should == 2
|
244
244
|
end
|
245
245
|
end
|
246
246
|
|
@@ -290,11 +290,11 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
290
290
|
end
|
291
291
|
|
292
292
|
it "should find the two records that are related to a baz record" do
|
293
|
-
Koo.search_for('baz').should
|
293
|
+
Koo.search_for('baz').length.should == 2
|
294
294
|
end
|
295
295
|
|
296
296
|
it "should find the two records that are related to a baz record" do
|
297
|
-
Koo.search_for('related=baz AND related="baz too!"').should
|
297
|
+
Koo.search_for('related=baz AND related="baz too!"').length.should == 1
|
298
298
|
end
|
299
299
|
end
|
300
300
|
|
@@ -339,11 +339,11 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
339
339
|
# This table schema is not supported in activerecord 2, skip the tests
|
340
340
|
if ActiveRecord::VERSION::MAJOR > 2
|
341
341
|
it "should find the three records that are related to a baz record" do
|
342
|
-
Zoo.search_for('baz').should
|
342
|
+
Zoo.search_for('baz').length.should == 3
|
343
343
|
end
|
344
344
|
|
345
345
|
it "should find no records that are related to a baz record" do
|
346
|
-
Zoo.search_for('related=baz AND related="baz too!"').should
|
346
|
+
Zoo.search_for('related=baz AND related="baz too!"').length.should == 0
|
347
347
|
end
|
348
348
|
end
|
349
349
|
end
|
@@ -406,19 +406,19 @@ ScopedSearch::RSpec::Database.test_databases.each do |db|
|
|
406
406
|
end
|
407
407
|
|
408
408
|
it "should find the two records that are related to a tag that contains foo record" do
|
409
|
-
Dog.search_for('foo').should
|
409
|
+
Dog.search_for('foo').length.should == 2
|
410
410
|
end
|
411
411
|
|
412
412
|
it "should find one records that is related to both tags" do
|
413
|
-
Dog.search_for('foo=foo AND foo="foo too"').should
|
413
|
+
Dog.search_for('foo=foo AND foo="foo too"').length.should == 1
|
414
414
|
end
|
415
415
|
|
416
416
|
it "should find the two tags that are related to a dog record" do
|
417
|
-
Tag.search_for('dog=baz').should
|
417
|
+
Tag.search_for('dog=baz').length.should == 2
|
418
418
|
end
|
419
419
|
|
420
420
|
it "should find the 3 tags that are related to dogs record" do
|
421
|
-
Tag.search_for('baz').should
|
421
|
+
Tag.search_for('baz').length.should == 3
|
422
422
|
end
|
423
423
|
|
424
424
|
end
|