thinking-sphinx 3.2.0 → 3.3.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 +6 -2
- data/Appraisals +13 -0
- data/Gemfile +2 -1
- data/HISTORY +19 -0
- data/README.textile +3 -2
- data/gemfiles/rails_3_2.gemfile +2 -1
- data/gemfiles/rails_4_0.gemfile +2 -1
- data/gemfiles/rails_4_1.gemfile +2 -1
- data/gemfiles/rails_4_2.gemfile +2 -1
- data/gemfiles/rails_5_0.gemfile +12 -0
- data/lib/thinking_sphinx.rb +2 -0
- data/lib/thinking_sphinx/active_record/attribute/type.rb +17 -3
- data/lib/thinking_sphinx/active_record/callbacks/delta_callbacks.rb +12 -4
- data/lib/thinking_sphinx/active_record/database_adapters.rb +1 -1
- data/lib/thinking_sphinx/active_record/sql_builder/query.rb +4 -0
- data/lib/thinking_sphinx/active_record/sql_source.rb +1 -1
- data/lib/thinking_sphinx/configuration.rb +3 -2
- data/lib/thinking_sphinx/connection.rb +23 -10
- data/lib/thinking_sphinx/deltas/index_job.rb +6 -2
- data/lib/thinking_sphinx/errors.rb +25 -0
- data/lib/thinking_sphinx/middlewares/active_record_translator.rb +14 -2
- data/lib/thinking_sphinx/railtie.rb +1 -1
- data/lib/thinking_sphinx/rake_interface.rb +71 -23
- data/lib/thinking_sphinx/real_time/callbacks/real_time_callbacks.rb +15 -7
- data/lib/thinking_sphinx/real_time/populator.rb +3 -3
- data/lib/thinking_sphinx/tasks.rb +7 -8
- data/lib/thinking_sphinx/wildcard.rb +1 -1
- data/spec/acceptance/association_scoping_spec.rb +5 -5
- data/spec/acceptance/attribute_access_spec.rb +4 -4
- data/spec/acceptance/attribute_updates_spec.rb +3 -3
- data/spec/acceptance/batch_searching_spec.rb +4 -4
- data/spec/acceptance/big_integers_spec.rb +6 -6
- data/spec/acceptance/connection_spec.rb +23 -0
- data/spec/acceptance/excerpts_spec.rb +8 -8
- data/spec/acceptance/facets_spec.rb +13 -13
- data/spec/acceptance/geosearching_spec.rb +8 -8
- data/spec/acceptance/grouping_by_attributes_spec.rb +10 -10
- data/spec/acceptance/index_options_spec.rb +16 -16
- data/spec/acceptance/indexing_spec.rb +3 -3
- data/spec/acceptance/paginating_search_results_spec.rb +3 -3
- data/spec/acceptance/real_time_updates_spec.rb +4 -4
- data/spec/acceptance/remove_deleted_records_spec.rb +12 -12
- data/spec/acceptance/search_counts_spec.rb +2 -2
- data/spec/acceptance/search_for_just_ids_spec.rb +2 -2
- data/spec/acceptance/searching_across_models_spec.rb +6 -6
- data/spec/acceptance/searching_across_schemas_spec.rb +10 -10
- data/spec/acceptance/searching_on_fields_spec.rb +9 -9
- data/spec/acceptance/searching_with_filters_spec.rb +16 -16
- data/spec/acceptance/searching_with_sti_spec.rb +9 -9
- data/spec/acceptance/searching_within_a_model_spec.rb +17 -17
- data/spec/acceptance/sorting_search_results_spec.rb +6 -6
- data/spec/acceptance/specifying_sql_spec.rb +62 -62
- data/spec/acceptance/sphinx_scopes_spec.rb +9 -9
- data/spec/acceptance/sql_deltas_spec.rb +7 -7
- data/spec/acceptance/support/database_cleaner.rb +1 -1
- data/spec/acceptance/support/sphinx_controller.rb +4 -1
- data/spec/acceptance/support/sphinx_helpers.rb +4 -0
- data/spec/acceptance/suspended_deltas_spec.rb +9 -9
- data/spec/internal/app/indices/article_index.rb +2 -2
- data/spec/internal/app/indices/book_index.rb +2 -1
- data/spec/internal/app/indices/product_index.rb +0 -2
- data/spec/internal/app/models/categorisation.rb +8 -1
- data/spec/spec_helper.rb +2 -0
- data/spec/support/json_column.rb +5 -1
- data/spec/support/multi_schema.rb +3 -1
- data/spec/support/sphinx_yaml_helpers.rb +1 -1
- data/spec/thinking_sphinx/active_record/association_spec.rb +1 -1
- data/spec/thinking_sphinx/active_record/attribute/type_spec.rb +41 -38
- data/spec/thinking_sphinx/active_record/base_spec.rb +29 -29
- data/spec/thinking_sphinx/active_record/callbacks/delete_callbacks_spec.rb +10 -10
- data/spec/thinking_sphinx/active_record/callbacks/delta_callbacks_spec.rb +48 -25
- data/spec/thinking_sphinx/active_record/callbacks/update_callbacks_spec.rb +8 -8
- data/spec/thinking_sphinx/active_record/column_spec.rb +13 -13
- data/spec/thinking_sphinx/active_record/column_sql_presenter_spec.rb +5 -5
- data/spec/thinking_sphinx/active_record/database_adapters/abstract_adapter_spec.rb +5 -5
- data/spec/thinking_sphinx/active_record/database_adapters/mysql_adapter_spec.rb +11 -11
- data/spec/thinking_sphinx/active_record/database_adapters/postgresql_adapter_spec.rb +13 -13
- data/spec/thinking_sphinx/active_record/database_adapters_spec.rb +48 -48
- data/spec/thinking_sphinx/active_record/field_spec.rb +7 -7
- data/spec/thinking_sphinx/active_record/filter_reflection_spec.rb +32 -32
- data/spec/thinking_sphinx/active_record/index_spec.rb +35 -36
- data/spec/thinking_sphinx/active_record/interpreter_spec.rb +51 -51
- data/spec/thinking_sphinx/active_record/polymorpher_spec.rb +14 -14
- data/spec/thinking_sphinx/active_record/property_sql_presenter_spec.rb +67 -67
- data/spec/thinking_sphinx/active_record/sql_builder_spec.rb +140 -140
- data/spec/thinking_sphinx/active_record/sql_source_spec.rb +97 -95
- data/spec/thinking_sphinx/configuration_spec.rb +81 -81
- data/spec/thinking_sphinx/connection_spec.rb +13 -13
- data/spec/thinking_sphinx/deletion_spec.rb +11 -11
- data/spec/thinking_sphinx/deltas/default_delta_spec.rb +20 -20
- data/spec/thinking_sphinx/deltas_spec.rb +12 -12
- data/spec/thinking_sphinx/errors_spec.rb +30 -30
- data/spec/thinking_sphinx/excerpter_spec.rb +7 -7
- data/spec/thinking_sphinx/facet_search_spec.rb +16 -16
- data/spec/thinking_sphinx/index_set_spec.rb +7 -7
- data/spec/thinking_sphinx/index_spec.rb +24 -24
- data/spec/thinking_sphinx/masks/pagination_mask_spec.rb +20 -20
- data/spec/thinking_sphinx/masks/scopes_mask_spec.rb +18 -18
- data/spec/thinking_sphinx/middlewares/active_record_translator_spec.rb +22 -22
- data/spec/thinking_sphinx/middlewares/geographer_spec.rb +9 -9
- data/spec/thinking_sphinx/middlewares/glazier_spec.rb +4 -4
- data/spec/thinking_sphinx/middlewares/inquirer_spec.rb +7 -7
- data/spec/thinking_sphinx/middlewares/sphinxql_spec.rb +53 -53
- data/spec/thinking_sphinx/middlewares/stale_id_checker_spec.rb +5 -5
- data/spec/thinking_sphinx/middlewares/stale_id_filter_spec.rb +15 -15
- data/spec/thinking_sphinx/panes/attributes_pane_spec.rb +1 -1
- data/spec/thinking_sphinx/panes/distance_pane_spec.rb +4 -4
- data/spec/thinking_sphinx/panes/excerpts_pane_spec.rb +5 -5
- data/spec/thinking_sphinx/panes/weight_pane_spec.rb +1 -1
- data/spec/thinking_sphinx/rake_interface_spec.rb +66 -53
- data/spec/thinking_sphinx/real_time/attribute_spec.rb +13 -13
- data/spec/thinking_sphinx/real_time/callbacks/real_time_callbacks_spec.rb +107 -23
- data/spec/thinking_sphinx/real_time/field_spec.rb +14 -14
- data/spec/thinking_sphinx/real_time/index_spec.rb +29 -30
- data/spec/thinking_sphinx/real_time/interpreter_spec.rb +30 -30
- data/spec/thinking_sphinx/scopes_spec.rb +5 -5
- data/spec/thinking_sphinx/search/glaze_spec.rb +15 -15
- data/spec/thinking_sphinx/search/query_spec.rb +10 -10
- data/spec/thinking_sphinx/search_spec.rb +28 -28
- data/spec/thinking_sphinx/wildcard_spec.rb +16 -11
- data/spec/thinking_sphinx_spec.rb +6 -6
- data/thinking-sphinx.gemspec +4 -4
- metadata +12 -9
|
@@ -9,14 +9,14 @@ describe ThinkingSphinx::Configuration do
|
|
|
9
9
|
|
|
10
10
|
describe '.instance' do
|
|
11
11
|
it "returns an instance of ThinkingSphinx::Configuration" do
|
|
12
|
-
ThinkingSphinx::Configuration.instance.
|
|
13
|
-
|
|
12
|
+
expect(ThinkingSphinx::Configuration.instance).
|
|
13
|
+
to be_a(ThinkingSphinx::Configuration)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
16
|
it "memoizes the instance" do
|
|
17
17
|
config = double('configuration')
|
|
18
18
|
|
|
19
|
-
ThinkingSphinx::Configuration.
|
|
19
|
+
expect(ThinkingSphinx::Configuration).to receive(:new).once.and_return(config)
|
|
20
20
|
|
|
21
21
|
ThinkingSphinx::Configuration.instance
|
|
22
22
|
ThinkingSphinx::Configuration.instance
|
|
@@ -29,8 +29,8 @@ describe ThinkingSphinx::Configuration do
|
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
it 'does not cache settings after reset' do
|
|
32
|
-
File.
|
|
33
|
-
File.
|
|
32
|
+
allow(File).to receive_messages :exists? => true
|
|
33
|
+
allow(File).to receive_messages :read => {
|
|
34
34
|
'test' => {'foo' => 'bugs'},
|
|
35
35
|
'production' => {'foo' => 'bar'}
|
|
36
36
|
}.to_yaml
|
|
@@ -38,33 +38,33 @@ describe ThinkingSphinx::Configuration do
|
|
|
38
38
|
ThinkingSphinx::Configuration.reset
|
|
39
39
|
# Grab a new copy of the instance.
|
|
40
40
|
config = ThinkingSphinx::Configuration.instance
|
|
41
|
-
config.settings['foo'].
|
|
41
|
+
expect(config.settings['foo']).to eq('bugs')
|
|
42
42
|
|
|
43
43
|
config.framework = double :environment => 'production', :root => Pathname.new(__FILE__).join('..', '..', 'internal')
|
|
44
|
-
config.settings['foo'].
|
|
44
|
+
expect(config.settings['foo']).to eq('bar')
|
|
45
45
|
end
|
|
46
46
|
end
|
|
47
47
|
|
|
48
48
|
describe '#configuration_file' do
|
|
49
49
|
it "uses the Rails environment in the configuration file name" do
|
|
50
|
-
config.configuration_file.
|
|
51
|
-
|
|
50
|
+
expect(config.configuration_file).
|
|
51
|
+
to eq(File.join(Rails.root, 'config', 'test.sphinx.conf'))
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
it "respects provided settings" do
|
|
55
55
|
write_configuration 'configuration_file' => '/path/to/foo.conf'
|
|
56
56
|
|
|
57
|
-
config.configuration_file.
|
|
57
|
+
expect(config.configuration_file).to eq('/path/to/foo.conf')
|
|
58
58
|
end
|
|
59
59
|
end
|
|
60
60
|
|
|
61
61
|
describe '#controller' do
|
|
62
62
|
it "returns an instance of Riddle::Controller" do
|
|
63
|
-
config.controller.
|
|
63
|
+
expect(config.controller).to be_a(Riddle::Controller)
|
|
64
64
|
end
|
|
65
65
|
|
|
66
66
|
it "memoizes the instance" do
|
|
67
|
-
Riddle::Controller.
|
|
67
|
+
expect(Riddle::Controller).to receive(:new).once.
|
|
68
68
|
and_return(double('controller'))
|
|
69
69
|
|
|
70
70
|
config.controller
|
|
@@ -74,19 +74,19 @@ describe ThinkingSphinx::Configuration do
|
|
|
74
74
|
it "sets the bin path from the thinking_sphinx.yml file" do
|
|
75
75
|
write_configuration('bin_path' => '/foo/bar/bin/')
|
|
76
76
|
|
|
77
|
-
config.controller.bin_path.
|
|
77
|
+
expect(config.controller.bin_path).to eq('/foo/bar/bin/')
|
|
78
78
|
end
|
|
79
79
|
|
|
80
80
|
it "appends a backslash to the bin_path if appropriate" do
|
|
81
81
|
write_configuration('bin_path' => '/foo/bar/bin')
|
|
82
82
|
|
|
83
|
-
config.controller.bin_path.
|
|
83
|
+
expect(config.controller.bin_path).to eq('/foo/bar/bin/')
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
86
|
|
|
87
87
|
describe '#index_paths' do
|
|
88
88
|
it "uses app/indices in the Rails app by default" do
|
|
89
|
-
config.index_paths.
|
|
89
|
+
expect(config.index_paths).to include(File.join(Rails.root, 'app', 'indices'))
|
|
90
90
|
end
|
|
91
91
|
|
|
92
92
|
it "uses app/indices in the Rails engines" do
|
|
@@ -95,22 +95,22 @@ describe ThinkingSphinx::Configuration do
|
|
|
95
95
|
} }
|
|
96
96
|
engine_class = double :instance => engine
|
|
97
97
|
|
|
98
|
-
Rails::Engine.
|
|
98
|
+
expect(Rails::Engine).to receive(:subclasses).and_return([ engine_class ])
|
|
99
99
|
|
|
100
|
-
config.index_paths.
|
|
100
|
+
expect(config.index_paths).to include('/engine/app/indices')
|
|
101
101
|
end
|
|
102
102
|
end
|
|
103
103
|
|
|
104
104
|
describe '#indices_location' do
|
|
105
105
|
it "stores index files in db/sphinx/ENVIRONMENT" do
|
|
106
|
-
config.indices_location.
|
|
107
|
-
|
|
106
|
+
expect(config.indices_location).
|
|
107
|
+
to eq(File.join(Rails.root, 'db', 'sphinx', 'test'))
|
|
108
108
|
end
|
|
109
109
|
|
|
110
110
|
it "respects provided settings" do
|
|
111
111
|
write_configuration 'indices_location' => '/my/index/files'
|
|
112
112
|
|
|
113
|
-
config.indices_location.
|
|
113
|
+
expect(config.indices_location).to eq('/my/index/files')
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
116
|
|
|
@@ -120,30 +120,30 @@ describe ThinkingSphinx::Configuration do
|
|
|
120
120
|
end
|
|
121
121
|
|
|
122
122
|
it "sets the daemon pid file within log for the Rails app" do
|
|
123
|
-
config.searchd.pid_file.
|
|
124
|
-
|
|
123
|
+
expect(config.searchd.pid_file).
|
|
124
|
+
to eq(File.join(Rails.root, 'log', 'test.sphinx.pid'))
|
|
125
125
|
end
|
|
126
126
|
|
|
127
127
|
it "sets the daemon log within log for the Rails app" do
|
|
128
|
-
config.searchd.log.
|
|
129
|
-
|
|
128
|
+
expect(config.searchd.log).
|
|
129
|
+
to eq(File.join(Rails.root, 'log', 'test.searchd.log'))
|
|
130
130
|
end
|
|
131
131
|
|
|
132
132
|
it "sets the query log within log for the Rails app" do
|
|
133
|
-
config.searchd.query_log.
|
|
134
|
-
|
|
133
|
+
expect(config.searchd.query_log).
|
|
134
|
+
to eq(File.join(Rails.root, 'log', 'test.searchd.query.log'))
|
|
135
135
|
end
|
|
136
136
|
|
|
137
137
|
it "sets indexer settings if within thinking_sphinx.yml" do
|
|
138
138
|
write_configuration 'mem_limit' => '128M'
|
|
139
139
|
|
|
140
|
-
config.indexer.mem_limit.
|
|
140
|
+
expect(config.indexer.mem_limit).to eq('128M')
|
|
141
141
|
end
|
|
142
142
|
|
|
143
143
|
it "sets searchd settings if within thinking_sphinx.yml" do
|
|
144
144
|
write_configuration 'workers' => 'none'
|
|
145
145
|
|
|
146
|
-
config.searchd.workers.
|
|
146
|
+
expect(config.searchd.workers).to eq('none')
|
|
147
147
|
end
|
|
148
148
|
|
|
149
149
|
it 'adds settings to indexer without common section' do
|
|
@@ -164,18 +164,18 @@ describe ThinkingSphinx::Configuration do
|
|
|
164
164
|
let(:reference) { double('reference') }
|
|
165
165
|
|
|
166
166
|
it "starts at 0" do
|
|
167
|
-
config.next_offset(reference).
|
|
167
|
+
expect(config.next_offset(reference)).to eq(0)
|
|
168
168
|
end
|
|
169
169
|
|
|
170
170
|
it "increments for each new reference" do
|
|
171
|
-
config.next_offset(double('reference')).
|
|
172
|
-
config.next_offset(double('reference')).
|
|
173
|
-
config.next_offset(double('reference')).
|
|
171
|
+
expect(config.next_offset(double('reference'))).to eq(0)
|
|
172
|
+
expect(config.next_offset(double('reference'))).to eq(1)
|
|
173
|
+
expect(config.next_offset(double('reference'))).to eq(2)
|
|
174
174
|
end
|
|
175
175
|
|
|
176
176
|
it "doesn't increment for recorded references" do
|
|
177
|
-
config.next_offset(reference).
|
|
178
|
-
config.next_offset(reference).
|
|
177
|
+
expect(config.next_offset(reference)).to eq(0)
|
|
178
|
+
expect(config.next_offset(reference)).to eq(0)
|
|
179
179
|
end
|
|
180
180
|
end
|
|
181
181
|
|
|
@@ -190,9 +190,9 @@ describe ThinkingSphinx::Configuration do
|
|
|
190
190
|
it "searches each index path for ruby files" do
|
|
191
191
|
config.index_paths.replace ['/path/to/indices', '/path/to/other/indices']
|
|
192
192
|
|
|
193
|
-
Dir.
|
|
193
|
+
expect(Dir).to receive(:[]).with('/path/to/indices/**/*.rb').once.
|
|
194
194
|
and_return([])
|
|
195
|
-
Dir.
|
|
195
|
+
expect(Dir).to receive(:[]).with('/path/to/other/indices/**/*.rb').once.
|
|
196
196
|
and_return([])
|
|
197
197
|
|
|
198
198
|
config.preload_indices
|
|
@@ -200,14 +200,14 @@ describe ThinkingSphinx::Configuration do
|
|
|
200
200
|
|
|
201
201
|
it "loads each file returned" do
|
|
202
202
|
config.index_paths.replace ['/path/to/indices']
|
|
203
|
-
Dir.
|
|
203
|
+
allow(Dir).to receive_messages :[] => [
|
|
204
204
|
'/path/to/indices/foo_index.rb',
|
|
205
205
|
'/path/to/indices/bar_index.rb'
|
|
206
206
|
]
|
|
207
207
|
|
|
208
|
-
ActiveSupport::Dependencies.
|
|
208
|
+
expect(ActiveSupport::Dependencies).to receive(:require_or_load).
|
|
209
209
|
with('/path/to/indices/foo_index.rb').once
|
|
210
|
-
ActiveSupport::Dependencies.
|
|
210
|
+
expect(ActiveSupport::Dependencies).to receive(:require_or_load).
|
|
211
211
|
with('/path/to/indices/bar_index.rb').once
|
|
212
212
|
|
|
213
213
|
config.preload_indices
|
|
@@ -215,14 +215,14 @@ describe ThinkingSphinx::Configuration do
|
|
|
215
215
|
|
|
216
216
|
it "does not double-load indices" do
|
|
217
217
|
config.index_paths.replace ['/path/to/indices']
|
|
218
|
-
Dir.
|
|
218
|
+
allow(Dir).to receive_messages :[] => [
|
|
219
219
|
'/path/to/indices/foo_index.rb',
|
|
220
220
|
'/path/to/indices/bar_index.rb'
|
|
221
221
|
]
|
|
222
222
|
|
|
223
|
-
ActiveSupport::Dependencies.
|
|
223
|
+
expect(ActiveSupport::Dependencies).to receive(:require_or_load).
|
|
224
224
|
with('/path/to/indices/foo_index.rb').once
|
|
225
|
-
ActiveSupport::Dependencies.
|
|
225
|
+
expect(ActiveSupport::Dependencies).to receive(:require_or_load).
|
|
226
226
|
with('/path/to/indices/bar_index.rb').once
|
|
227
227
|
|
|
228
228
|
config.preload_indices
|
|
@@ -230,7 +230,7 @@ describe ThinkingSphinx::Configuration do
|
|
|
230
230
|
end
|
|
231
231
|
|
|
232
232
|
it 'adds distributed indices' do
|
|
233
|
-
distributor.
|
|
233
|
+
expect(distributor).to receive(:reconcile)
|
|
234
234
|
|
|
235
235
|
config.preload_indices
|
|
236
236
|
end
|
|
@@ -238,7 +238,7 @@ describe ThinkingSphinx::Configuration do
|
|
|
238
238
|
it 'does not add distributed indices if disabled' do
|
|
239
239
|
write_configuration('distributed_indices' => false)
|
|
240
240
|
|
|
241
|
-
distributor.
|
|
241
|
+
expect(distributor).not_to receive(:reconcile)
|
|
242
242
|
|
|
243
243
|
config.preload_indices
|
|
244
244
|
end
|
|
@@ -246,15 +246,15 @@ describe ThinkingSphinx::Configuration do
|
|
|
246
246
|
|
|
247
247
|
describe '#render' do
|
|
248
248
|
before :each do
|
|
249
|
-
config.searchd.
|
|
249
|
+
allow(config.searchd).to receive_messages :render => 'searchd { }'
|
|
250
250
|
end
|
|
251
251
|
|
|
252
252
|
it "searches each index path for ruby files" do
|
|
253
253
|
config.index_paths.replace ['/path/to/indices', '/path/to/other/indices']
|
|
254
254
|
|
|
255
|
-
Dir.
|
|
255
|
+
expect(Dir).to receive(:[]).with('/path/to/indices/**/*.rb').once.
|
|
256
256
|
and_return([])
|
|
257
|
-
Dir.
|
|
257
|
+
expect(Dir).to receive(:[]).with('/path/to/other/indices/**/*.rb').once.
|
|
258
258
|
and_return([])
|
|
259
259
|
|
|
260
260
|
config.render
|
|
@@ -262,14 +262,14 @@ describe ThinkingSphinx::Configuration do
|
|
|
262
262
|
|
|
263
263
|
it "loads each file returned" do
|
|
264
264
|
config.index_paths.replace ['/path/to/indices']
|
|
265
|
-
Dir.
|
|
265
|
+
allow(Dir).to receive_messages :[] => [
|
|
266
266
|
'/path/to/indices/foo_index.rb',
|
|
267
267
|
'/path/to/indices/bar_index.rb'
|
|
268
268
|
]
|
|
269
269
|
|
|
270
|
-
ActiveSupport::Dependencies.
|
|
270
|
+
expect(ActiveSupport::Dependencies).to receive(:require_or_load).
|
|
271
271
|
with('/path/to/indices/foo_index.rb').once
|
|
272
|
-
ActiveSupport::Dependencies.
|
|
272
|
+
expect(ActiveSupport::Dependencies).to receive(:require_or_load).
|
|
273
273
|
with('/path/to/indices/bar_index.rb').once
|
|
274
274
|
|
|
275
275
|
config.render
|
|
@@ -277,14 +277,14 @@ describe ThinkingSphinx::Configuration do
|
|
|
277
277
|
|
|
278
278
|
it "does not double-load indices" do
|
|
279
279
|
config.index_paths.replace ['/path/to/indices']
|
|
280
|
-
Dir.
|
|
280
|
+
allow(Dir).to receive_messages :[] => [
|
|
281
281
|
'/path/to/indices/foo_index.rb',
|
|
282
282
|
'/path/to/indices/bar_index.rb'
|
|
283
283
|
]
|
|
284
284
|
|
|
285
|
-
ActiveSupport::Dependencies.
|
|
285
|
+
expect(ActiveSupport::Dependencies).to receive(:require_or_load).
|
|
286
286
|
with('/path/to/indices/foo_index.rb').once
|
|
287
|
-
ActiveSupport::Dependencies.
|
|
287
|
+
expect(ActiveSupport::Dependencies).to receive(:require_or_load).
|
|
288
288
|
with('/path/to/indices/bar_index.rb').once
|
|
289
289
|
|
|
290
290
|
config.preload_indices
|
|
@@ -297,33 +297,33 @@ describe ThinkingSphinx::Configuration do
|
|
|
297
297
|
let(:output) { config.render }
|
|
298
298
|
|
|
299
299
|
before :each do
|
|
300
|
-
config.searchd.
|
|
300
|
+
allow(config.searchd).to receive_messages :render => 'searchd { }'
|
|
301
301
|
end
|
|
302
302
|
|
|
303
303
|
it "writes the rendered configuration to the file" do
|
|
304
304
|
config.configuration_file = '/path/to/file.config'
|
|
305
305
|
|
|
306
|
-
config.
|
|
306
|
+
expect(config).to receive(:open).with('/path/to/file.config', 'w').
|
|
307
307
|
and_yield(file)
|
|
308
|
-
file.
|
|
308
|
+
expect(file).to receive(:write).with(output)
|
|
309
309
|
|
|
310
310
|
config.render_to_file
|
|
311
311
|
end
|
|
312
312
|
|
|
313
313
|
it "creates a directory at the binlog_path" do
|
|
314
|
-
FileUtils.
|
|
315
|
-
config.
|
|
314
|
+
allow(FileUtils).to receive_messages :mkdir_p => true
|
|
315
|
+
allow(config).to receive_messages :searchd => double(:binlog_path => '/path/to/binlog')
|
|
316
316
|
|
|
317
|
-
FileUtils.
|
|
317
|
+
expect(FileUtils).to receive(:mkdir_p).with('/path/to/binlog')
|
|
318
318
|
|
|
319
319
|
config.render_to_file
|
|
320
320
|
end
|
|
321
321
|
|
|
322
322
|
it "skips creating a directory when the binlog_path is blank" do
|
|
323
|
-
FileUtils.
|
|
324
|
-
config.
|
|
323
|
+
allow(FileUtils).to receive_messages :mkdir_p => true
|
|
324
|
+
allow(config).to receive_messages :searchd => double(:binlog_path => '')
|
|
325
325
|
|
|
326
|
-
FileUtils.
|
|
326
|
+
expect(FileUtils).not_to receive(:mkdir_p)
|
|
327
327
|
|
|
328
328
|
config.render_to_file
|
|
329
329
|
end
|
|
@@ -332,31 +332,31 @@ describe ThinkingSphinx::Configuration do
|
|
|
332
332
|
describe '#searchd' do
|
|
333
333
|
describe '#address' do
|
|
334
334
|
it "defaults to 127.0.0.1" do
|
|
335
|
-
config.searchd.address.
|
|
335
|
+
expect(config.searchd.address).to eq('127.0.0.1')
|
|
336
336
|
end
|
|
337
337
|
|
|
338
338
|
it "respects the address setting" do
|
|
339
339
|
write_configuration('address' => '10.11.12.13')
|
|
340
340
|
|
|
341
|
-
config.searchd.address.
|
|
341
|
+
expect(config.searchd.address).to eq('10.11.12.13')
|
|
342
342
|
end
|
|
343
343
|
end
|
|
344
344
|
|
|
345
345
|
describe '#mysql41' do
|
|
346
346
|
it "defaults to 9306" do
|
|
347
|
-
config.searchd.mysql41.
|
|
347
|
+
expect(config.searchd.mysql41).to eq(9306)
|
|
348
348
|
end
|
|
349
349
|
|
|
350
350
|
it "respects the port setting" do
|
|
351
351
|
write_configuration('port' => 9313)
|
|
352
352
|
|
|
353
|
-
config.searchd.mysql41.
|
|
353
|
+
expect(config.searchd.mysql41).to eq(9313)
|
|
354
354
|
end
|
|
355
355
|
|
|
356
356
|
it "respects the mysql41 setting" do
|
|
357
357
|
write_configuration('mysql41' => 9307)
|
|
358
358
|
|
|
359
|
-
config.searchd.mysql41.
|
|
359
|
+
expect(config.searchd.mysql41).to eq(9307)
|
|
360
360
|
end
|
|
361
361
|
end
|
|
362
362
|
end
|
|
@@ -364,66 +364,66 @@ describe ThinkingSphinx::Configuration do
|
|
|
364
364
|
describe '#settings' do
|
|
365
365
|
context 'YAML file exists' do
|
|
366
366
|
before :each do
|
|
367
|
-
File.
|
|
367
|
+
allow(File).to receive_messages :exists? => true
|
|
368
368
|
end
|
|
369
369
|
|
|
370
370
|
it "reads from the YAML file" do
|
|
371
|
-
File.
|
|
371
|
+
expect(File).to receive(:read).and_return('')
|
|
372
372
|
|
|
373
373
|
config.settings
|
|
374
374
|
end
|
|
375
375
|
|
|
376
376
|
it "uses the settings for the given environment" do
|
|
377
|
-
File.
|
|
377
|
+
allow(File).to receive_messages :read => {
|
|
378
378
|
'test' => {'foo' => 'bar'},
|
|
379
379
|
'staging' => {'baz' => 'qux'}
|
|
380
380
|
}.to_yaml
|
|
381
|
-
Rails.
|
|
381
|
+
allow(Rails).to receive_messages :env => 'staging'
|
|
382
382
|
|
|
383
|
-
config.settings['baz'].
|
|
383
|
+
expect(config.settings['baz']).to eq('qux')
|
|
384
384
|
end
|
|
385
385
|
|
|
386
386
|
it "remembers the file contents" do
|
|
387
|
-
File.
|
|
387
|
+
expect(File).to receive(:read).and_return('')
|
|
388
388
|
|
|
389
389
|
config.settings
|
|
390
390
|
config.settings
|
|
391
391
|
end
|
|
392
392
|
|
|
393
393
|
it "returns an empty hash when no settings for the environment exist" do
|
|
394
|
-
File.
|
|
395
|
-
Rails.
|
|
394
|
+
allow(File).to receive_messages :read => {'test' => {'foo' => 'bar'}}.to_yaml
|
|
395
|
+
allow(Rails).to receive_messages :env => 'staging'
|
|
396
396
|
|
|
397
|
-
config.settings.
|
|
397
|
+
expect(config.settings).to eq({})
|
|
398
398
|
end
|
|
399
399
|
end
|
|
400
400
|
|
|
401
401
|
context 'YAML file does not exist' do
|
|
402
402
|
before :each do
|
|
403
|
-
File.
|
|
403
|
+
allow(File).to receive_messages :exists? => false
|
|
404
404
|
end
|
|
405
405
|
|
|
406
406
|
it "does not read the file" do
|
|
407
|
-
File.
|
|
407
|
+
expect(File).not_to receive(:read)
|
|
408
408
|
|
|
409
409
|
config.settings
|
|
410
410
|
end
|
|
411
411
|
|
|
412
412
|
it "returns an empty hash" do
|
|
413
|
-
config.settings.
|
|
413
|
+
expect(config.settings).to eq({})
|
|
414
414
|
end
|
|
415
415
|
end
|
|
416
416
|
end
|
|
417
417
|
|
|
418
418
|
describe '#version' do
|
|
419
419
|
it "defaults to 2.1.4" do
|
|
420
|
-
config.version.
|
|
420
|
+
expect(config.version).to eq('2.1.4')
|
|
421
421
|
end
|
|
422
422
|
|
|
423
423
|
it "respects supplied YAML versions" do
|
|
424
424
|
write_configuration 'version' => '2.0.4'
|
|
425
425
|
|
|
426
|
-
config.version.
|
|
426
|
+
expect(config.version).to eq('2.0.4')
|
|
427
427
|
end
|
|
428
428
|
end
|
|
429
429
|
end
|