activerecord-oracle_enhanced-adapter 1.6.9 → 1.7.0.beta1

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.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +10 -11
  3. data/History.md +126 -14
  4. data/README.md +9 -6
  5. data/RUNNING_TESTS.md +1 -1
  6. data/Rakefile +1 -16
  7. data/VERSION +1 -1
  8. data/activerecord-oracle_enhanced-adapter.gemspec +15 -52
  9. data/lib/active_record/connection_adapters/oracle_enhanced/column.rb +8 -22
  10. data/lib/active_record/connection_adapters/oracle_enhanced/column_dumper.rb +53 -45
  11. data/lib/active_record/connection_adapters/oracle_enhanced/connection.rb +6 -1
  12. data/lib/active_record/connection_adapters/oracle_enhanced/database_statements.rb +23 -62
  13. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_connection.rb +46 -56
  14. data/lib/active_record/connection_adapters/oracle_enhanced/jdbc_quoting.rb +35 -0
  15. data/lib/active_record/connection_adapters/oracle_enhanced/oci_connection.rb +34 -21
  16. data/lib/active_record/connection_adapters/oracle_enhanced/oci_quoting.rb +36 -0
  17. data/lib/active_record/connection_adapters/oracle_enhanced/procedures.rb +1 -1
  18. data/lib/active_record/connection_adapters/oracle_enhanced/quoting.rb +174 -0
  19. data/lib/active_record/connection_adapters/oracle_enhanced/schema_creation.rb +17 -8
  20. data/lib/active_record/connection_adapters/oracle_enhanced/schema_definitions.rb +17 -11
  21. data/lib/active_record/connection_adapters/oracle_enhanced/schema_dumper.rb +160 -178
  22. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements.rb +42 -94
  23. data/lib/active_record/connection_adapters/oracle_enhanced/schema_statements_ext.rb +50 -54
  24. data/lib/active_record/connection_adapters/oracle_enhanced/structure_dump.rb +15 -11
  25. data/lib/active_record/connection_adapters/oracle_enhanced_adapter.rb +197 -301
  26. data/lib/active_record/oracle_enhanced/type/integer.rb +3 -2
  27. data/lib/active_record/oracle_enhanced/type/national_character_string.rb +25 -0
  28. data/lib/active_record/oracle_enhanced/type/raw.rb +14 -2
  29. data/lib/active_record/oracle_enhanced/type/string.rb +28 -0
  30. data/lib/active_record/oracle_enhanced/type/text.rb +32 -0
  31. data/lib/activerecord-oracle_enhanced-adapter.rb +12 -17
  32. data/spec/active_record/connection_adapters/oracle_enhanced_adapter_spec.rb +113 -135
  33. data/spec/active_record/connection_adapters/oracle_enhanced_connection_spec.rb +51 -59
  34. data/spec/active_record/connection_adapters/oracle_enhanced_context_index_spec.rb +40 -41
  35. data/spec/active_record/connection_adapters/oracle_enhanced_cpk_spec.rb +6 -6
  36. data/spec/active_record/connection_adapters/oracle_enhanced_data_types_spec.rb +281 -233
  37. data/spec/active_record/connection_adapters/oracle_enhanced_database_tasks_spec.rb +7 -7
  38. data/spec/active_record/connection_adapters/oracle_enhanced_dbms_output_spec.rb +10 -10
  39. data/spec/active_record/connection_adapters/oracle_enhanced_dirty_spec.rb +22 -22
  40. data/spec/active_record/connection_adapters/oracle_enhanced_emulate_oracle_adapter_spec.rb +2 -2
  41. data/spec/active_record/connection_adapters/oracle_enhanced_procedures_spec.rb +36 -37
  42. data/spec/active_record/connection_adapters/oracle_enhanced_schema_dump_spec.rb +86 -46
  43. data/spec/active_record/connection_adapters/oracle_enhanced_schema_statements_spec.rb +194 -294
  44. data/spec/active_record/connection_adapters/oracle_enhanced_structure_dump_spec.rb +53 -39
  45. data/spec/spec_helper.rb +0 -6
  46. metadata +42 -143
  47. data/.travis.yml +0 -39
  48. data/.travis/oracle/download.sh +0 -14
  49. data/.travis/oracle/install.sh +0 -31
  50. data/.travis/setup_accounts.sh +0 -9
  51. data/lib/active_record/connection_adapters/oracle_enhanced/dirty.rb +0 -40
  52. data/lib/active_record/oracle_enhanced/type/timestamp.rb +0 -11
  53. data/spec/spec_config.yaml.template +0 -11
  54. data/spec/support/alter_system_user_password.sql +0 -2
  55. data/spec/support/create_oracle_enhanced_users.sql +0 -31
