thinking-sphinx 1.5.0 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (104) hide show
  1. data/README.textile +15 -48
  2. data/VERSION +1 -0
  3. data/features/attribute_transformation.feature +7 -7
  4. data/features/attribute_updates.feature +16 -18
  5. data/features/deleting_instances.feature +13 -16
  6. data/features/excerpts.feature +0 -8
  7. data/features/facets.feature +19 -25
  8. data/features/handling_edits.feature +20 -25
  9. data/features/searching_across_models.feature +1 -1
  10. data/features/searching_by_index.feature +5 -6
  11. data/features/searching_by_model.feature +29 -29
  12. data/features/sphinx_scopes.feature +0 -26
  13. data/features/step_definitions/common_steps.rb +6 -18
  14. data/features/step_definitions/scope_steps.rb +0 -4
  15. data/features/step_definitions/search_steps.rb +4 -9
  16. data/features/support/env.rb +10 -3
  17. data/features/thinking_sphinx/db/fixtures/alphas.rb +10 -8
  18. data/features/thinking_sphinx/db/fixtures/cats.rb +1 -1
  19. data/features/thinking_sphinx/db/fixtures/dogs.rb +1 -1
  20. data/features/thinking_sphinx/db/fixtures/foxes.rb +1 -1
  21. data/features/thinking_sphinx/db/fixtures/people.rb +1 -1
  22. data/features/thinking_sphinx/db/fixtures/posts.rb +1 -5
  23. data/features/thinking_sphinx/db/migrations/create_posts.rb +0 -1
  24. data/features/thinking_sphinx/models/alpha.rb +0 -1
  25. data/features/thinking_sphinx/models/beta.rb +0 -5
  26. data/features/thinking_sphinx/models/developer.rb +1 -6
  27. data/features/thinking_sphinx/models/music.rb +1 -3
  28. data/features/thinking_sphinx/models/person.rb +1 -2
  29. data/features/thinking_sphinx/models/post.rb +0 -1
  30. data/lib/cucumber/thinking_sphinx/external_world.rb +4 -8
  31. data/lib/cucumber/thinking_sphinx/internal_world.rb +27 -36
  32. data/lib/thinking_sphinx.rb +60 -132
  33. data/lib/thinking_sphinx/active_record.rb +98 -124
  34. data/lib/thinking_sphinx/active_record/attribute_updates.rb +13 -17
  35. data/lib/thinking_sphinx/active_record/delta.rb +15 -21
  36. data/lib/thinking_sphinx/active_record/has_many_association.rb +23 -16
  37. data/lib/thinking_sphinx/active_record/scopes.rb +0 -18
  38. data/lib/thinking_sphinx/adapters/abstract_adapter.rb +15 -63
  39. data/lib/thinking_sphinx/adapters/mysql_adapter.rb +0 -4
  40. data/lib/thinking_sphinx/adapters/postgresql_adapter.rb +24 -65
  41. data/lib/thinking_sphinx/association.rb +11 -36
  42. data/lib/thinking_sphinx/attribute.rb +85 -92
  43. data/lib/thinking_sphinx/auto_version.rb +3 -21
  44. data/lib/thinking_sphinx/class_facet.rb +3 -8
  45. data/lib/thinking_sphinx/configuration.rb +58 -114
  46. data/lib/thinking_sphinx/context.rb +20 -22
  47. data/lib/thinking_sphinx/core/array.rb +13 -0
  48. data/lib/thinking_sphinx/deltas.rb +0 -2
  49. data/lib/thinking_sphinx/deltas/default_delta.rb +22 -18
  50. data/lib/thinking_sphinx/deploy/capistrano.rb +31 -30
  51. data/lib/thinking_sphinx/excerpter.rb +1 -2
  52. data/lib/thinking_sphinx/facet.rb +35 -45
  53. data/lib/thinking_sphinx/facet_search.rb +24 -58
  54. data/lib/thinking_sphinx/field.rb +0 -18
  55. data/lib/thinking_sphinx/index.rb +36 -38
  56. data/lib/thinking_sphinx/index/builder.rb +59 -74
  57. data/lib/thinking_sphinx/property.rb +45 -66
  58. data/lib/thinking_sphinx/railtie.rb +35 -0
  59. data/lib/thinking_sphinx/search.rb +250 -506
  60. data/lib/thinking_sphinx/source.rb +31 -50
  61. data/lib/thinking_sphinx/source/internal_properties.rb +3 -8
  62. data/lib/thinking_sphinx/source/sql.rb +31 -71
  63. data/lib/thinking_sphinx/tasks.rb +27 -48
  64. data/spec/thinking_sphinx/active_record/delta_spec.rb +41 -36
  65. data/spec/thinking_sphinx/active_record/has_many_association_spec.rb +0 -96
  66. data/spec/thinking_sphinx/active_record/scopes_spec.rb +29 -29
  67. data/spec/thinking_sphinx/active_record_spec.rb +169 -140
  68. data/spec/thinking_sphinx/association_spec.rb +2 -20
  69. data/spec/thinking_sphinx/attribute_spec.rb +97 -101
  70. data/spec/thinking_sphinx/auto_version_spec.rb +11 -75
  71. data/spec/thinking_sphinx/configuration_spec.rb +62 -63
  72. data/spec/thinking_sphinx/context_spec.rb +66 -66
  73. data/spec/thinking_sphinx/facet_search_spec.rb +99 -99
  74. data/spec/thinking_sphinx/facet_spec.rb +4 -30
  75. data/spec/thinking_sphinx/field_spec.rb +3 -17
  76. data/spec/thinking_sphinx/index/builder_spec.rb +132 -169
  77. data/spec/thinking_sphinx/index_spec.rb +39 -45
  78. data/spec/thinking_sphinx/search_methods_spec.rb +33 -37
  79. data/spec/thinking_sphinx/search_spec.rb +269 -491
  80. data/spec/thinking_sphinx/source_spec.rb +48 -62
  81. data/spec/thinking_sphinx_spec.rb +49 -49
  82. data/tasks/distribution.rb +46 -0
  83. data/tasks/testing.rb +74 -0
  84. metadata +123 -199
  85. data/features/field_sorting.feature +0 -18
  86. data/features/thinking_sphinx/db/.gitignore +0 -1
  87. data/features/thinking_sphinx/db/fixtures/post_keywords.txt +0 -1
  88. data/features/thinking_sphinx/models/andrew.rb +0 -17
  89. data/lib/thinking-sphinx.rb +0 -1
  90. data/lib/thinking_sphinx/active_record/has_many_association_with_scopes.rb +0 -21
  91. data/lib/thinking_sphinx/bundled_search.rb +0 -40
  92. data/lib/thinking_sphinx/connection.rb +0 -71
  93. data/lib/thinking_sphinx/deltas/delete_job.rb +0 -16
  94. data/lib/thinking_sphinx/deltas/index_job.rb +0 -17
  95. data/lib/thinking_sphinx/rails_additions.rb +0 -181
  96. data/spec/fixtures/data.sql +0 -32
  97. data/spec/fixtures/database.yml.default +0 -3
  98. data/spec/fixtures/models.rb +0 -161
  99. data/spec/fixtures/structure.sql +0 -146
  100. data/spec/spec_helper.rb +0 -54
  101. data/spec/sphinx_helper.rb +0 -67
  102. data/spec/thinking_sphinx/adapters/abstract_adapter_spec.rb +0 -163
  103. data/spec/thinking_sphinx/connection_spec.rb +0 -77
  104. data/spec/thinking_sphinx/rails_additions_spec.rb +0 -203
