thinking-sphinx 2.0.7 → 2.0.8

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.
@@ -2,14 +2,21 @@ module Rails
2
2
  def self.root
3
3
  File.join(Dir.pwd, 'tmp')
4
4
  end
5
-
5
+
6
6
  def self.env
7
7
  @@environment ||= 'development'
8
8
  end
9
-
9
+
10
10
  def self.env=(env)
11
11
  @@environment = env
12
12
  end
13
+
14
+ def self.application
15
+ @@application ||= begin
16
+ railties = Struct.new(:engines).new([])
17
+ Struct.new(:paths, :railties).new(Hash.new([]), railties)
18
+ end
19
+ end
13
20
  end
14
21
 
15
22
  ActiveSupport::Inflector.inflections do |inflect|
@@ -4,16 +4,16 @@ describe ThinkingSphinx::Configuration do
4
4
  describe "environment class method" do
5
5
  before :each do
6
6
  ThinkingSphinx::Configuration.reset_environment
7
-
7
+
8
8
  ENV["RAILS_ENV"] = nil
9
9
  end
10
10
 
11
11
  it "should use Rails.env if set" do
12
12
  was = Rails.env
13
13
  Rails.env = 'global_rails'
14
-
14
+
15
15
  ThinkingSphinx::Configuration.environment.should == 'global_rails'
16
-
16
+
17
17
  Rails.env = was
18
18
  end
19
19
 
@@ -26,31 +26,31 @@ describe ThinkingSphinx::Configuration do
26
26
  ThinkingSphinx::Configuration.environment.should == "development"
27
27
  end
28
28
  end
29
-
29
+
30
30
  describe '#version' do
31
31
  before :each do
32
32
  @config = ThinkingSphinx::Configuration.instance
33
33
  @config.reset
34
34
  end
35
-
35
+
36
36
  it "should use the given version from sphinx.yml if there is one" do
37
37
  open("#{Rails.root}/config/sphinx.yml", "w") do |f|
38
38
  f.write YAML.dump({'development' => {'version' => '0.9.7'}})
39
39
  end
40
40
  @config.reset
41
-
41
+
42
42
  @config.version.should == '0.9.7'
43
-
43
+
44
44
  FileUtils.rm "#{Rails.root}/config/sphinx.yml"
45
45
  end
46
-
46
+
47
47
  it "should detect the version from Riddle otherwise" do
48
48
  controller = @config.controller
49
49
  controller.stub!(:sphinx_version => '0.9.6')
50
-
50
+
51
51
  Riddle::Controller.stub!(:new => controller)
52
52
  @config.reset
53
-
53
+
54
54
  @config.version.should == '0.9.6'
55
55
  end
56
56
  end
@@ -107,7 +107,7 @@ describe ThinkingSphinx::Configuration do
107
107
  config.app_root = "/here/somewhere"
108
108
  end
109
109
  ThinkingSphinx::Configuration.instance.app_root.should == "/here/somewhere"
110
-
110
+
111
111
  ThinkingSphinx::Configuration.instance.reset
112
112
  end
113
113
  end
@@ -127,7 +127,7 @@ describe ThinkingSphinx::Configuration do
127
127
  open("#{Rails.root}/config/sphinx.yml", "w") do |f|
128
128
  f.write YAML.dump(@settings)
129
129
  end
130
-
130
+
131
131
  ThinkingSphinx::Configuration.instance.send(:parse_config)
132
132
  ThinkingSphinx::Configuration.instance.bin_path.should match(/\/$/)
133
133
 
@@ -160,7 +160,7 @@ describe ThinkingSphinx::Configuration do
160
160
 
161
161
  it "should insert set index options into the configuration file" do
162
162
  config = ThinkingSphinx::Configuration.instance
163
-
163
+
164
164
  ThinkingSphinx::Configuration::IndexOptions.each do |option|
165
165
  config.reset
166
166
  config.index_options[option.to_sym] = "something"
@@ -176,7 +176,7 @@ describe ThinkingSphinx::Configuration do
176
176
  it "should insert set source options into the configuration file" do
177
177
  config = ThinkingSphinx::Configuration.instance
178
178
  config.reset