@@ -12,25 +12,25 @@ describe "OracleEnhancedConnection" do
12
12
  end
13
13
 
14
14
  it "should create new connection" do
15
- @conn.should be_active
15
+ expect(@conn).to be_active
16
16
  end
17
17
 
18
18
  it "should ping active connection" do
19
- @conn.ping.should be true
19
+ expect(@conn.ping).to be_truthy
20
20
  end
21
21
 
22
22
  it "should not ping inactive connection" do
23
23
  @conn.logoff
24
- lambda { @conn.ping }.should raise_error(ActiveRecord::ConnectionAdapters::OracleEnhancedConnectionException)
24
+ expect { @conn.ping }.to raise_error(ActiveRecord::ConnectionAdapters::OracleEnhancedConnectionException)
25
25
  end
26
26
 
27
27
  it "should reset active connection" do
28
28
  @conn.reset!
29
- @conn.should be_active
29
+ expect(@conn).to be_active
30
30
  end
31
31
 
32
32
  it "should be in autocommit mode after connection" do
33
- @conn.should be_autocommit
33
+ expect(@conn).to be_autocommit
34
34
  end
35
35
 
36
36
  end
@@ -45,16 +45,16 @@ describe "OracleEnhancedConnection" do
45
45
  end
46
46
 
47
47
  it "should create new connection" do
48
- @conn.should be_active
48
+ expect(@conn).to be_active
49
49
  end
50
50
 
51
51
  it "should swith to specified schema" do
52
- @conn.select_value("select SYS_CONTEXT('userenv', 'current_schema') from dual").should == CONNECTION_WITH_SCHEMA_PARAMS[:schema].upcase
52
+ expect(@conn.select_value("select SYS_CONTEXT('userenv', 'current_schema') from dual")).to eq(CONNECTION_WITH_SCHEMA_PARAMS[:schema].upcase)
53
53
  end
54
54
 
55
55
  it "should swith to specified schema after reset" do
56
56
  @conn.reset!
57
- @conn.select_value("select SYS_CONTEXT('userenv', 'current_schema') from dual").should == CONNECTION_WITH_SCHEMA_PARAMS[:schema].upcase
57
+ expect(@conn.select_value("select SYS_CONTEXT('userenv', 'current_schema') from dual")).to eq(CONNECTION_WITH_SCHEMA_PARAMS[:schema].upcase)
58
58
  end
59
59
 
60
60
  end
@@ -67,20 +67,20 @@ describe "OracleEnhancedConnection" do
67
67
  it "should use NLS_DATE_FORMAT environment variable" do
68
68
  ENV['NLS_DATE_FORMAT'] = 'YYYY-MM-DD'
69
69
  @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(CONNECTION_PARAMS)
70
- @conn.select("SELECT value FROM v$nls_parameters WHERE parameter = 'NLS_DATE_FORMAT'").should == [{'value' => 'YYYY-MM-DD'}]
70
+ expect(@conn.select("SELECT value FROM v$nls_parameters WHERE parameter = 'NLS_DATE_FORMAT'")).to eq([{'value' => 'YYYY-MM-DD'}])
71
71
  end
72
72
 
73
73
  it "should use configuration value and ignore NLS_DATE_FORMAT environment variable" do
74
74
  ENV['NLS_DATE_FORMAT'] = 'YYYY-MM-DD'
75
75
  @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(CONNECTION_PARAMS.merge(:nls_date_format => 'YYYY-MM-DD HH24:MI'))
76
- @conn.select("SELECT value FROM v$nls_parameters WHERE parameter = 'NLS_DATE_FORMAT'").should == [{'value' => 'YYYY-MM-DD HH24:MI'}]
76
+ expect(@conn.select("SELECT value FROM v$nls_parameters WHERE parameter = 'NLS_DATE_FORMAT'")).to eq([{'value' => 'YYYY-MM-DD HH24:MI'}])
77
77
  end
78
78
 
79
79
  it "should use default value when NLS_DATE_FORMAT environment variable is not set" do
80
80
  ENV['NLS_DATE_FORMAT'] = nil
81
81
  @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(CONNECTION_PARAMS)
82
82
  default = ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter::DEFAULT_NLS_PARAMETERS[:nls_date_format]
83
- @conn.select("SELECT value FROM v$nls_parameters WHERE parameter = 'NLS_DATE_FORMAT'").should == [{'value' => default}]
83
+ expect(@conn.select("SELECT value FROM v$nls_parameters WHERE parameter = 'NLS_DATE_FORMAT'")).to eq([{'value' => default}])
84
84
  end
85
85
  end
86
86
 
@@ -94,7 +94,7 @@ describe "OracleEnhancedConnection" do
94
94
  end
95
95
 
96
96
  it "should create new connection" do
97
- @conn.should be_active
97
+ expect(@conn).to be_active
98
98
  end