@@ -1,146 +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) NULL,
6
- `middle_initial` varchar(10) NULL,
7
- `last_name` varchar(50) NULL,
8
- `gender` varchar(10) NULL,
9
- `street_address` varchar(200) NULL,
10
- `city` varchar(100) NULL,
11
- `state` varchar(100) NULL,
12
- `postcode` varchar(10) NULL,
13
- `email` varchar(100) NULL,
14
- `birthday` datetime NULL,
15
- `team_id` int(11) NULL,
16
- `team_type` varchar(50) NULL,
17
- `type` varchar(50) NULL,
18
- `parent_id` varchar(50) NULL,
19
- `source_id` int(11) NULL,
20
- `source_type` varchar(50) NULL,
21
- `delta` tinyint(1) NOT NULL DEFAULT 0,
22
- PRIMARY KEY (`id`)
23
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
24
-
25
- DROP TABLE IF EXISTS `friendships`;
26
-
27
- CREATE TABLE `friendships` (
28
- `id` int(11) NOT NULL auto_increment,
29
- `person_id` int(11) NOT NULL,
30
- `friend_id` int(11) NOT NULL,
31
- `created_at` datetime NOT NULL,
32
- `created_on` date NULL,
33
- `updated_at` datetime NOT NULL,
34
- PRIMARY KEY (`id`)
35
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
36
-
37
- DROP TABLE IF EXISTS `football_teams`;
38
-
39
- CREATE TABLE `football_teams` (
40
- `id` int(11) NOT NULL auto_increment,
41
- `name` varchar(50) NOT NULL,
42
- `state` varchar(50) NOT NULL,
43
- `league` varchar(50) NOT NULL,
44
- PRIMARY KEY (`id`)
45
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
46
-
47
- DROP TABLE IF EXISTS `cricket_teams`;
48
-
49
- CREATE TABLE `cricket_teams` (
50
- `id` int(11) NOT NULL auto_increment,
51
- `name` varchar(50) NOT NULL,
52
- `state` varchar(50) NOT NULL,
53
- PRIMARY KEY (`id`)
54
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
55
-
56
- DROP TABLE IF EXISTS `contacts`;
57
-
58
- CREATE TABLE `contacts` (
59
- `id` int(11) NOT NULL auto_increment,
60
- `phone_number` varchar(50) NOT NULL,
61
- `person_id` int(11) NOT NULL,
62
- PRIMARY KEY (`id`)
63
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
64
-
65
- DROP TABLE IF EXISTS `alphas`;
66
-
67
- CREATE TABLE `alphas` (
68
- `id` int(11) NOT NULL auto_increment,
69
- `name` varchar(50) NOT NULL,
70
- `value` int(11),
71
- `cost` decimal(10,6),
72
- PRIMARY KEY (`id`)
73
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
74
-
75
- DROP TABLE IF EXISTS `betas`;
76
-
77
- CREATE TABLE `betas` (
78
- `id` int(11) NOT NULL auto_increment,
79
- `name` varchar(50) NOT NULL,
80
- `alpha_id` int(11),
81
- `delta` tinyint(1) NOT NULL DEFAULT 0,
82
- PRIMARY KEY (`id`)
83
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
84
-
85
- DROP TABLE IF EXISTS `gammas`;
86
-
87
- CREATE TABLE `gammas` (
88
- `id` int(11) NOT NULL auto_increment,
89
- `name` varchar(50) NOT NULL,
90
- `value` int(11),
91
- `beta_id` int(11),
92
- PRIMARY KEY (`id`)
93
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
94
-
95
- DROP TABLE IF EXISTS `thetas`;
96
-
97
- CREATE TABLE `thetas` (
98
- `id` int(11) NOT NULL auto_increment,
99
- `name` varchar(50) NOT NULL,
100
- `value` int(11),
101
- `alpha_id` int(11),
102
- PRIMARY KEY (`id`)
103
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
104
-
105
- DROP TABLE IF EXISTS `searches`;
106
-
107
- CREATE TABLE `searches` (
108
- `id` int(11) NOT NULL auto_increment,
109
- `name` varchar(50) NOT NULL,
110
- PRIMARY KEY (`id`)
111
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
112
-
113
- DROP TABLE IF EXISTS `tags`;
114
-
115
- CREATE TABLE `tags` (
116
- `id` int(11) NOT NULL auto_increment,
117
- `person_id` int(11) NOT NULL,
118
- `football_team_id` int(11) NOT NULL,
119
- `cricket_team_id` int(11) NOT NULL,
120
- `name` varchar(50) NOT NULL,
121
- PRIMARY KEY (`id`)
122
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
123
-
124
- DROP TABLE IF EXISTS `links`;
125
-
126
- CREATE TABLE `links` (
127
- `id` int(11) NOT NULL auto_increment,
128
- `url` varchar(50) NOT NULL,
129
- `description` varchar(200),
130
- PRIMARY KEY (`id`)
131
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
132
-
133
- DROP TABLE IF EXISTS `links_people`;
134
-
135
- CREATE TABLE `links_people` (
136
- `link_id` int(11) NOT NULL,
137
- `person_id` int(11) NOT NULL
138
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
139
-
140
- DROP TABLE IF EXISTS `big_foos`;
141
-
142
- CREATE TABLE `big_foos` (
143
- `id` bigint NOT NULL auto_increment,
144
- `name` varchar(50) NOT NULL,
145
- PRIMARY KEY (`id`)
146
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
data/spec/spec_helper.rb DELETED
@@ -1,54 +0,0 @@
1
- $:.unshift File.dirname(__FILE__) + '/../lib'
2
-
3
- require 'rubygems'
4
- require 'fileutils'
5
- require 'bundler'
6
-
7
- Bundler.require :default, :development
8
-
9
- require "#{File.dirname(__FILE__)}/sphinx_helper"
10
-
11
- ActiveRecord::Base.logger = Logger.new(StringIO.new)
12
-
13
- RSpec.configure do |config|
14
- %w( tmp tmp/config tmp/log tmp/db ).each do |path|
15
- FileUtils.mkdir_p "#{Dir.pwd}/#{path}"
16
- end
17
-
18
- Kernel.const_set :RAILS_ROOT, "#{Dir.pwd}/tmp" unless defined?(RAILS_ROOT)
19
-
20
- sphinx = SphinxHelper.new
21
- sphinx.setup_mysql
22
-
23
- require "#{File.dirname(__FILE__)}/fixtures/models"
24
- ThinkingSphinx.context.define_indexes
25
-
26
- config.before :each do
27
- %w( tmp tmp/config tmp/log tmp/db ).each do |path|
28
- FileUtils.mkdir_p "#{Dir.pwd}/#{path}"
29
- end
30
-
31
- ThinkingSphinx.updates_enabled = true
32
- ThinkingSphinx.deltas_enabled = true
33
- ThinkingSphinx.suppress_delta_output = true
34
-
35
- ThinkingSphinx::Configuration.instance.reset
36
- end
37
-
38
- config.after :all do
39
- FileUtils.rm_r "#{Dir.pwd}/tmp" rescue nil
40
- end
41
- end
42
-
43
- def minimal_result_hashes(*instances)
44
- instances.collect do |instance|
45
- {
46
- :weight => 21,
47
- :attributes => {
48
- 'sphinx_internal_id' => instance.id,
49
- 'sphinx_internal_class' => instance.class.name,
50
- 'class_crc' => instance.class.name.to_crc32
51
- }
52
- }
53
- end
54
- end
@@ -1,67 +0,0 @@
1
- require 'active_record'
2
- prefix = defined?(JRUBY_VERSION) ? "jdbc" : ""
3
- require "active_record/connection_adapters/#{prefix}mysql_adapter"
4
- require "active_record/connection_adapters/mysql2_adapter"
5
-
6
- begin
7
- require "active_record/connection_adapters/#{prefix}postgresql_adapter"
8
- rescue LoadError
9
- # No postgres? no prob...
10
- end
11
- require 'yaml'
12
-
13
- class SphinxHelper
14
- attr_accessor :host, :username, :password, :socket
15
- attr_reader :path
16
-
17
- def initialize
18
- @host = 'localhost'
19
- @username = 'root'
20
- @password = ''
21
-
22
- if File.exist?('spec/fixtures/database.yml')
23
- config = YAML.load(File.open('spec/fixtures/database.yml'))
24
- @host = config['host']
25
- @username = config['username']
26
- @password = config['password']
27
- @socket = config['socket']
28
- @sslca = config['sslca']
29
- @sslcert = config['sslcert']
30
- @sslkey = config['sslkey']
31
- end
32
-
33
- @path = File.expand_path(File.dirname(__FILE__))
34
- end
35
-
36
- def setup_mysql
37
- ActiveRecord::Base.establish_connection(
38
- :adapter => mysql_adapter,
39
- :database => 'thinking_sphinx',
40
- :username => @username,
41
- :password => @password,
42
- :host => @host,
43
- :socket => @socket,
44
- :sslca => @sslca,
45
- :sslcert => @sslcert,
46
- :sslkey => @sslkey
47
- )
48
- ActiveRecord::Base.logger = Logger.new(File.open('tmp/activerecord.log', 'a'))
49
-
50
- structure = File.open('spec/fixtures/structure.sql') { |f| f.read.chomp }
51
- structure.split(';').each { |table|
52
- ActiveRecord::Base.connection.execute table
53
- }
54
-
55
- File.open('spec/fixtures/data.sql') { |f|
56
- while line = f.gets
57
- ActiveRecord::Base.connection.execute line unless line.blank?
58
- end
59
- }
60
- end
61
-
62
- private
63
-
64
- def mysql_adapter
65
- defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql2'
66
- end
67
- end
@@ -1,163 +0,0 @@
1
- require 'spec_helper'
2
-
3
- class CustomAdapter < ThinkingSphinx::AbstractAdapter
4
- #
5
- end
6
-
7
- describe ThinkingSphinx::AbstractAdapter do
8
- describe '.detect' do
9
- let(:model) { stub('model') }
10
-
11
- it "returns a MysqlAdapter object for :mysql" do
12
- ThinkingSphinx::AbstractAdapter.stub(:adapter_for_model => :mysql)
13
-
14
- adapter = ThinkingSphinx::AbstractAdapter.detect(model)
15
- adapter.should be_a(ThinkingSphinx::MysqlAdapter)
16
- end
17
-
18
- it "returns a PostgreSQLAdapter object for :postgresql" do
19
- ThinkingSphinx::AbstractAdapter.stub(:adapter_for_model => :postgresql)
20
-
21
- adapter = ThinkingSphinx::AbstractAdapter.detect(model)
22
- adapter.should be_a(ThinkingSphinx::PostgreSQLAdapter)
23
- end
24
-
25
- it "instantiates the provided class if one is provided" do
26
- ThinkingSphinx::AbstractAdapter.stub(:adapter_for_model => CustomAdapter)
27
- CustomAdapter.should_receive(:new).and_return(stub('adapter'))
28
-
29
- ThinkingSphinx::AbstractAdapter.detect(model)
30
- end
31
-
32
- it "raises an exception for other responses" do
33
- ThinkingSphinx::AbstractAdapter.stub(:adapter_for_model => :sqlite)
34
-
35
- lambda {
36
- ThinkingSphinx::AbstractAdapter.detect(model)
37
- }.should raise_error
38
- end
39
- end
40
-
41
- describe '.adapter_for_model' do
42
- let(:model) { stub('model') }
43
-
44
- after :each do
45
- ThinkingSphinx.database_adapter = nil
46
- end
47
-
48
- it "translates strings to symbols" do
49
- ThinkingSphinx.database_adapter = 'foo'
50
-
51
- ThinkingSphinx::AbstractAdapter.adapter_for_model(model).should == :foo
52
- end
53
-
54
- it "passes through symbols unchanged" do
55
- ThinkingSphinx.database_adapter = :bar
56
-
57
- ThinkingSphinx::AbstractAdapter.adapter_for_model(model).should == :bar
58
- end
59
-
60
- it "returns standard_adapter_for_model if database_adapter is not set" do
61
- ThinkingSphinx.database_adapter = nil
62
- ThinkingSphinx::AbstractAdapter.stub!(:standard_adapter_for_model => :baz)
63
-
64
- ThinkingSphinx::AbstractAdapter.adapter_for_model(model).should == :baz
65
- end
66
-
67
- it "calls the lambda and returns it if one is provided" do
68
- ThinkingSphinx.database_adapter = lambda { |model| :foo }
69
-
70
- ThinkingSphinx::AbstractAdapter.adapter_for_model(model).should == :foo
71
- end
72
- end
73
-
74
- describe '.standard_adapter_for_model' do
75
- let(:klass) { stub('connection class') }
76
- let(:connection) { stub('connection', :class => klass) }
77
- let(:model) { stub('model', :connection => connection) }
78
-
79
- it "translates a normal MySQL adapter" do
80
- klass.stub(:name => 'ActiveRecord::ConnectionAdapters::MysqlAdapter')
81
-
82
- ThinkingSphinx::AbstractAdapter.standard_adapter_for_model(model).
83
- should == :mysql
84
- end
85
-
86
- it "translates a MySQL plus adapter" do
87
- klass.stub(:name => 'ActiveRecord::ConnectionAdapters::MysqlplusAdapter')
88
-
89
- ThinkingSphinx::AbstractAdapter.standard_adapter_for_model(model).
90
- should == :mysql
91
- end
92
-
93
- it "translates a MySQL2 adapter" do
94
- klass.stub(:name => 'ActiveRecord::ConnectionAdapters::Mysql2Adapter')
95
-
96
- ThinkingSphinx::AbstractAdapter.standard_adapter_for_model(model).
97
- should == :mysql
98
- end
99
-
100
- it "translates a NullDB adapter to MySQL" do
101
- klass.stub(:name => 'ActiveRecord::ConnectionAdapters::NullDBAdapter')
102
-
103
- ThinkingSphinx::AbstractAdapter.standard_adapter_for_model(model).
104
- should == :mysql
105
- end
106
-
107
- it "translates a normal PostgreSQL adapter" do
108
- klass.stub(:name => 'ActiveRecord::ConnectionAdapters::PostgreSQLAdapter')
109
-
110
- ThinkingSphinx::AbstractAdapter.standard_adapter_for_model(model).
111
- should == :postgresql
112
- end
113
-
114
- it "translates a JDBC MySQL adapter to MySQL" do
115
- klass.stub(:name => 'ActiveRecord::ConnectionAdapters::JdbcAdapter')
116
- connection.stub(:config => {:adapter => 'jdbcmysql'})
117
-
118
- ThinkingSphinx::AbstractAdapter.standard_adapter_for_model(model).
119
- should == :mysql
120
- end
121
-
122
- it "translates a JDBC PostgreSQL adapter to PostgreSQL" do
123
- klass.stub(:name => 'ActiveRecord::ConnectionAdapters::JdbcAdapter')
124
- connection.stub(:config => {:adapter => 'jdbcpostgresql'})
125
-
126
- ThinkingSphinx::AbstractAdapter.standard_adapter_for_model(model).
127
- should == :postgresql
128
- end
129
-
130
- it "translates a JDBC adapter with MySQL connection string to MySQL" do
131
- klass.stub(:name => 'ActiveRecord::ConnectionAdapters::JdbcAdapter')
132
- connection.stub(:config => {:adapter => 'jdbc',
133
- :url => 'jdbc:mysql://127.0.0.1:3306/sphinx'})
134
-
135
- ThinkingSphinx::AbstractAdapter.standard_adapter_for_model(model).
136
- should == :mysql
137
- end
138
-
139
- it "translates a JDBC adapter with PostgresSQL connection string to PostgresSQL" do
140
- klass.stub(:name => 'ActiveRecord::ConnectionAdapters::JdbcAdapter')
141
- connection.stub(:config => {:adapter => 'jdbc',
142
- :url => 'jdbc:postgresql://127.0.0.1:3306/sphinx'})
143
-
144
- ThinkingSphinx::AbstractAdapter.standard_adapter_for_model(model).
145
- should == :postgresql
146
- end
147
-
148
- it "returns other JDBC adapters without translation" do
149
- klass.stub(:name => 'ActiveRecord::ConnectionAdapters::JdbcAdapter')
150
- connection.stub(:config => {:adapter => 'jdbcmssql'})
151
-
152
- ThinkingSphinx::AbstractAdapter.standard_adapter_for_model(model).
153
- should == :jdbcmssql
154
- end
155
-
156
- it "returns other unknown adapters without translation" do
157
- klass.stub(:name => 'ActiveRecord::ConnectionAdapters::FooAdapter')
158
-
159
- ThinkingSphinx::AbstractAdapter.standard_adapter_for_model(model).
160
- should == 'ActiveRecord::ConnectionAdapters::FooAdapter'
161
- end
162
- end
163
- end
@@ -1,77 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe ThinkingSphinx::Connection do
4
- describe '#client' do
5
- let(:connection) { ThinkingSphinx::Connection.new }
6
-
7
- before :each do
8
- @config = ThinkingSphinx::Configuration.instance
9
- @config.address = 'domain.url'
10
- @config.port = 3333
11
- @config.configuration.searchd.max_matches = 100
12
- @config.timeout = 1
13
-
14
- pending
15
- end
16
-
17
- it "should return an instance of Riddle::Client" do
18
- connection.client.should be_a(Riddle::Client)
19
- end
20
-
21
- it "should use the configuration address" do
22
- connection.client.server.should == 'domain.url'
23
- end
24
-
25
- it "should use the configuration port" do
26
- connection.client.port.should == 3333
27
- end
28
-
29
- it "should use the configuration max matches" do
30
- connection.client.max_matches.should == 100
31
- end
32
-
33
- it "should use the configuration timeout" do
34
- connection.client.timeout.should == 1
35
- end
36
-
37
- describe 'when shuffle is enabled' do
38
- let(:client) { double('client', :max_matches= => nil, :timeout= => nil,
39
- :open => true) }
40
-
41
- before :each do
42
- @config.shuffle = true
43
- end
44
-
45
- it "should shuffle client servers" do
46
- @config.address = ['1.1.1.1', '2.2.2.2']
47
- @config.address.stub!(:shuffle => ['2.2.2.2', '1.1.1.1'])
48
-
49
- Riddle::Client.should_receive(:new) do |addresses, port, key|
50
- addresses.should == ['2.2.2.2', '1.1.1.1']
51
- client
52
- end
53
- connection.client
54
- end
55
- end
56
-
57
- describe 'when shuffle is disabled' do
58
- let(:client) { double('client', :max_matches= => nil, :timeout= => nil,
59
- :open => true) }
60
-
61
- before :each do
62
- @config.shuffle = false
63
- end
64
-
65
- it "should not shuffle client servers" do
66
- @config.address = ['1.1.1.1', '2.2.2.2.', '3.3.3.3', '4.4.4.4', '5.5.5.5']
67
-
68
- @config.address.should_not_receive(:shuffle)
69
- Riddle::Client.should_receive(:new) do |addresses, port, key|
70
- addresses.should == ['1.1.1.1', '2.2.2.2.', '3.3.3.3', '4.4.4.4', '5.5.5.5']
71
- client
72
- end
73
- connection.client
74
- end
75
- end
76
- end
77
- end