DrMark-thinking-sphinx 0.9.9 → 1.1.6
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.
- data/README +64 -2
- data/lib/thinking_sphinx.rb +88 -11
- data/lib/thinking_sphinx/active_record.rb +136 -21
- data/lib/thinking_sphinx/active_record/delta.rb +43 -62
- data/lib/thinking_sphinx/active_record/has_many_association.rb +1 -1
- data/lib/thinking_sphinx/active_record/search.rb +7 -0
- data/lib/thinking_sphinx/adapters/abstract_adapter.rb +42 -0
- data/lib/thinking_sphinx/adapters/mysql_adapter.rb +54 -0
- data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +130 -0
- data/lib/thinking_sphinx/association.rb +17 -0
- data/lib/thinking_sphinx/attribute.rb +171 -97
- data/lib/thinking_sphinx/collection.rb +126 -2
- data/lib/thinking_sphinx/configuration.rb +120 -171
- data/lib/thinking_sphinx/core/string.rb +15 -0
- data/lib/thinking_sphinx/deltas.rb +27 -0
- data/lib/thinking_sphinx/deltas/datetime_delta.rb +50 -0
- data/lib/thinking_sphinx/deltas/default_delta.rb +67 -0
- data/lib/thinking_sphinx/deltas/delayed_delta.rb +25 -0
- data/lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb +24 -0
- data/lib/thinking_sphinx/deltas/delayed_delta/flag_as_deleted_job.rb +27 -0
- data/lib/thinking_sphinx/deltas/delayed_delta/job.rb +26 -0
- data/lib/thinking_sphinx/facet.rb +58 -0
- data/lib/thinking_sphinx/facet_collection.rb +60 -0
- data/lib/thinking_sphinx/field.rb +18 -52
- data/lib/thinking_sphinx/index.rb +246 -199
- data/lib/thinking_sphinx/index/builder.rb +85 -16
- data/lib/thinking_sphinx/rails_additions.rb +85 -5
- data/lib/thinking_sphinx/search.rb +459 -190
- data/lib/thinking_sphinx/tasks.rb +128 -0
- data/spec/unit/thinking_sphinx/active_record/delta_spec.rb +53 -124
- data/spec/unit/thinking_sphinx/active_record/has_many_association_spec.rb +2 -2
- data/spec/unit/thinking_sphinx/active_record_spec.rb +110 -30
- data/spec/unit/thinking_sphinx/attribute_spec.rb +16 -149
- data/spec/unit/thinking_sphinx/collection_spec.rb +14 -0
- data/spec/unit/thinking_sphinx/configuration_spec.rb +54 -412
- data/spec/unit/thinking_sphinx/core/string_spec.rb +9 -0
- data/spec/unit/thinking_sphinx/field_spec.rb +0 -79
- data/spec/unit/thinking_sphinx/index/builder_spec.rb +1 -29
- data/spec/unit/thinking_sphinx/index/faux_column_spec.rb +1 -39
- data/spec/unit/thinking_sphinx/index_spec.rb +78 -226
- data/spec/unit/thinking_sphinx/search_spec.rb +29 -228
- data/spec/unit/thinking_sphinx_spec.rb +23 -19
- data/tasks/distribution.rb +48 -0
- data/tasks/rails.rake +1 -0
- data/tasks/testing.rb +86 -0
- data/vendor/after_commit/LICENSE +20 -0
- data/vendor/after_commit/README +16 -0
- data/vendor/after_commit/Rakefile +22 -0
- data/vendor/after_commit/init.rb +8 -0
- data/vendor/after_commit/lib/after_commit.rb +45 -0
- data/vendor/after_commit/lib/after_commit/active_record.rb +114 -0
- data/vendor/after_commit/lib/after_commit/connection_adapters.rb +103 -0
- data/vendor/after_commit/test/after_commit_test.rb +53 -0
- data/vendor/delayed_job/lib/delayed/job.rb +251 -0
- data/vendor/delayed_job/lib/delayed/message_sending.rb +7 -0
- data/vendor/delayed_job/lib/delayed/performable_method.rb +55 -0
- data/vendor/delayed_job/lib/delayed/worker.rb +54 -0
- data/{lib → vendor/riddle/lib}/riddle.rb +9 -5
- data/{lib → vendor/riddle/lib}/riddle/client.rb +6 -26
- data/{lib → vendor/riddle/lib}/riddle/client/filter.rb +10 -1
- data/{lib → vendor/riddle/lib}/riddle/client/message.rb +0 -0
- data/{lib → vendor/riddle/lib}/riddle/client/response.rb +0 -0
- data/vendor/riddle/lib/riddle/configuration.rb +33 -0
- data/vendor/riddle/lib/riddle/configuration/distributed_index.rb +48 -0
- data/vendor/riddle/lib/riddle/configuration/index.rb +142 -0
- data/vendor/riddle/lib/riddle/configuration/indexer.rb +19 -0
- data/vendor/riddle/lib/riddle/configuration/remote_index.rb +17 -0
- data/vendor/riddle/lib/riddle/configuration/searchd.rb +25 -0
- data/vendor/riddle/lib/riddle/configuration/section.rb +37 -0
- data/vendor/riddle/lib/riddle/configuration/source.rb +23 -0
- data/vendor/riddle/lib/riddle/configuration/sql_source.rb +34 -0
- data/vendor/riddle/lib/riddle/configuration/xml_source.rb +28 -0
- data/vendor/riddle/lib/riddle/controller.rb +44 -0
- metadata +63 -10
- data/lib/test.rb +0 -46
- data/tasks/thinking_sphinx_tasks.rake +0 -1
- data/tasks/thinking_sphinx_tasks.rb +0 -86
@@ -3,17 +3,18 @@ require 'will_paginate/collection'
|
|
3
3
|
|
4
4
|
describe ThinkingSphinx::Search do
|
5
5
|
describe "search method" do
|
6
|
-
it "should actually have some tests"
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "search_for_id method" do
|
10
6
|
before :each do
|
11
7
|
@client = Riddle::Client.stub_instance(
|
12
8
|
:filters => [],
|
13
9
|
:filters= => true,
|
14
10
|
:id_range= => true,
|
11
|
+
:sort_mode => :asc,
|
12
|
+
:limit => 5,
|
13
|
+
:offset= => 0,
|
14
|
+
:sort_mode= => true,
|
15
15
|
:query => {
|
16
|
-
:matches => []
|
16
|
+
:matches => [],
|
17
|
+
:total => 50
|
17
18
|
}
|
18
19
|
)
|
19
20
|
|
@@ -23,236 +24,36 @@ describe ThinkingSphinx::Search do
|
|
23
24
|
)
|
24
25
|
end
|
25
26
|
|
26
|
-
|
27
|
-
ThinkingSphinx::Search.search_for_id 42, "an_index"
|
28
|
-
|
29
|
-
@client.should have_received(:id_range=).with(42..42)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "should query on the given index" do
|
33
|
-
ThinkingSphinx::Search.search_for_id 42, "an_index"
|
34
|
-
|
35
|
-
@client.should have_received(:query).with("", "an_index")
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should return true if a record is returned" do
|
39
|
-
@client.stub_method(:query => {
|
40
|
-
:matches => [24]
|
41
|
-
})
|
42
|
-
|
43
|
-
ThinkingSphinx::Search.search_for_id(42, "an_index").should be_true
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should return false if no records are returned" do
|
47
|
-
ThinkingSphinx::Search.search_for_id(42, "an_index").should be_false
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
describe "instance_from_result method" do
|
52
|
-
before :each do
|
53
|
-
Person.stub_method(:find => true)
|
54
|
-
ThinkingSphinx::Search.stub_method(:class_from_crc => Person)
|
55
|
-
end
|
56
|
-
|
57
|
-
after :each do
|
58
|
-
Person.unstub_method(:find)
|
59
|
-
ThinkingSphinx::Search.unstub_method(:class_from_crc)
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should honour the :include option" do
|
63
|
-
ThinkingSphinx::Search.send(
|
64
|
-
:instance_from_result,
|
65
|
-
{
|
66
|
-
:doc => 1, :attributes => {
|
67
|
-
"sphinx_internal_id" => 2, "class_crc" => 123
|
68
|
-
}
|
69
|
-
},
|
70
|
-
{:include => :assoc}
|
71
|
-
)
|
72
|
-
|
73
|
-
Person.should have_received(:find).with(2, :include => :assoc, :select => nil)
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should honour the :select option" do
|
77
|
-
ThinkingSphinx::Search.send(
|
78
|
-
:instance_from_result,
|
79
|
-
{
|
80
|
-
:doc => 1, :attributes => {
|
81
|
-
"sphinx_internal_id" => 2, "class_crc" => 123
|
82
|
-
}
|
83
|
-
},
|
84
|
-
{:select => :columns}
|
85
|
-
)
|
86
|
-
|
87
|
-
Person.should have_received(:find).with(2, :include => nil, :select => :columns)
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
|
-
describe "instances_from_results method" do
|
93
|
-
before :each do
|
94
|
-
@person_a = Person.stub_instance
|
95
|
-
@person_b = Person.stub_instance
|
96
|
-
@person_c = Person.stub_instance
|
97
|
-
|
98
|
-
@person_a.stub_method(:attributes => [])
|
99
|
-
@person_b.stub_method(:attributes => [])
|
100
|
-
@person_c.stub_method(:attributes => [])
|
101
|
-
|
102
|
-
@results = [
|
103
|
-
{:attributes => {"sphinx_internal_id" => @person_a.id}},
|
104
|
-
{:attributes => {"sphinx_internal_id" => @person_b.id}},
|
105
|
-
{:attributes => {"sphinx_internal_id" => @person_c.id}}
|
106
|
-
]
|
27
|
+
describe ":star option" do
|
107
28
|
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
end
|
113
|
-
|
114
|
-
after :each do
|
115
|
-
Person.unstub_method(:find)
|
116
|
-
ThinkingSphinx::Search.unstub_method(:instance_from_result)
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should pass calls to instance_from_result if no class given" do
|
120
|
-
ThinkingSphinx::Search.send(
|
121
|
-
:instances_from_results, @results
|
122
|
-
)
|
29
|
+
it "should not apply by default" do
|
30
|
+
ThinkingSphinx::Search.search "foo bar"
|
31
|
+
@client.should have_received(:query).with("foo bar")
|
32
|
+
end
|
123
33
|
|
124
|
-
|
125
|
-
{
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
ThinkingSphinx::Search.should have_received(:instance_from_result).with(
|
131
|
-
{:attributes => {"sphinx_internal_id" => @person_c.id}}, {}
|
132
|
-
)
|
133
|
-
end
|
34
|
+
it "should apply when passed, and handle full extended syntax" do
|
35
|
+
input = %{a b* c (d | e) 123 5&6 (f_f g) !h "i j" "k l"~10 "m n"/3 @o p -(q|r)}
|
36
|
+
expected = %{*a* b* *c* (*d* | *e*) *123* *5*&*6* (*f_f* *g*) !*h* "i j" "k l"~10 "m n"/3 @o *p* -(*q*|*r*)}
|
37
|
+
ThinkingSphinx::Search.search input, :star => true
|
38
|
+
@client.should have_received(:query).with(expected)
|
39
|
+
end
|
134
40
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
Person.should have_received(:find).with(
|
141
|
-
:all,
|
142
|
-
:conditions => {:id => [@person_a.id, @person_b.id, @person_c.id]},
|
143
|
-
:include => nil,
|
144
|
-
:select => nil
|
145
|
-
)
|
146
|
-
end
|
147
|
-
|
148
|
-
it "should honour the :include option" do
|
149
|
-
ThinkingSphinx::Search.send(
|
150
|
-
:instances_from_results, @results, {:include => :something}, Person
|
151
|
-
)
|
152
|
-
|
153
|
-
Person.should have_received(:find).with(
|
154
|
-
:all,
|
155
|
-
:conditions => {:id => [@person_a.id, @person_b.id, @person_c.id]},
|
156
|
-
:include => :something,
|
157
|
-
:select => nil
|
158
|
-
)
|
159
|
-
end
|
41
|
+
it "should default to /\w+/ as token" do
|
42
|
+
ThinkingSphinx::Search.search "foo@bar.com", :star => true
|
43
|
+
@client.should have_received(:query).with("*foo*@*bar*.*com*")
|
44
|
+
end
|
160
45
|
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
Person.should have_received(:find).with(
|
167
|
-
:all,
|
168
|
-
:conditions => {:id => [@person_a.id, @person_b.id, @person_c.id]},
|
169
|
-
:include => nil,
|
170
|
-
:select => :fields
|
171
|
-
)
|
172
|
-
end
|
46
|
+
it "should honour custom token" do
|
47
|
+
ThinkingSphinx::Search.search "foo@bar.com -foo-bar", :star => /[\w@.-]+/u
|
48
|
+
@client.should have_received(:query).with("*foo@bar.com* -*foo-bar*")
|
49
|
+
end
|
173
50
|
|
174
|
-
it "should sort the objects the same as the result set" do
|
175
|
-
ThinkingSphinx::Search.send(
|
176
|
-
:instances_from_results, @results, {:select => :fields}, Person
|
177
|
-
).should == [@person_a, @person_b, @person_c]
|
178
|
-
end
|
179
|
-
|
180
|
-
it "should run the append distances function when distance_name is passed" do
|
181
|
-
ThinkingSphinx::Search.stub_method(:append_distances => @results)
|
182
|
-
|
183
|
-
ThinkingSphinx::Search.send(
|
184
|
-
:instances_from_results, @results, {:distance_name => 'distance'}, Person
|
185
|
-
)
|
186
|
-
|
187
|
-
Person.should have_received(:find).with(
|
188
|
-
:all,
|
189
|
-
:conditions => {:id => [@person_a.id, @person_b.id, @person_c.id]},
|
190
|
-
:include => nil,
|
191
|
-
:select => nil
|
192
|
-
)
|
193
51
|
end
|
194
|
-
|
195
|
-
it "should have a test for the append_distances function"
|
196
52
|
end
|
197
|
-
|
198
|
-
describe "count method" do
|
199
|
-
before :each do
|
200
|
-
@client = Riddle::Client.stub_instance(
|
201
|
-
:filters => [],
|
202
|
-
:filters= => true,
|
203
|
-
:id_range= => true,
|
204
|
-
:sort_mode => :asc,
|
205
|
-
:limit => 5,
|
206
|
-
:offset= => 0,
|
207
|
-
:sort_mode= => true,
|
208
|
-
:query => {
|
209
|
-
:matches => [],
|
210
|
-
:total => 50
|
211
|
-
}
|
212
|
-
)
|
213
|
-
|
214
|
-
ThinkingSphinx::Search.stub_methods(
|
215
|
-
:client_from_options => @client,
|
216
|
-
:search_conditions => ["", []]
|
217
|
-
)
|
218
|
-
end
|
53
|
+
end
|
219
54
|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
end
|
224
|
-
|
225
|
-
describe "search result" do
|
226
|
-
before :each do
|
227
|
-
@results = ThinkingSphinx::Search.search "nothing will match this"
|
228
|
-
end
|
229
|
-
|
230
|
-
it "should respond to previous_page" do
|
231
|
-
@results.should respond_to(:previous_page)
|
232
|
-
end
|
233
|
-
|
234
|
-
it "should respond to next_page" do
|
235
|
-
@results.should respond_to(:next_page)
|
236
|
-
end
|
237
|
-
|
238
|
-
it "should respond to current_page" do
|
239
|
-
@results.should respond_to(:current_page)
|
240
|
-
end
|
241
|
-
|
242
|
-
it "should respond to total_pages" do
|
243
|
-
@results.should respond_to(:total_pages)
|
244
|
-
end
|
245
|
-
|
246
|
-
it "should respond to total_entries" do
|
247
|
-
@results.should respond_to(:total_entries)
|
248
|
-
end
|
249
|
-
|
250
|
-
it "should respond to offset" do
|
251
|
-
@results.should respond_to(:offset)
|
252
|
-
end
|
253
|
-
|
254
|
-
it "should be a subclass of Array" do
|
255
|
-
@results.should be_kind_of(Array)
|
256
|
-
end
|
55
|
+
describe ThinkingSphinx::Search, "playing nice with Search model" do
|
56
|
+
it "should not conflict with models called Search" do
|
57
|
+
lambda { Search.find(:all) }.should_not raise_error
|
257
58
|
end
|
258
59
|
end
|
@@ -1,12 +1,6 @@
|
|
1
1
|
require 'spec/spec_helper'
|
2
2
|
|
3
3
|
describe ThinkingSphinx do
|
4
|
-
describe "indexed_models methods" do
|
5
|
-
it "should contain all the names of models that have indexes" do
|
6
|
-
ThinkingSphinx.indexed_models.should include("Person")
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
4
|
it "should define indexes by default" do
|
11
5
|
ThinkingSphinx.define_indexes?.should be_true
|
12
6
|
end
|
@@ -58,12 +52,24 @@ describe ThinkingSphinx do
|
|
58
52
|
end
|
59
53
|
|
60
54
|
describe "use_group_by_shortcut? method" do
|
61
|
-
|
62
|
-
|
55
|
+
before :each do
|
56
|
+
adapter = defined?(JRUBY_VERSION) ? :JdbcAdapter : :MysqlAdapter
|
57
|
+
unless ::ActiveRecord::ConnectionAdapters.const_defined?(adapter)
|
58
|
+
pending "No MySQL"
|
59
|
+
return
|
60
|
+
end
|
61
|
+
|
62
|
+
@connection = ::ActiveRecord::ConnectionAdapters.const_get(adapter).stub_instance(
|
63
|
+
:select_all => true,
|
64
|
+
:config => {:adapter => defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql'}
|
65
|
+
)
|
66
|
+
::ActiveRecord::Base.stub_method(
|
67
|
+
:connection => @connection
|
68
|
+
)
|
63
69
|
end
|
64
70
|
|
65
71
|
it "should return true if no ONLY_FULL_GROUP_BY" do
|
66
|
-
|
72
|
+
@connection.stub_method(
|
67
73
|
:select_all => {:a => "OTHER SETTINGS"}
|
68
74
|
)
|
69
75
|
|
@@ -71,7 +77,7 @@ describe ThinkingSphinx do
|
|
71
77
|
end
|
72
78
|
|
73
79
|
it "should return true if NULL value" do
|
74
|
-
|
80
|
+
@connection.stub_method(
|
75
81
|
:select_all => {:a => nil}
|
76
82
|
)
|
77
83
|
|
@@ -79,7 +85,7 @@ describe ThinkingSphinx do
|
|
79
85
|
end
|
80
86
|
|
81
87
|
it "should return false if ONLY_FULL_GROUP_BY is set" do
|
82
|
-
|
88
|
+
@connection.stub_method(
|
83
89
|
:select_all => {:a => "OTHER SETTINGS,ONLY_FULL_GROUP_BY,blah"}
|
84
90
|
)
|
85
91
|
|
@@ -87,7 +93,7 @@ describe ThinkingSphinx do
|
|
87
93
|
end
|
88
94
|
|
89
95
|
it "should return false if ONLY_FULL_GROUP_BY is set in any of the values" do
|
90
|
-
|
96
|
+
@connection.stub_method(
|
91
97
|
:select_all => {
|
92
98
|
:a => "OTHER SETTINGS",
|
93
99
|
:b => "ONLY_FULL_GROUP_BY"
|
@@ -99,21 +105,19 @@ describe ThinkingSphinx do
|
|
99
105
|
|
100
106
|
describe "if not using MySQL" do
|
101
107
|
before :each do
|
102
|
-
|
108
|
+
adapter = defined?(JRUBY_VERSION) ? :JdbcAdapter : :PostgreSQLAdapter
|
109
|
+
unless ::ActiveRecord::ConnectionAdapters.const_defined?(adapter)
|
103
110
|
pending "No PostgreSQL"
|
104
111
|
return
|
105
112
|
end
|
106
|
-
@connection = ::ActiveRecord::ConnectionAdapters
|
107
|
-
:select_all => true
|
113
|
+
@connection = ::ActiveRecord::ConnectionAdapters.const_get(adapter).stub_instance(
|
114
|
+
:select_all => true,
|
115
|
+
:config => {:adapter => defined?(JRUBY_VERSION) ? 'jdbcpostgresql' : 'postgresql'}
|
108
116
|
)
|
109
117
|
::ActiveRecord::Base.stub_method(
|
110
118
|
:connection => @connection
|
111
119
|
)
|
112
120
|
end
|
113
|
-
|
114
|
-
after :each do
|
115
|
-
::ActiveRecord::Base.unstub_method(:connection)
|
116
|
-
end
|
117
121
|
|
118
122
|
it "should return false" do
|
119
123
|
ThinkingSphinx.use_group_by_shortcut?.should be_false
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'rake/rdoctask'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
|
4
|
+
$LOAD_PATH.unshift File.dirname(__FILE__) + '/../lib'
|
5
|
+
require 'thinking_sphinx'
|
6
|
+
|
7
|
+
desc 'Generate documentation'
|
8
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
9
|
+
rdoc.rdoc_dir = 'rdoc'
|
10
|
+
rdoc.title = 'Thinking Sphinx - ActiveRecord Sphinx Plugin'
|
11
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
12
|
+
rdoc.rdoc_files.include('README')
|
13
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
14
|
+
end
|
15
|
+
|
16
|
+
spec = Gem::Specification.new do |s|
|
17
|
+
s.name = "thinking-sphinx"
|
18
|
+
s.version = ThinkingSphinx::Version::String
|
19
|
+
s.summary = "A concise and easy-to-use Ruby library that connects ActiveRecord to the Sphinx search daemon, managing configuration, indexing and searching."
|
20
|
+
s.description = "A concise and easy-to-use Ruby library that connects ActiveRecord to the Sphinx search daemon, managing configuration, indexing and searching."
|
21
|
+
s.author = "Pat Allan"
|
22
|
+
s.email = "pat@freelancing-gods.com"
|
23
|
+
s.homepage = "http://ts.freelancing-gods.com"
|
24
|
+
s.has_rdoc = true
|
25
|
+
s.rdoc_options << "--title" << "Thinking Sphinx -- Rails/Merb Sphinx Plugin" <<
|
26
|
+
"--line-numbers"
|
27
|
+
s.rubyforge_project = "thinking-sphinx"
|
28
|
+
s.test_files = FileList["spec/**/*_spec.rb"]
|
29
|
+
s.files = FileList[
|
30
|
+
"lib/**/*.rb",
|
31
|
+
"LICENCE",
|
32
|
+
"README",
|
33
|
+
"tasks/**/*.rb",
|
34
|
+
"tasks/**/*.rake",
|
35
|
+
"vendor/**/*"
|
36
|
+
]
|
37
|
+
end
|
38
|
+
|
39
|
+
Rake::GemPackageTask.new(spec) do |p|
|
40
|
+
p.gem_spec = spec
|
41
|
+
p.need_tar = true
|
42
|
+
p.need_zip = true
|
43
|
+
end
|
44
|
+
|
45
|
+
desc "Build gemspec file"
|
46
|
+
task :build do
|
47
|
+
File.open('thinking-sphinx.gemspec', 'w') { |f| f.write spec.to_ruby }
|
48
|
+
end
|
data/tasks/rails.rake
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), '/../lib/thinking_sphinx/tasks')
|
data/tasks/testing.rb
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'spec/rake/spectask'
|
3
|
+
require 'cucumber/rake/task'
|
4
|
+
|
5
|
+
desc "Run the specs under spec"
|
6
|
+
Spec::Rake::SpecTask.new do |t|
|
7
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
8
|
+
t.spec_opts << "-c"
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Run all feature-set configurations"
|
12
|
+
task :features do |t|
|
13
|
+
puts "rake features:mysql"
|
14
|
+
system "rake features:mysql"
|
15
|
+
puts "rake features:postgresql"
|
16
|
+
system "rake features:postgresql"
|
17
|
+
end
|
18
|
+
|
19
|
+
namespace :features do
|
20
|
+
def add_task(name, description)
|
21
|
+
Cucumber::Rake::Task.new(name, description) do |t|
|
22
|
+
t.cucumber_opts = "--format pretty"
|
23
|
+
t.step_pattern = [
|
24
|
+
"features/support/env",
|
25
|
+
"features/support/db/#{name}",
|
26
|
+
"features/support/db/active_record",
|
27
|
+
"features/support/post_database",
|
28
|
+
"features/step_definitions/**.rb"
|
29
|
+
]
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
add_task :mysql, "Run feature-set against MySQL"
|
34
|
+
add_task :postgresql, "Run feature-set against PostgreSQL"
|
35
|
+
end
|
36
|
+
|
37
|
+
desc "Generate RCov reports"
|
38
|
+
Spec::Rake::SpecTask.new(:rcov) do |t|
|
39
|
+
t.libs << 'lib'
|
40
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
41
|
+
t.rcov = true
|
42
|
+
t.rcov_opts = ['--exclude', 'spec', '--exclude', 'gems', '--exclude', 'riddle']
|
43
|
+
end
|
44
|
+
|
45
|
+
namespace :rcov do
|
46
|
+
def add_task(name, description)
|
47
|
+
Cucumber::Rake::Task.new(name, description) do |t|
|
48
|
+
t.cucumber_opts = "--format pretty"
|
49
|
+
t.step_pattern = [
|
50
|
+
"features/support/env",
|
51
|
+
"features/support/db/#{name}",
|
52
|
+
"features/support/db/active_record",
|
53
|
+
"features/support/post_database",
|
54
|
+
"features/step_definitions/**.rb"
|
55
|
+
]
|
56
|
+
t.rcov = true
|
57
|
+
t.rcov_opts = [
|
58
|
+
'--exclude', 'spec',
|
59
|
+
'--exclude', 'gems',
|
60
|
+
'--exclude', 'riddle',
|
61
|
+
'--exclude', 'features'
|
62
|
+
]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
add_task :mysql, "Run feature-set against MySQL with rcov"
|
67
|
+
add_task :postgresql, "Run feature-set against PostgreSQL with rcov"
|
68
|
+
end
|
69
|
+
|
70
|
+
desc "Build cucumber.yml file"
|
71
|
+
task :cucumber_defaults do
|
72
|
+
default_requires = %w(
|
73
|
+
--require features/support/env.rb
|
74
|
+
--require features/support/db/mysql.rb
|
75
|
+
--require features/support/db/active_record.rb
|
76
|
+
--require features/support/post_database.rb
|
77
|
+
).join(" ")
|
78
|
+
|
79
|
+
step_definitions = FileList["features/step_definitions/**.rb"].collect { |path|
|
80
|
+
"--require #{path}"
|
81
|
+
}.join(" ")
|
82
|
+
|
83
|
+
File.open('cucumber.yml', 'w') { |f|
|
84
|
+
f.write "default: \"#{default_requires} #{step_definitions}\""
|
85
|
+
}
|
86
|
+
end
|