99
99
  end
100
100
 
@@ -106,24 +106,7 @@ describe "OracleEnhancedConnection" do
106
106
  end
107
107
 
108
108
  it "should create new connection" do
109
- @conn.should be_active
110
- end
111
- end
112
-
113
- describe 'with host="connection-string"' do
114
- let(:username) { CONNECTION_PARAMS[:username] }
115
- let(:password) { CONNECTION_PARAMS[:password] }
116
- let(:connection_string) { "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=tcp)(HOST=#{DATABASE_HOST})(PORT=#{DATABASE_PORT})))(CONNECT_DATA=(SERVICE_NAME=#{DATABASE_NAME})))" }
117
- let(:params) { { username: username, password: password, host: 'connection-string', database: connection_string } }
118
-
119
- it 'uses the database param as the connection string' do
120
- if ORACLE_ENHANCED_CONNECTION == :jdbc
121
- expect(java.sql.DriverManager).to receive(:getConnection).with("jdbc:oracle:thin:@#{connection_string}", anything).and_call_original
122
- else
123
- expect(OCI8).to receive(:new).with(username, password, connection_string, nil).and_call_original
124
- end
125
- conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(params)
126
- expect(conn).to be_active
109
+ expect(@conn).to be_active
127
110
  end
128
111
  end
129
112
 
@@ -138,7 +121,7 @@ describe "OracleEnhancedConnection" do
138
121
  params[:host] = nil
139
122
  params[:database] = nil
140
123
  @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(params)
141
- @conn.should be_active
124
+ expect(@conn).to be_active
142
125
  end
143
126
 
144
127
  it "should create new connection using :url and tnsnames alias" do
@@ -147,14 +130,14 @@ describe "OracleEnhancedConnection" do
147
130
  params[:host] = nil
148
131
  params[:database] = nil
149
132
  @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(params)
150
- @conn.should be_active
133
+ expect(@conn).to be_active
151
134
  end
152
135
 
153
136
  it "should create new connection using just tnsnames alias" do
154
137
  params = CONNECTION_PARAMS.dup
155
138
  params[:host] = nil
156
139
  @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(params)
157
- @conn.should be_active
140
+ expect(@conn).to be_active
158
141
  end
159
142
 
160
143
  it "should create a new connection using JNDI" do
@@ -187,12 +170,12 @@ describe "OracleEnhancedConnection" do
187
170
  end
188
171
  end
189
172
 
190
- javax.naming.InitialContext.stub(:new).and_return(InitialContextMock.new)
173
+ allow(javax.naming.InitialContext).to receive(:new).and_return(InitialContextMock.new)
191
174
 
192
175
  params = {}
193
176
  params[:jndi] = 'java:comp/env/jdbc/test'
194
177
  @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(params)
195
- @conn.should be_active
178
+ expect(@conn).to be_active
196
179
  end
197
180
 
198
181
  end
@@ -202,9 +185,9 @@ describe "OracleEnhancedConnection" do
202
185
  params[:url] = "jdbc:oracle:thin:@#{DATABASE_HOST && "//#{DATABASE_HOST}#{DATABASE_PORT && ":#{DATABASE_PORT}"}/"}#{DATABASE_NAME}"
203
186
  params[:host] = nil
204
187
  params[:database] = nil
205
- java.sql.DriverManager.stub(:getConnection).and_raise('no suitable driver found')
188
+ allow(java.sql.DriverManager).to receive(:getConnection).and_raise('no suitable driver found')
206
189
  @conn = ActiveRecord::ConnectionAdapters::OracleEnhancedConnection.create(params)
207
- @conn.should be_active
190
+ expect(@conn).to be_active
208
191
  end
209
192
 
210
193
  end
@@ -215,15 +198,15 @@ describe "OracleEnhancedConnection" do
215
198
  end
216
199
 
217
200
  it "should execute SQL statement" do
218
- @conn.exec("SELECT * FROM dual").should_not be_nil
201
+ expect(@conn.exec("SELECT * FROM dual")).not_to be_nil
219
202
  end
220
203
 
221
204
  it "should execute SQL select" do
222
- @conn.select("SELECT * FROM dual").should == [{'dummy' => 'X'}]
205
+ expect(@conn.select("SELECT * FROM dual")).to eq([{'dummy' => 'X'}])
223
206
  end
224
207
 
225
208
  it "should execute SQL select and return also columns" do
226
- @conn.select("SELECT * FROM dual", nil, true).should == [ [{'dummy' => 'X'}], ['dummy'] ]
209
+ expect(@conn.select("SELECT * FROM dual", nil, true)).to eq([ [{'dummy' => 'X'}], ['dummy'] ])
227
210
  end
228
211
 
229
212
  end