179
-
179
+
180
180
  config.source_options[:sql_query_pre] = ["something"]
181
181
  ThinkingSphinx::Configuration::SourceOptions.each do |option|
182
182
  config.source_options[option.to_sym] ||= "something"
@@ -187,27 +187,27 @@ describe ThinkingSphinx::Configuration do
187
187
 
188
188
  config.source_options.delete option.to_sym
189
189
  end
190
-
191
- config.source_options[:sql_query_pre] = []
190
+
191
+ config.source_options[:sql_query_pre] = []
192
192
  end
193
-
193
+
194
194
  it "should not blow away delta or utf options if sql pre is specified in config" do
195
195
  config = ThinkingSphinx::Configuration.instance
196
196
  config.reset
197
-
197
+
198
198
  config.source_options[:sql_query_pre] = ["a pre query"]
199
199
  config.build
200
200
  file = open(config.config_file) { |f| f.read }
201
-
201
+
202
202
  file.should match(/sql_query_pre = a pre query\n\s*sql_query_pre = UPDATE `\w+` SET `delta` = 0 WHERE `delta` = 1/im)
203
203
  file.should match(/sql_query_pre = a pre query\n\s*sql_query_pre = \n/im)
204
-
204
+
205
205
  config.source_options[:sql_query_pre] = []
206
206
  end
207
207
 
208
208
  it "should set any explicit prefixed or infixed fields" do
209
209
  ThinkingSphinx::Configuration.instance.build
210
-
210
+
211
211
  file = open(ThinkingSphinx::Configuration.instance.config_file) { |f|
212
212
  f.read
213
213
  }
@@ -217,30 +217,30 @@ describe ThinkingSphinx::Configuration do
217
217
 
218
218
  it "should not have prefix fields in indexes where nothing is set" do
219
219
  ThinkingSphinx::Configuration.instance.build
220
-
220
+
221
221
  file = open(ThinkingSphinx::Configuration.instance.config_file) { |f|
222
222
  f.read
223
223
  }
224
224
  file.should_not match(/index alpha_core\s+\{\s+[^\}]*prefix_fields\s+=[^\}]*\}/m)
225
225
  end
226
-
226
+
227
227
  describe '#generate' do
228
228
  let(:config) { ThinkingSphinx::Configuration.instance }
229
-
229
+
230
230
  it "should set all sphinx_internal_id attributes to bigints if one is" do
231
231
  config.reset
232
232
  config.generate
233
-
233
+
234
234
  config.configuration.indexes.each do |index|
235
235
  next if index.is_a? Riddle::Configuration::DistributedIndex
236
-
236
+
237
237
  index.sources.each do |source|
238
238
  source.sql_attr_bigint.should include(:sphinx_internal_id)
239
239
  end
240
240
  end
241
241
  end
242
242
  end
243
-
243
+
244
244
  describe '#client' do
245
245
  before :each do
246
246
  @config = ThinkingSphinx::Configuration.instance
@@ -249,19 +249,19 @@ describe ThinkingSphinx::Configuration do
249
249
  @config.configuration.searchd.max_matches = 100
250
250
  @config.timeout = 1
251
251
  end
252
-
252
+
253
253
  it "should return an instance of Riddle::Client" do
254
254
  @config.client.should be_a(Riddle::Client)
255
255
  end
256
-
256
+
257
257
  it "should use the configuration address" do
258
258
  @config.client.server.should == 'domain.url'
259
259
  end
260
-
260
+
261
261
  it "should use the configuration port" do
262
262
  @config.client.port.should == 3333
263
263
  end
264
-
264
+
265
265
  it "should use the configuration max matches" do
266
266
  @config.client.max_matches.should == 100
267
267
  end
@@ -269,17 +269,55 @@ describe ThinkingSphinx::Configuration do
269
269
  it "should use the configuration timeout" do
270
270
  @config.client.timeout.should == 1
271
271
  end