@@ -237,8 +220,8 @@ describe "OracleEnhancedConnection" do
237
220
  cursor = @conn.prepare("SELECT * FROM dual WHERE :1 = 1")
238
221
  cursor.bind_param(1, 1)
239
222
  cursor.exec
240
- cursor.get_col_names.should == ['DUMMY']
241
- cursor.fetch.should == ["X"]
223
+ expect(cursor.get_col_names).to eq(['DUMMY'])
224
+ expect(cursor.fetch).to eq(["X"])
242
225
  cursor.close
243
226
  end
244
227
 
@@ -246,10 +229,10 @@ describe "OracleEnhancedConnection" do
246
229
  cursor = @conn.prepare("SELECT * FROM dual WHERE :1 = 1")
247
230
  cursor.bind_param(1, 1)
248
231
  cursor.exec
249
- cursor.fetch.should == ["X"]
232
+ expect(cursor.fetch).to eq(["X"])
250
233
  cursor.bind_param(1, 0)
251
234
  cursor.exec
252
- cursor.fetch.should be_nil
235
+ expect(cursor.fetch).to be_nil
253
236
  cursor.close
254
237
  end
255
238
  end
@@ -268,14 +251,15 @@ describe "OracleEnhancedConnection" do
268
251
 
269
252
  it "should execute prepared statement with decimal bind parameter " do
270
253
  cursor = @conn.prepare("INSERT INTO test_employees VALUES(:1)")
271
- column = ActiveRecord::ConnectionAdapters::OracleEnhancedColumn.new('age', nil, ActiveRecord::Type::Decimal.new, 'NUMBER(10,2)')
272
- column.type.should == :decimal
254
+ type_metadata = ActiveRecord::ConnectionAdapters::SqlTypeMetadata.new(sql_type: "NUMBER", type: :decimal, limit: 10, precision: nil, scale: 2)
255
+ column = ActiveRecord::ConnectionAdapters::OracleEnhancedColumn.new('age', nil, type_metadata, false, "test_employees", false, false, nil)
256
+ expect(column.type).to eq(:decimal)
273
257
  cursor.bind_param(1, "1.5", column)
274
258
  cursor.exec
275
259
  cursor.close
276
260
  cursor = @conn.prepare("SELECT age FROM test_employees")
277
261
  cursor.exec
278
- cursor.fetch.should == [1.5]
262
+ expect(cursor.fetch).to eq([1.5])
279
263
  cursor.close
280
264
  end
281
265
  end
@@ -303,28 +287,36 @@ describe "OracleEnhancedConnection" do
303
287
  # @conn.auto_retry = true
304
288
  ActiveRecord::Base.connection.auto_retry = true
305
289
  kill_current_session
306
- @conn.exec("SELECT * FROM dual").should_not be_nil
290
+ expect(@conn.exec("SELECT * FROM dual")).not_to be_nil
307
291
  end
308
292
 
309
293
  it "should not reconnect and execute SQL statement if connection is lost and auto retry is disabled" do
310
294
  # @conn.auto_retry = false
311
295
  ActiveRecord::Base.connection.auto_retry = false
312
296
  kill_current_session
313
- lambda { @conn.exec("SELECT * FROM dual") }.should raise_error
297
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
298
+ expect { @conn.exec("SELECT * FROM dual") }.to raise_error(NativeException)
299
+ else
300
+ expect { @conn.exec("SELECT * FROM dual") }.to raise_error(OCIError)
301
+ end
314
302
  end
315
303
 
316
304
  it "should reconnect and execute SQL select if connection is lost and auto retry is enabled" do
317
305
  # @conn.auto_retry = true
318
306
  ActiveRecord::Base.connection.auto_retry = true
319
307
  kill_current_session
320
- @conn.select("SELECT * FROM dual").should == [{'dummy' => 'X'}]
308
+ expect(@conn.select("SELECT * FROM dual")).to eq([{'dummy' => 'X'}])
321
309
  end
322
310
 
323
311
  it "should not reconnect and execute SQL select if connection is lost and auto retry is disabled" do
324
312
  # @conn.auto_retry = false
325
313
  ActiveRecord::Base.connection.auto_retry = false
326
314
  kill_current_session
327
- lambda { @conn.select("SELECT * FROM dual") }.should raise_error
315
+ if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
316
+ expect { @conn.select("SELECT * FROM dual") }.to raise_error(NativeException)
317
+ else
318
+ expect { @conn.select("SELECT * FROM dual") }.to raise_error(OCIError)
319
+ end
328
320
  end
329
321
 
330
322
  end
@@ -337,45 +329,45 @@ describe "OracleEnhancedConnection" do
337
329
 
338
330
  it "should describe existing table" do
339
331
  @conn.exec "CREATE TABLE test_employees (first_name VARCHAR2(20))" rescue nil
340
- @conn.describe("test_employees").should == [@owner, "TEST_EMPLOYEES"]
332
+ expect(@conn.describe("test_employees")).to eq([@owner, "TEST_EMPLOYEES"])
341
333
  @conn.exec "DROP TABLE test_employees" rescue nil
342
334
  end
343
335
 
344
336
  it "should not describe non-existing table" do
345
- lambda { @conn.describe("test_xxx") }.should raise_error(ActiveRecord::ConnectionAdapters::OracleEnhancedConnectionException)
337
+ expect { @conn.describe("test_xxx") }.to raise_error(ActiveRecord::ConnectionAdapters::OracleEnhancedConnectionException)
346
338
  end
347
339
 
348
340
  it "should describe table in other schema" do
349
- @conn.describe("sys.dual").should == ["SYS", "DUAL"]
341
+ expect(@conn.describe("sys.dual")).to eq(["SYS", "DUAL"])
350
342
  end
351
343
 
352
344
  it "should describe existing view" do
353
345
  @conn.exec "CREATE TABLE test_employees (first_name VARCHAR2(20))" rescue nil
354
346
  @conn.exec "CREATE VIEW test_employees_v AS SELECT * FROM test_employees" rescue nil
355
- @conn.describe("test_employees_v").should == [@owner, "TEST_EMPLOYEES_V"]
347
+ expect(@conn.describe("test_employees_v")).to eq([@owner, "TEST_EMPLOYEES_V"])
356
348
  @conn.exec "DROP VIEW test_employees_v" rescue nil
357
349
  @conn.exec "DROP TABLE test_employees" rescue nil
358
350
  end
359
351
 
360
352
  it "should describe view in other schema" do
361
- @conn.describe("sys.v_$version").should == ["SYS", "V_$VERSION"]
353
+ expect(@conn.describe("sys.v_$version")).to eq(["SYS", "V_$VERSION"])
362
354
  end
363
355
 
364
356
  it "should describe existing private synonym" do
365
357
  @conn.exec "CREATE SYNONYM test_dual FOR sys.dual" rescue nil
366
- @conn.describe("test_dual").should == ["SYS", "DUAL"]
358
+ expect(@conn.describe("test_dual")).to eq(["SYS", "DUAL"])
367
359
  @conn.exec "DROP SYNONYM test_dual" rescue nil
368
360
  end
369
361
 
370
362
  it "should describe existing public synonym" do
371
- @conn.describe("all_tables").should == ["SYS", "ALL_TABLES"]
363
+ expect(@conn.describe("all_tables")).to eq(["SYS", "ALL_TABLES"])
372
364
  end
373
365
 
374
366
  if defined?(OCI8)
375
367
  context "OCI8 adapter" do
376
368
 
377
369
  it "should not fallback to SELECT-based logic when querying non-existant table information" do
378
- @conn.should_not_receive(:select_one)
370
+ expect(@conn).not_to receive(:select_one)
379
371
  @conn.describe("non_existant") rescue ActiveRecord::ConnectionAdapters::OracleEnhancedConnectionException
380
372
  end
381
373
 
@@ -1,4 +1,3 @@
1
- # encoding: utf-8
2
1
  require 'spec_helper'
3
2
 
4
3
  describe "OracleEnhancedAdapter context index" do
@@ -88,7 +87,7 @@ describe "OracleEnhancedAdapter context index" do
88
87
  it "should create single VARCHAR2 column index" do
89
88
  @conn.add_context_index :posts, :title
90
89
  @title_words.each do |word|
91
- Post.contains(:title, word).to_a.should == [@post2, @post1]
90
+ expect(Post.contains(:title, word).to_a).to eq([@post2, @post1])
92
91
  end
93
92
  @conn.remove_context_index :posts, :title
94
93
  end
@@ -96,28 +95,28 @@ describe "OracleEnhancedAdapter context index" do
96
95
  it "should create single CLOB column index" do
97
96
  @conn.add_context_index :posts, :body
98
97
  @body_words.each do |word|
99
- Post.contains(:body, word).to_a.should == [@post2, @post1]
98
+ expect(Post.contains(:body, word).to_a).to eq([@post2, @post1])
100
99
  end
101
100
  @conn.remove_context_index :posts, :body
102
101
  end
103
102
 
104
103
  it "should not include text index secondary tables in user tables list" do
105
104
  @conn.add_context_index :posts, :title
106
- @conn.tables.any?{|t| t =~ /^dr\$/i}.should be false
105
+ expect(@conn.tables.any?{|t| t =~ /^dr\$/i}).to be_falsey
107
106
  @conn.remove_context_index :posts, :title
108
107
  end
109
108
 
110
109
  it "should create multiple column index" do