272
+
273
+ describe 'when shuffle is enabled' do
274
+ let(:client) { double('client', :max_matches= => nil, :timeout= => nil) }
275
+
276
+ before :each do
277
+ @config.shuffle = true
278
+ end
279
+
280
+ it "should shuffle client servers" do
281
+ @config.address = ['1.1.1.1', '2.2.2.2']
282
+ @config.address.stub!(:shuffle => ['2.2.2.2', '1.1.1.1'])
283
+
284
+ Riddle::Client.should_receive(:new) do |addresses, port, key|
285
+ addresses.should == ['2.2.2.2', '1.1.1.1']
286
+ client
287
+ end
288
+ @config.client
289
+ end
290
+ end
291
+
292
+ describe 'when shuffle is disabled' do
293
+ let(:client) { double('client', :max_matches= => nil, :timeout= => nil) }
294
+
295
+ before :each do
296
+ @config.shuffle = false
297
+ end
298
+
299
+ it "should not shuffle client servers" do
300
+ @config.address = ['1.1.1.1', '2.2.2.2.', '3.3.3.3', '4.4.4.4', '5.5.5.5']
301
+
302
+ @config.address.should_not_receive(:shuffle)
303
+ Riddle::Client.should_receive(:new) do |addresses, port, key|
304
+ addresses.should == ['1.1.1.1', '2.2.2.2.', '3.3.3.3', '4.4.4.4', '5.5.5.5']
305
+ client
306
+ end
307
+ @config.client
308
+ end
309
+ end
272
310
  end
273
-
311
+
274
312
  describe '#models_by_crc' do
275
313
  before :each do
276
314
  @config = ThinkingSphinx::Configuration.instance
277
315
  end
278
-
316
+
279
317
  it "should return a hash" do
280
318
  @config.models_by_crc.should be_a(Hash)
281
319
  end
282
-
320
+
283
321
  it "should pair class names to their crc codes" do
284
322
  @config.models_by_crc[Person.to_crc32].should == 'Person'
285
323
  @config.models_by_crc[Alpha.to_crc32].should == 'Alpha'
@@ -31,18 +31,20 @@ describe ThinkingSphinx::Context do
31
31
  }.should_not raise_error
32
32
  end
33
33
 
34
- it "should not raise errors if the file name does not represent a class name" do
35
- class_name.should_receive(:constantize).and_raise(NameError)
34
+ it "should report name errors but not raise them" do
35
+ class_name.stub(:constantize).and_raise(NameError)
36
+ STDERR.stub!(:puts => '')
37
+ STDERR.should_receive(:puts).with('Warning: Error loading a.rb:')
36
38
 
37
39
  lambda {
38
40
  ts_context.prepare
39
41
  }.should_not raise_error
40
42
  end
41
43
 
42
- # Fails in Ruby 1.9 (or maybe it's an RSpec update). Not sure why.
43
- it "should retry if the first pass fails and contains a directory" do
44
+ it "should report load errors but not raise them" do
44
45
  class_name.stub(:constantize).and_raise(LoadError)
45
- model_name_lower.should_receive(:gsub!).twice.and_return(true, nil)
46
+ STDERR.stub!(:puts => '')
47
+ STDERR.should_receive(:puts).with('Warning: Error loading a.rb:')
46
48
 