111
110
  @conn.add_context_index :posts, [:title, :body]
112
111
  (@title_words+@body_words).each do |word|
113
- Post.contains(:title, word).to_a.should == [@post2, @post1]
112
+ expect(Post.contains(:title, word).to_a).to eq([@post2, @post1])
114
113
  end
115
114
  @conn.remove_context_index :posts, [:title, :body]
116
115
  end
117
116
 
118
117
  it "should index records with null values" do
119
118
  @conn.add_context_index :posts, [:title, :body]
120
- Post.contains(:title, "withnull").to_a.should == [@post_with_null_body, @post_with_null_title]
119
+ expect(Post.contains(:title, "withnull").to_a).to eq([@post_with_null_body, @post_with_null_title])
121
120
  @conn.remove_context_index :posts, [:title, :body]
122
121
  end
123
122
 
@@ -125,14 +124,14 @@ describe "OracleEnhancedAdapter context index" do
125
124
  @conn.add_context_index :posts, [:title, :body],
126
125
  index_column: :all_text, sync: 'ON COMMIT'
127
126
  @post = Post.create(title: "abc", body: "def")
128
- Post.contains(:all_text, "abc").to_a.should == [@post]
129
- Post.contains(:all_text, "def").to_a.should == [@post]
127
+ expect(Post.contains(:all_text, "abc").to_a).to eq([@post])
128
+ expect(Post.contains(:all_text, "def").to_a).to eq([@post])
130
129
  @post.update_attributes!(title: "ghi")
131
130
  # index will not be updated as all_text column is not changed
132
- Post.contains(:all_text, "ghi").to_a.should be_empty
131
+ expect(Post.contains(:all_text, "ghi").to_a).to be_empty
133
132
  @post.update_attributes!(all_text: "1")
134
133
  # index will be updated when all_text column is changed
135
- Post.contains(:all_text, "ghi").to_a.should == [@post]
134
+ expect(Post.contains(:all_text, "ghi").to_a).to eq([@post])
136
135
  @conn.remove_context_index :posts, index_column: :all_text
137
136
  end
138
137
 
@@ -141,11 +140,11 @@ describe "OracleEnhancedAdapter context index" do
141
140
  index_column: :all_text, index_column_trigger_on: [:created_at, :updated_at],
142
141
  sync: 'ON COMMIT'
143
142
  @post = Post.create(title: "abc", body: "def")
144
- Post.contains(:all_text, "abc").to_a.should == [@post]
145
- Post.contains(:all_text, "def").to_a.should == [@post]
143
+ expect(Post.contains(:all_text, "abc").to_a).to eq([@post])
144
+ expect(Post.contains(:all_text, "def").to_a).to eq([@post])
146
145
  @post.update_attributes!(title: "ghi")
147
146
  # index should be updated as created_at column is changed
148
- Post.contains(:all_text, "ghi").to_a.should == [@post]
147
+ expect(Post.contains(:all_text, "ghi").to_a).to eq([@post])
149
148
  @conn.remove_context_index :posts, index_column: :all_text
150
149
  end
151
150
 
@@ -153,9 +152,9 @@ describe "OracleEnhancedAdapter context index" do
153
152
  @post = Post.create!(title: "āčē", body: "dummy")
154
153
  @conn.add_context_index :posts, :title,
155
154
  lexer: { type: "BASIC_LEXER", base_letter_type: 'GENERIC', base_letter: true }
156
- Post.contains(:title, "āčē").to_a.should == [@post]
157
- Post.contains(:title, "ace").to_a.should == [@post]
158
- Post.contains(:title, "ACE").to_a.should == [@post]
155
+ expect(Post.contains(:title, "āčē").to_a).to eq([@post])
156
+ expect(Post.contains(:title, "ace").to_a).to eq([@post])
157
+ expect(Post.contains(:title, "ACE").to_a).to eq([@post])
159
158
  @conn.remove_context_index :posts, :title
160
159
  end
161
160
 
@@ -163,9 +162,9 @@ describe "OracleEnhancedAdapter context index" do
163
162
  @conn.add_context_index :posts, :title, transactional: true
164
163
  Post.transaction do
165
164
  @post = Post.create(title: "abc")
166
- Post.contains(:title, "abc").to_a.should == [@post]
165
+ expect(Post.contains(:title, "abc").to_a).to eq([@post])
167
166
  @post.update_attributes!(title: "ghi")
168
- Post.contains(:title, "ghi").to_a.should == [@post]
167
+ expect(Post.contains(:title, "ghi").to_a).to eq([@post])
169
168
  end
170
169
  @conn.remove_context_index :posts, :title
171
170
  end
@@ -218,7 +217,7 @@ describe "OracleEnhancedAdapter context index" do
218
217
  @post.comments.create!(author: "ccc", body: "ddd")
219
218
  @post.comments.create!(author: "eee", body: "fff")
220
219
  ["aaa", "bbb", "ccc", "ddd", "eee", "fff"].each do |word|
221
- Post.contains(:all_text, word).to_a.should == [@post]
220
+ expect(Post.contains(:all_text, word).to_a).to eq([@post])
222
221
  end
223
222
  end
224
223
 
@@ -239,7 +238,7 @@ describe "OracleEnhancedAdapter context index" do
239
238
  @post.comments.create!(author: "ccc", body: "ddd")
240
239
  @post.comments.create!(author: "eee", body: "fff")
241
240
  ["aaa", "bbb", "ccc", "ddd", "eee", "fff"].each do |word|
242
- Post.contains(:all_text, word).to_a.should == [@post]
241
+ expect(Post.contains(:all_text, word).to_a).to eq([@post])
243
242
  end
244
243
  end
245
244
 
@@ -252,14 +251,14 @@ describe "OracleEnhancedAdapter context index" do
252
251
  "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"
253
252
  ],
254
253
  index_column: :all_text
255
- Post.contains(:all_text, "aaa within title").to_a.should == [@post]
256
- Post.contains(:all_text, "aaa within body").to_a.should be_empty
257
- Post.contains(:all_text, "bbb within body").to_a.should == [@post]
258
- Post.contains(:all_text, "bbb within title").to_a.should be_empty
259
- Post.contains(:all_text, "ccc within comment_author").to_a.should == [@post]
260
- Post.contains(:all_text, "ccc within comment_body").to_a.should be_empty
261
- Post.contains(:all_text, "ddd within comment_body").to_a.should == [@post]
262
- Post.contains(:all_text, "ddd within comment_author").to_a.should be_empty
254
+ expect(Post.contains(:all_text, "aaa within title").to_a).to eq([@post])
255
+ expect(Post.contains(:all_text, "aaa within body").to_a).to be_empty
256
+ expect(Post.contains(:all_text, "bbb within body").to_a).to eq([@post])
257
+ expect(Post.contains(:all_text, "bbb within title").to_a).to be_empty
258
+ expect(Post.contains(:all_text, "ccc within comment_author").to_a).to eq([@post])
259
+ expect(Post.contains(:all_text, "ccc within comment_body").to_a).to be_empty
260
+ expect(Post.contains(:all_text, "ddd within comment_body").to_a).to eq([@post])
261
+ expect(Post.contains(:all_text, "ddd within comment_author").to_a).to be_empty
263
262
  end
264
263
 
265
264
  end
@@ -289,22 +288,22 @@ describe "OracleEnhancedAdapter context index" do
289
288
 
290
289
  def verify_logged_statements
291
290
  ['K_TABLE_CLAUSE', 'R_TABLE_CLAUSE', 'N_TABLE_CLAUSE', 'I_INDEX_CLAUSE', 'P_TABLE_CLAUSE'].each do |clause|
292
- @logger.output(:debug).should =~ /CTX_DDL\.SET_ATTRIBUTE\('index_posts_on_title_sto', '#{clause}', '.*TABLESPACE #{@tablespace}'\)/
291
+ expect(@logger.output(:debug)).to match(/CTX_DDL\.SET_ATTRIBUTE\('index_posts_on_title_sto', '#{clause}', '.*TABLESPACE #{@tablespace}'\)/)
293
292
  end
294
- @logger.output(:debug).should =~ /CREATE INDEX .* PARAMETERS \('STORAGE index_posts_on_title_sto'\)/
293
+ expect(@logger.output(:debug)).to match(/CREATE INDEX .* PARAMETERS \('STORAGE index_posts_on_title_sto'\)/)
295
294
  end
296
295
 
297
296
  it "should create index on single column" do
298
297
  @conn.add_context_index :posts, :title, tablespace: @tablespace
299
298
  verify_logged_statements
300
- Post.contains(:title, 'aaa').to_a.should == [@post]
299
+ expect(Post.contains(:title, 'aaa').to_a).to eq([@post])
301
300
  @conn.remove_context_index :posts, :title
302
301
  end
303
302
 
304
303
  it "should create index on multiple columns" do
305
304
  @conn.add_context_index :posts, [:title, :body], name: 'index_posts_text', tablespace: @conn.default_tablespace
306
305
  verify_logged_statements
307
- Post.contains(:title, 'aaa AND bbb').to_a.should == [@post]
306
+ expect(Post.contains(:title, 'aaa AND bbb').to_a).to eq([@post])
308
307
  @conn.remove_context_index :posts, name: 'index_posts_text'
309
308
  end
310
309
 
@@ -332,13 +331,13 @@ describe "OracleEnhancedAdapter context index" do
332
331
 