47
49
  lambda {
48
50
  ts_context.prepare
@@ -110,7 +110,7 @@ describe ThinkingSphinx do
110
110
 
111
111
  describe "use_group_by_shortcut? method" do
112
112
  before :each do
113
- adapter = defined?(JRUBY_VERSION) ? :JdbcAdapter : :MysqlAdapter
113
+ adapter = defined?(JRUBY_VERSION) ? :JdbcAdapter : :Mysql2Adapter
114
114
  unless ::ActiveRecord::ConnectionAdapters.const_defined?(adapter)
115
115
  pending "No MySQL"
116
116
  return
@@ -118,8 +118,8 @@ describe ThinkingSphinx do
118
118
 
119
119
  @connection = stub('adapter',
120
120
  :select_all => true,
121
- :class => ActiveRecord::ConnectionAdapters::MysqlAdapter,
122
- :config => {:adapter => defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql'}
121
+ :class => ActiveRecord::ConnectionAdapters::Mysql2Adapter,
122
+ :config => {:adapter => defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'}
123
123
  )
124
124
  ::ActiveRecord::Base.stub!(
125
125
  :connection => @connection
metadata CHANGED
@@ -1,138 +1,145 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: thinking-sphinx
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.0.8
4
5
  prerelease:
5
- version: 2.0.7
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Pat Allan
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-08-29 00:00:00 +10:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2011-10-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: activerecord
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70126506526780 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
23
21
  version: 3.0.3
24
22
  type: :runtime
25
23
  prerelease: false
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
24
+ version_requirements: *70126506526780
25
+ - !ruby/object:Gem::Dependency
28
26
  name: riddle
29
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &70126506525900 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
34
32
  version: 1.3.3
35
33
  type: :runtime
36
34
  prerelease: false
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
35
+ version_requirements: *70126506525900
36
+ - !ruby/object:Gem::Dependency
37
+ name: builder
38
+ requirement: &70126506547900 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: 2.1.2
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70126506547900
47
+ - !ruby/object:Gem::Dependency
39
48
  name: actionpack
40
- requirement: &id003 !ruby/object:Gem::Requirement
49
+ requirement: &70126506547320 !ruby/object:Gem::Requirement
41
50
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
45
54
  version: 3.0.3
46
55
  type: :development
47
56
  prerelease: false
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
57
+ version_requirements: *70126506547320
58
+ - !ruby/object:Gem::Dependency
50
59
  name: cucumber
51
- requirement: &id004 !ruby/object:Gem::Requirement
60
+ requirement: &70126506546700 !ruby/object:Gem::Requirement
52
61
  none: false
53
- requirements:
54
- - - "="
55
- - !ruby/object:Gem::Version
62
+ requirements:
63
+ - - =
64
+ - !ruby/object:Gem::Version
56
65
  version: 1.0.2
57
66
  type: :development
58
67
  prerelease: false
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
68
+ version_requirements: *70126506546700
69
+ - !ruby/object:Gem::Dependency
61
70
  name: faker
62
- requirement: &id005 !ruby/object:Gem::Requirement
71
+ requirement: &70126506545720 !ruby/object:Gem::Requirement
63
72
  none: false
64
- requirements:
65
- - - "="
66
- - !ruby/object:Gem::Version
73
+ requirements:
74
+ - - =
75
+ - !ruby/object:Gem::Version
67
76
  version: 0.3.1
68
77
  type: :development
69
78
  prerelease: false
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
79
+ version_requirements: *70126506545720
80
+ - !ruby/object:Gem::Dependency
72
81
  name: ginger
73
- requirement: &id006 !ruby/object:Gem::Requirement
82
+ requirement: &70126506545060 !ruby/object:Gem::Requirement
74
83
  none: false
75
- requirements:
76
- - - "="
77
- - !ruby/object:Gem::Version
84
+ requirements:
85
+ - - =
86
+ - !ruby/object:Gem::Version
78
87
  version: 1.2.0
79
88
  type: :development
80
89
  prerelease: false
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
90
+ version_requirements: *70126506545060
91
+ - !ruby/object:Gem::Dependency
83
92
  name: rake
84
- requirement: &id007 !ruby/object:Gem::Requirement
93
+ requirement: &70126506544440 !ruby/object:Gem::Requirement
85
94
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
89
98
  version: 0.9.2
90
99
  type: :development
91
100
  prerelease: false
92
- version_requirements: *id007
93
- - !ruby/object:Gem::Dependency
101
+ version_requirements: *70126506544440
102
+ - !ruby/object:Gem::Dependency
94
103
  name: rspec
95
- requirement: &id008 !ruby/object:Gem::Requirement
104
+ requirement: &70126506543500 !ruby/object:Gem::Requirement
96
105
  none: false
97
- requirements:
98
- - - "="
99
- - !ruby/object:Gem::Version
106
+ requirements:
107
+ - - =
108
+ - !ruby/object:Gem::Version
100
109
  version: 2.6.0
101
110
  type: :development
102
111
  prerelease: false
103
- version_requirements: *id008
104
- - !ruby/object:Gem::Dependency
112
+ version_requirements: *70126506543500
113
+ - !ruby/object:Gem::Dependency
105
114
  name: will_paginate
106
- requirement: &id009 !ruby/object:Gem::Requirement
115
+ requirement: &70126506541700 !ruby/object:Gem::Requirement
107
116
  none: false
108
- requirements:
109
- - - "="
110
- - !ruby/object:Gem::Version
111
- version: "3.0"
117
+ requirements:
118
+ - - =
119
+ - !ruby/object:Gem::Version
120
+ version: '3.0'
112
121
  type: :development
113
122
  prerelease: false
114
- version_requirements: *id009
115
- - !ruby/object:Gem::Dependency
123
+ version_requirements: *70126506541700
124
+ - !ruby/object:Gem::Dependency
116
125
  name: yard
117
- requirement: &id010 !ruby/object:Gem::Requirement
126
+ requirement: &70126506541020 !ruby/object:Gem::Requirement
118
127
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
128
+ requirements:
129
+ - - ! '>='
130
+ - !ruby/object:Gem::Version
122
131
  version: 0.7.2
123
132
  type: :development
124
133
  prerelease: false
125
- version_requirements: *id010
126
- description: A concise and easy-to-use Ruby library that connects ActiveRecord to the Sphinx search daemon, managing configuration, indexing and searching.
127
- email:
134
+ version_requirements: *70126506541020
135
+ description: A concise and easy-to-use Ruby library that connects ActiveRecord to
136
+ the Sphinx search daemon, managing configuration, indexing and searching.
137
+ email:
128
138
  - pat@freelancing-gods.com
129
139
  executables: []
130
-
131
140
  extensions: []
132
-
133
141
  extra_rdoc_files: []
134
-
135
- files:
142
+ files:
136
143
  - lib/cucumber/thinking_sphinx/external_world.rb
137
144
  - lib/cucumber/thinking_sphinx/internal_world.rb
138
145
  - lib/cucumber/thinking_sphinx/sql_logger.rb
@@ -307,44 +314,42 @@ files:
307
314
  - spec/thinking_sphinx/source_spec.rb
308
315
  - spec/thinking_sphinx/test_spec.rb
309
316
  - spec/thinking_sphinx_spec.rb
310
- has_rdoc: true
311
317
  homepage: http://freelancing-god.github.com/ts/en/
312
318
  licenses: []
319
+ post_install_message: ! 'If you''re upgrading, you should read this:
313
320
 
314
- post_install_message: |+
315
- If you're upgrading, you should read this:
316
321
  http://freelancing-god.github.com/ts/en/upgrading.html
317
-
318
- rdoc_options: []
319
322
 
320
- require_paths:
323
+
324
+ '
325
+ rdoc_options: []
326
+ require_paths:
321
327
  - lib
322
- required_ruby_version: !ruby/object:Gem::Requirement
328
+ required_ruby_version: !ruby/object:Gem::Requirement
323
329
  none: false
324
- requirements:
325
- - - ">="
326
- - !ruby/object:Gem::Version
327
- hash: 3081911813492499191
328
- segments:
330
+ requirements:
331
+ - - ! '>='
332
+ - !ruby/object:Gem::Version
333
+ version: '0'
334
+ segments:
329
335
  - 0
330
- version: "0"
331
- required_rubygems_version: !ruby/object:Gem::Requirement
336
+ hash: 4029810406127413901
337
+ required_rubygems_version: !ruby/object:Gem::Requirement
332
338
  none: false
333
- requirements:
334
- - - ">="
335
- - !ruby/object:Gem::Version
336
- hash: 3081911813492499191
337
- segments:
339
+ requirements:
340
+ - - ! '>='
341
+ - !ruby/object:Gem::Version
342
+ version: '0'
343
+ segments:
338
344
  - 0
339
- version: "0"
345
+ hash: 4029810406127413901
340
346
  requirements: []
341
-
342
347
  rubyforge_project: thinking-sphinx
343
- rubygems_version: 1.6.2
348
+ rubygems_version: 1.8.10
344
349
  signing_key:
345
350
  specification_version: 3
346
351
  summary: ActiveRecord/Rails Sphinx library
347
- test_files:
352
+ test_files:
348
353
  - features/abstract_inheritance.feature
349
354
  - features/alternate_primary_key.feature
350
355
  - features/attribute_transformation.feature