333
332
  it "should dump definition of single column index" do
334
333
  @conn.add_context_index :posts, :title
335
- standard_dump.should =~ /add_context_index "posts", \["title"\], name: \"index_posts_on_title\"$/
334
+ expect(standard_dump).to match(/add_context_index "posts", \["title"\], name: \"index_posts_on_title\"$/)
336
335
  @conn.remove_context_index :posts, :title
337
336
  end
338
337
 
339
338
  it "should dump definition of multiple column index" do
340
339
  @conn.add_context_index :posts, [:title, :body]
341
- standard_dump.should =~ /add_context_index "posts", \[:title, :body\]$/
340
+ expect(standard_dump).to match(/add_context_index "posts", \[:title, :body\]$/)
342
341
  @conn.remove_context_index :posts, [:title, :body]
343
342
  end
344
343
 
@@ -351,7 +350,7 @@ describe "OracleEnhancedAdapter context index" do
351
350
  }
352
351
  sub_query = "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"
353
352
  @conn.add_context_index :posts, [:title, :body, sub_query], options
354
- standard_dump.should =~ /add_context_index "posts", \[:title, :body, "#{sub_query}"\], #{options.inspect[1..-2]}$/
353
+ expect(standard_dump).to match(/add_context_index "posts", \[:title, :body, "#{sub_query}"\], #{options.inspect[1..-2]}$/)
355
354
  @conn.remove_context_index :posts, name: 'post_and_comments_index'
356
355
  end
357
356
 
@@ -364,7 +363,7 @@ describe "OracleEnhancedAdapter context index" do
364
363
  }
365
364
  sub_query = "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id#{' AND 1=1' * 500}"
366
365
  @conn.add_context_index :posts, [:title, :body, sub_query], options
367
- standard_dump.should =~ /add_context_index "posts", \[:title, :body, "#{sub_query}"\], #{options.inspect[1..-2]}$/
366
+ expect(standard_dump).to match(/add_context_index "posts", \[:title, :body, "#{sub_query}"\], #{options.inspect[1..-2]}$/)
368
367
  @conn.remove_context_index :posts, name: 'post_and_comments_index'
369
368
  end
370
369
 
@@ -377,7 +376,7 @@ describe "OracleEnhancedAdapter context index" do
377
376
  }
378
377
  sub_query = "SELECT comments.author AS comment_author, comments.body AS comment_body\nFROM comments\nWHERE comments.post_id = :id"
379
378
  @conn.add_context_index :posts, [:title, :body, sub_query], options
380
- standard_dump.should =~ /add_context_index "posts", \[:title, :body, "#{sub_query.gsub(/\n/, ' ')}"\], #{options.inspect[1..-2]}$/
379
+ expect(standard_dump).to match(/add_context_index "posts", \[:title, :body, "#{sub_query.gsub(/\n/, ' ')}"\], #{options.inspect[1..-2]}$/)
381
380
  @conn.remove_context_index :posts, name: 'post_and_comments_index'
382
381
  end
383
382
 
@@ -398,13 +397,13 @@ describe "OracleEnhancedAdapter context index" do
398
397
 
399
398
  it "should dump definition of single column index" do
400
399
  schema_define { add_context_index :posts, :title }
401
- standard_dump.should =~ /add_context_index "posts", \["title"\], name: "i_xxx_posts_xxx_title"$/
400
+ expect(standard_dump).to match(/add_context_index "posts", \["title"\], name: "i_xxx_posts_xxx_title"$/)
402
401
  schema_define { remove_context_index :posts, :title }
403
402
  end
404
403
 
405
404
  it "should dump definition of multiple column index" do
406
405
  schema_define { add_context_index :posts, [:title, :body] }
407
- standard_dump.should =~ /add_context_index "posts", \[:title, :body\]$/
406
+ expect(standard_dump).to match(/add_context_index "posts", \[:title, :body\]$/)
408
407
  schema_define { remove_context_index :posts, [:title, :body] }
409
408
  end
410
409
 
@@ -422,8 +421,8 @@ describe "OracleEnhancedAdapter context index" do
422
421
  "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"
423
422
  ], options
424
423
  end
425
- standard_dump.should =~ /add_context_index "posts", \[:title, :body, "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"\], #{
426
- options.inspect[1..-2].gsub(/[{}]/){|s| '\\'<<s }}$/
424
+ expect(standard_dump).to match(/add_context_index "posts", \[:title, :body, "SELECT comments.author AS comment_author, comments.body AS comment_body FROM comments WHERE comments.post_id = :id"\], #{
425
+ options.inspect[1..-2].gsub(/[{}]/){|s| '\\'<<s }}$/)
427
426
  schema_define { remove_context_index :posts, name: 'xxx_post_and_comments_i' }
428
427
  end
429
428