activerecord-oracle_enhanced-adapter 1.6.9 → 1.7.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -15,7 +15,7 @@ describe "Oracle Enhanced adapter database tasks" do
15
15
  end
16
16
  it "creates user" do
17
17
  query = "SELECT COUNT(*) FROM dba_users WHERE UPPER(username) = '#{new_user_config[:username].upcase}'"
18
- ActiveRecord::Base.connection.select_value(query).should == 1
18
+ expect(ActiveRecord::Base.connection.select_value(query)).to eq(1)
19
19
  end
20
20
  after do
21
21
  ActiveRecord::Base.connection.execute("DROP USER #{new_user_config[:username]}");
@@ -42,15 +42,15 @@ describe "Oracle Enhanced adapter database tasks" do
42
42
  describe "drop" do
43
43
  before { ActiveRecord::Tasks::DatabaseTasks.drop(config) }
44
44
  it "drops all tables" do
45
- ActiveRecord::Base.connection.table_exists?(:test_posts).should be false
45
+ expect(ActiveRecord::Base.connection.table_exists?(:test_posts)).to be_falsey
46
46
  end
47
47
  end
48
48
 
49
49
  describe "purge" do
50
50
  before { ActiveRecord::Tasks::DatabaseTasks.purge(config) }
51
51
  it "drops all tables" do
52
- ActiveRecord::Base.connection.table_exists?(:test_posts).should be false
53
- ActiveRecord::Base.connection.select_value("SELECT COUNT(*) FROM RECYCLEBIN").should == 0
52
+ expect(ActiveRecord::Base.connection.table_exists?(:test_posts)).to be_falsey
53
+ expect(ActiveRecord::Base.connection.select_value("SELECT COUNT(*) FROM RECYCLEBIN")).to eq(0)
54
54
  end
55
55
  end
56
56
 
@@ -65,8 +65,8 @@ describe "Oracle Enhanced adapter database tasks" do
65
65
  before { ActiveRecord::Tasks::DatabaseTasks.structure_dump(config, temp_file) }
66
66
  it "dumps the database structure to a file without the schema information" do
67
67
  contents = File.read(temp_file)
68
- contents.should include('CREATE TABLE "TEST_POSTS"')
69
- contents.should_not include('INSERT INTO schema_migrations')
68
+ expect(contents).to include('CREATE TABLE "TEST_POSTS"')
69
+ expect(contents).not_to include('INSERT INTO schema_migrations')
70
70
  end
71
71
  end
72
72
 
@@ -77,7 +77,7 @@ describe "Oracle Enhanced adapter database tasks" do
77
77
  ActiveRecord::Tasks::DatabaseTasks.structure_load(config, temp_file)
78
78
  end
79
79
  it "loads the database structure from a file" do
80
- ActiveRecord::Base.connection.table_exists?(:test_posts).should be true
80
+ expect(ActiveRecord::Base.connection.table_exists?(:test_posts)).to be_truthy
81
81
  end
82
82
  end
83
83
 
@@ -42,28 +42,28 @@ describe "OracleEnhancedAdapter logging dbms_output from plsql" do
42
42
  it "should NOT log dbms output when dbms output is disabled" do
43
43
  @conn.disable_dbms_output
44
44
 
45
- @conn.select_all("select more_than_five_characters_long('hi there') is_it_long from dual").to_a.should == [{'is_it_long'=>1}]
45
+ expect(@conn.select_all("select more_than_five_characters_long('hi there') is_it_long from dual").to_a).to eq([{'is_it_long'=>1}])
46
46
 
47
- @logger.output(:debug).should_not match(/^DBMS_OUTPUT/)
47
+ expect(@logger.output(:debug)).not_to match(/^DBMS_OUTPUT/)
48
48
  end
49
49
 
50
50
  it "should log dbms output lines to the rails log" do
51
51
  @conn.enable_dbms_output
52
52
 
53
- @conn.select_all("select more_than_five_characters_long('hi there') is_it_long from dual").to_a.should == [{'is_it_long'=>1}]
53
+ expect(@conn.select_all("select more_than_five_characters_long('hi there') is_it_long from dual").to_a).to eq([{'is_it_long'=>1}])
54
54
 
55
- @logger.output(:debug).should match(/^DBMS_OUTPUT: before the if -hi there-$/)
56
- @logger.output(:debug).should match(/^DBMS_OUTPUT: it is longer than 5$/)
57
- @logger.output(:debug).should match(/^DBMS_OUTPUT: about to return: 1$/)
55
+ expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: before the if -hi there-$/)
56
+ expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: it is longer than 5$/)
57
+ expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: about to return: 1$/)
58
58
  end
59
59
 
60
60
  it "should log dbms output lines to the rails log" do
61
61
  @conn.enable_dbms_output
62
62
 
63
- @conn.select_all("select more_than_five_characters_long('short') is_it_long from dual").to_a.should == [{'is_it_long'=>0}]
63
+ expect(@conn.select_all("select more_than_five_characters_long('short') is_it_long from dual").to_a).to eq([{'is_it_long'=>0}])
64
64
 
65
- @logger.output(:debug).should match(/^DBMS_OUTPUT: before the if -short-$/)
66
- @logger.output(:debug).should match(/^DBMS_OUTPUT: it is 5 or shorter$/)
67
- @logger.output(:debug).should match(/^DBMS_OUTPUT: about to return: 0$/)
65
+ expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: before the if -short-$/)
66
+ expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: it is 5 or shorter$/)
67
+ expect(@logger.output(:debug)).to match(/^DBMS_OUTPUT: about to return: 0$/)
68
68
  end
69
69
  end
@@ -38,99 +38,99 @@ if ActiveRecord::Base.method_defined?(:changed?)
38
38
  it "should not mark empty string (stored as NULL) as changed when reassigning it" do
39
39
  @employee = TestEmployee.create!(:first_name => '')
40
40
  @employee.first_name = ''
41
- @employee.should_not be_changed
41
+ expect(@employee).not_to be_changed
42
42
  @employee.reload
43
43
  @employee.first_name = ''
44
- @employee.should_not be_changed
44
+ expect(@employee).not_to be_changed
45
45
  end
46
46
 
47
47
  it "should not mark empty integer (stored as NULL) as changed when reassigning it" do
48
48
  @employee = TestEmployee.create!(:job_id => '')
49
49
  @employee.job_id = ''
50
- @employee.should_not be_changed
50
+ expect(@employee).not_to be_changed
51
51
  @employee.reload
52
52
  @employee.job_id = ''
53
- @employee.should_not be_changed
53
+ expect(@employee).not_to be_changed
54
54
  end
55
55
 
56
56
  it "should not mark empty decimal (stored as NULL) as changed when reassigning it" do
57
57
  @employee = TestEmployee.create!(:salary => '')
58
58
  @employee.salary = ''
59
- @employee.should_not be_changed
59
+ expect(@employee).not_to be_changed
60
60
  @employee.reload
61
61
  @employee.salary = ''
62
- @employee.should_not be_changed
62
+ expect(@employee).not_to be_changed
63
63
  end
64
64
 
65
65
  it "should not mark empty text (stored as NULL) as changed when reassigning it" do
66
66
  @employee = TestEmployee.create!(:comments => nil)
67
67
  @employee.comments = nil
68
- @employee.should_not be_changed
68
+ expect(@employee).not_to be_changed
69
69
  @employee.reload
70
70
  @employee.comments = nil
71
- @employee.should_not be_changed
71
+ expect(@employee).not_to be_changed
72
72
  end
73
73
 
74
74
  it "should not mark empty text (stored as empty_clob()) as changed when reassigning it" do
75
75
  @employee = TestEmployee.create!(:comments => '')
76
76
  @employee.comments = ''
77
- @employee.should_not be_changed
77
+ expect(@employee).not_to be_changed
78
78
  @employee.reload
79
79
  @employee.comments = ''
80
- @employee.should_not be_changed
80
+ expect(@employee).not_to be_changed
81
81
  end
82
82
 
83
83
  it "should mark empty text (stored as empty_clob()) as changed when assigning nil to it" do
84
84
  @employee = TestEmployee.create!(:comments => '')
85
85
  @employee.comments = nil
86
- @employee.should be_changed
86
+ expect(@employee).to be_changed
87
87
  @employee.reload
88
88
  @employee.comments = nil
89
- @employee.should be_changed
89
+ expect(@employee).to be_changed
90
90
  end
91
91
 
92
92
  it "should mark empty text (stored as NULL) as changed when assigning '' to it" do
93
93
  @employee = TestEmployee.create!(:comments => nil)
94
94
  @employee.comments = ''
95
- @employee.should be_changed
95
+ expect(@employee).to be_changed
96
96
  @employee.reload
97
97
  @employee.comments = ''
98
- @employee.should be_changed
98
+ expect(@employee).to be_changed
99
99
  end
100
100
 
101
101
  it "should not mark empty date (stored as NULL) as changed when reassigning it" do
102
102
  @employee = TestEmployee.create!(:hire_date => '')
103
103
  @employee.hire_date = ''
104
- @employee.should_not be_changed
104
+ expect(@employee).not_to be_changed
105
105
  @employee.reload
106
106
  @employee.hire_date = ''
107
- @employee.should_not be_changed
107
+ expect(@employee).not_to be_changed
108
108
  end
109
109
 
110
110
  it "should not mark integer as changed when reassigning it" do
111
111
  @employee = TestEmployee.new
112
112
  @employee.job_id = 0
113
- @employee.save.should be true
113
+ expect(@employee.save!).to be_truthy
114
114
 
115
- @employee.should_not be_changed
115
+ expect(@employee).not_to be_changed
116
116
 
117
117
  @employee.job_id = '0'
118
- @employee.should_not be_changed
118
+ expect(@employee).not_to be_changed
119
119
  end
120
120
 
121
121
  it "should not update unchanged CLOBs" do
122
122
  @employee = TestEmployee.create!(
123
123
  :comments => "initial"
124
124
  )
125
- @employee.save.should be true
125
+ expect(@employee.save!).to be_truthy
126
126
  @employee.reload
127
- @employee.comments.should == 'initial'
127
+ expect(@employee.comments).to eq('initial')
128
128
 
129
129
  oci_conn = @conn.instance_variable_get('@connection')
130
130
  class << oci_conn
131
131
  def write_lob(lob, value, is_binary = false); raise "don't do this'"; end
132
132
  end
133
- expect { @employee.save! }.to_not raise_error
133
+ expect{@employee.save!}.not_to raise_exception(RuntimeError, "don't do this'")
134
134
  class << oci_conn
135
135
  remove_method :write_lob
136
136
  end
@@ -11,8 +11,8 @@ describe "OracleEnhancedAdapter emulate OracleAdapter" do
11
11
 
12
12
  it "should be an OracleAdapter" do
13
13
  @conn = ActiveRecord::Base.establish_connection(CONNECTION_PARAMS.merge(:emulate_oracle_adapter => true))
14
- ActiveRecord::Base.connection.should_not be_nil
15
- ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::OracleAdapter).should be true
14
+ expect(ActiveRecord::Base.connection).not_to be_nil
15
+ expect(ActiveRecord::Base.connection.is_a?(ActiveRecord::ConnectionAdapters::OracleAdapter)).to be_truthy
16
16
  end
17
17
 
18
18
  after(:all) do
@@ -166,12 +166,12 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
166
166
  :hire_date => @today
167
167
  )
168
168
  @employee.reload
169
- @employee.first_name.should == "First"
170
- @employee.last_name.should == "Last"
171
- @employee.hire_date.should == @today
172
- @employee.description.should == "First Last"
173
- @employee.create_time.should_not be_nil
174
- @employee.update_time.should_not be_nil
169
+ expect(@employee.first_name).to eq("First")
170
+ expect(@employee.last_name).to eq("Last")
171
+ expect(@employee.hire_date).to eq(@today)
172
+ expect(@employee.description).to eq("First Last")
173
+ expect(@employee.create_time).not_to be_nil
174
+ expect(@employee.update_time).not_to be_nil
175
175
  end
176
176
 
177
177
  it "should rollback record when exception is raised in after_create callback" do
@@ -183,11 +183,11 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
183
183
  :hire_date => @today
184
184
  )
185
185
  employees_count = TestEmployee.count
186
- lambda {
186
+ expect {
187
187
  @employee.save
188
- }.should raise_error("Make the transaction rollback")
189
- @employee.new_record?.should be true
190
- TestEmployee.count.should == employees_count
188
+ }.to raise_error("Make the transaction rollback")
189
+ expect(@employee.id).to eq(nil)
190
+ expect(TestEmployee.count).to eq(employees_count)
191
191
  end
192
192
 
193
193
  it "should update record" do
@@ -201,7 +201,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
201
201
  @employee.first_name = "Second"
202
202
  @employee.save!
203
203
  @employee.reload
204
- @employee.description.should == "Second Last"
204
+ expect(@employee.description).to eq("Second Last")
205
205
  end
206
206
 
207
207
  it "should rollback record when exception is raised in after_update callback" do
@@ -216,11 +216,11 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
216
216
  empl_id = @employee.id
217
217
  @employee.reload
218
218
  @employee.first_name = "Second"
219
- lambda {
219
+ expect {
220
220
  @employee.save
221
- }.should raise_error("Make the transaction rollback")
221
+ }.to raise_error("Make the transaction rollback")
222
222
  @employee.reload
223
- @employee.first_name.should == "First"
223
+ expect(@employee.first_name).to eq("First")
224
224
  end
225
225
 
226
226
  it "should not update record if nothing is changed and partial writes are enabled" do
@@ -233,7 +233,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
233
233
  @employee.reload
234
234
  @employee.save!
235
235
  @employee.reload
236
- @employee.version.should == 1
236
+ expect(@employee.version).to eq(1)
237
237
  end
238
238
 
239
239
  it "should update record if nothing is changed and partial writes are disabled" do
@@ -246,7 +246,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
246
246
  @employee.reload
247
247
  @employee.save!
248
248
  @employee.reload
249
- @employee.version.should == 2
249
+ expect(@employee.version).to eq(2)
250
250
  end
251
251
 
252
252
  it "should delete record" do
@@ -258,8 +258,8 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
258
258
  @employee.reload
259
259
  empl_id = @employee.id
260
260
  @employee.destroy
261
- @employee.should be_frozen
262
- TestEmployee.find_by_employee_id(empl_id).should be_nil
261
+ expect(@employee).to be_frozen
262
+ expect(TestEmployee.find_by_employee_id(empl_id)).to be_nil
263
263
  end
264
264
 
265
265
  it "should delete record and set destroyed flag" do
@@ -270,7 +270,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
270
270
  )
271
271
  @employee.reload
272
272
  @employee.destroy
273
- @employee.should be_destroyed
273
+ expect(@employee).to be_destroyed
274
274
  end
275
275
 
276
276
  it "should rollback record when exception is raised in after_destroy callback" do
@@ -284,11 +284,11 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
284
284
  )
285
285
  @employee.reload
286
286
  empl_id = @employee.id
287
- lambda {
287
+ expect {
288
288
  @employee.destroy
289
- }.should raise_error("Make the transaction rollback")
290
- @employee.id.should == empl_id
291
- TestEmployee.find_by_employee_id(empl_id).should_not be_nil
289
+ }.to raise_error("Make the transaction rollback")
290
+ expect(@employee.id).to eq(empl_id)
291
+ expect(TestEmployee.find_by_employee_id(empl_id)).not_to be_nil
292
292
  clear_logger
293
293
  end
294
294
 
@@ -298,8 +298,8 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
298
298
  :last_name => "Last",
299
299
  :hire_date => @today
300
300
  )
301
- @employee.created_at.should_not be_nil
302
- @employee.updated_at.should_not be_nil
301
+ expect(@employee.created_at).not_to be_nil
302
+ expect(@employee.updated_at).not_to be_nil
303
303
  end
304
304
 
305
305
  it "should set timestamps when updating record" do
@@ -309,12 +309,12 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
309
309
  :hire_date => @today
310
310
  )
311
311
  @employee.reload
312
- @employee.created_at.should be_nil
313
- @employee.updated_at.should be_nil
312
+ expect(@employee.created_at).to be_nil
313
+ expect(@employee.updated_at).to be_nil
314
314
  @employee.first_name = "Second"
315
315
  @employee.save!
316
- @employee.created_at.should be_nil
317
- @employee.updated_at.should_not be_nil
316
+ expect(@employee.created_at).to be_nil
317
+ expect(@employee.updated_at).not_to be_nil
318
318
  end
319
319
 
320
320
  it "should log create record" do
@@ -324,8 +324,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
324
324
  :last_name => "Last",
325
325
  :hire_date => @today
326
326
  )
327
- #TODO: dirty workaround to remove sql statement for `table` method
328
- @logger.logged(:debug)[-2].should match(/^TestEmployee Create \(\d+\.\d+(ms)?\) custom create method$/)
327
+ expect(@logger.logged(:debug).last).to match(/^TestEmployee Create \(\d+\.\d+(ms)?\) custom create method$/)
329
328
  clear_logger
330
329
  end
331
330
 
@@ -338,7 +337,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
338
337
  )
339
338
  set_logger
340
339
  @employee.save!
341
- @logger.logged(:debug).last.should match(/^TestEmployee Update \(\d+\.\d+(ms)?\) custom update method with employee_id=#{@employee.id}$/)
340
+ expect(@logger.logged(:debug).last).to match(/^TestEmployee Update \(\d+\.\d+(ms)?\) custom update method with employee_id=#{@employee.id}$/)
342
341
  clear_logger
343
342
  end
344
343
 
@@ -350,7 +349,7 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
350
349
  )
351
350
  set_logger
352
351
  @employee.destroy
353
- @logger.logged(:debug).last.should match(/^TestEmployee Destroy \(\d+\.\d+(ms)?\) custom delete method with employee_id=#{@employee.id}$/)
352
+ expect(@logger.logged(:debug).last).to match(/^TestEmployee Destroy \(\d+\.\d+(ms)?\) custom delete method with employee_id=#{@employee.id}$/)
354
353
  clear_logger
355
354
  end
356
355
 
@@ -359,8 +358,8 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
359
358
  :last_name => "Last",
360
359
  :hire_date => @today
361
360
  )
362
- @employee.save.should be false
363
- @employee.errors[:first_name].should_not be_blank
361
+ expect(@employee.save).to be_falsey
362
+ expect(@employee.errors[:first_name]).not_to be_blank
364
363
  end
365
364
 
366
365
  it "should validate existing record before update" do
@@ -370,8 +369,8 @@ describe "OracleEnhancedAdapter custom methods for create, update and destroy" d
370
369
  :hire_date => @today
371
370
  )
372
371
  @employee.first_name = nil
373
- @employee.save.should be false
374
- @employee.errors[:first_name].should_not be_blank
372
+ expect(@employee.save).to be_falsey
373
+ expect(@employee.errors[:first_name]).not_to be_blank
375
374
  end
376
375
 
377
376
  end
@@ -43,12 +43,12 @@ describe "OracleEnhancedAdapter schema dump" do
43
43
 
44
44
  it "should not include ignored table names in schema dump" do
45
45
  create_test_posts_table
46
- standard_dump(ignore_tables: %w(test_posts)).should_not =~ /create_table "test_posts"/
46
+ expect(standard_dump(ignore_tables: %w(test_posts))).not_to match(/create_table "test_posts"/)
47
47
  end
48
48
 
49
49
  it "should not include ignored table regexes in schema dump" do
50
50
  create_test_posts_table
51
- standard_dump(ignore_tables: [ /test_posts/i ]).should_not =~ /create_table "test_posts"/
51
+ expect(standard_dump(ignore_tables: [ /test_posts/i ])).not_to match(/create_table "test_posts"/)
52
52
  end
53
53
 
54
54
  end
@@ -70,7 +70,7 @@ describe "OracleEnhancedAdapter schema dump" do
70
70
  end
71
71
 
72
72
  it "should be able to dump default values using special characters" do
73
- standard_dump.should =~ /t.string \"special_c\", default: "\\n"/
73
+ expect(standard_dump).to match(/t.string \"special_c\", default: "\\n"/)
74
74
  end
75
75
  end
76
76
  describe "table prefixes and suffixes" do
@@ -84,37 +84,37 @@ describe "OracleEnhancedAdapter schema dump" do
84
84
  it "should remove table prefix in schema dump" do
85
85
  ActiveRecord::Base.table_name_prefix = 'xxx_'
86
86
  create_test_posts_table
87
- standard_dump.should =~ /create_table "test_posts".*add_index "test_posts"/m
87
+ expect(standard_dump).to match(/create_table "test_posts".*add_index "test_posts"/m)
88
88
  end
89
89
 
90
90
  it "should remove table prefix with $ sign in schema dump" do
91
91
  ActiveRecord::Base.table_name_prefix = 'xxx$'
92
92
  create_test_posts_table
93
- standard_dump.should =~ /create_table "test_posts".*add_index "test_posts"/m
93
+ expect(standard_dump).to match(/create_table "test_posts".*add_index "test_posts"/m)
94
94
  end
95
95
 
96
96
  it "should remove table suffix in schema dump" do
97
97
  ActiveRecord::Base.table_name_suffix = '_xxx'
98
98
  create_test_posts_table
99
- standard_dump.should =~ /create_table "test_posts".*add_index "test_posts"/m
99
+ expect(standard_dump).to match(/create_table "test_posts".*add_index "test_posts"/m)
100
100
  end
101
101
 
102
102
  it "should remove table suffix with $ sign in schema dump" do
103
103
  ActiveRecord::Base.table_name_suffix = '$xxx'
104
104
  create_test_posts_table
105
- standard_dump.should =~ /create_table "test_posts".*add_index "test_posts"/m
105
+ expect(standard_dump).to match(/create_table "test_posts".*add_index "test_posts"/m)
106
106
  end
107
107
 
108
108
  it "should not include schema_migrations table with prefix in schema dump" do
109
109
  ActiveRecord::Base.table_name_prefix = 'xxx_'
110
110
  @conn.initialize_schema_migrations_table
111
- standard_dump.should_not =~ /schema_migrations/
111
+ expect(standard_dump).not_to match(/schema_migrations/)
112
112
  end
113
113
 
114
114
  it "should not include schema_migrations table with suffix in schema dump" do
115
115
  ActiveRecord::Base.table_name_suffix = '_xxx'
116
116
  @conn.initialize_schema_migrations_table
117
- standard_dump.should_not =~ /schema_migrations/
117
+ expect(standard_dump).not_to match(/schema_migrations/)
118
118
  end
119
119
 
120
120
  end
@@ -126,7 +126,7 @@ describe "OracleEnhancedAdapter schema dump" do
126
126
 
127
127
  it "should include non-default primary key in schema dump" do
128
128
  create_test_posts_table(primary_key: 'post_id')
129
- standard_dump.should =~ /create_table "test_posts", primary_key: "post_id"/
129
+ expect(standard_dump).to match(/create_table "test_posts", primary_key: "post_id"/)
130
130
  end
131
131
 
132
132
  end
@@ -140,12 +140,12 @@ describe "OracleEnhancedAdapter schema dump" do
140
140
 
141
141
  it "should include primary key trigger in schema dump" do
142
142
  create_test_posts_table(primary_key_trigger: true)
143
- standard_dump.should =~ /create_table "test_posts".*add_primary_key_trigger "test_posts"/m
143
+ expect(standard_dump).to match(/create_table "test_posts".*add_primary_key_trigger "test_posts"/m)
144
144
  end
145
145
 
146
146
  it "should include primary key trigger with non-default primary key in schema dump" do
147
147
  create_test_posts_table(primary_key_trigger: true, primary_key: 'post_id')
148
- standard_dump.should =~ /create_table "test_posts", primary_key: "post_id".*add_primary_key_trigger "test_posts", primary_key: "post_id"/m
148
+ expect(standard_dump).to match(/create_table "test_posts", primary_key: "post_id".*add_primary_key_trigger "test_posts", primary_key: "post_id"/m)
149
149
  end
150
150
 
151
151
  end
@@ -180,49 +180,49 @@ describe "OracleEnhancedAdapter schema dump" do
180
180
  schema_define do
181
181
  add_foreign_key :test_comments, :test_posts
182
182
  end
183
- standard_dump.should =~ /add_foreign_key "test_comments", "test_posts"/
183
+ expect(standard_dump).to match(/add_foreign_key "test_comments", "test_posts"/)
184
184
  end
185
185
 
186
186
  it "should include foreign key with delete dependency in schema dump" do
187
187
  schema_define do
188
188
  add_foreign_key :test_comments, :test_posts, dependent: :delete
189
189
  end
190
- standard_dump.should =~ /add_foreign_key "test_comments", "test_posts", on_delete: :cascade/
190
+ expect(standard_dump).to match(/add_foreign_key "test_comments", "test_posts", on_delete: :cascade/)
191
191
  end
192
192
 
193
193
  it "should include foreign key with nullify dependency in schema dump" do
194
194
  schema_define do
195
195
  add_foreign_key :test_comments, :test_posts, dependent: :nullify
196
196
  end
197
- standard_dump.should =~ /add_foreign_key "test_comments", "test_posts", on_delete: :nullify/
197
+ expect(standard_dump).to match(/add_foreign_key "test_comments", "test_posts", on_delete: :nullify/)
198
198
  end
199
199
 
200
200
  it "should not include foreign keys on ignored table names in schema dump" do
201
201
  schema_define do
202
202
  add_foreign_key :test_comments, :test_posts
203
203
  end
204
- standard_dump(ignore_tables: %w(test_comments)).should_not =~ /add_foreign_key "test_comments"/
204
+ expect(standard_dump(ignore_tables: %w(test_comments))).not_to match(/add_foreign_key "test_comments"/)
205
205
  end
206
206
 
207
207
  it "should not include foreign keys on ignored table regexes in schema dump" do
208
208
  schema_define do
209
209
  add_foreign_key :test_comments, :test_posts
210
210
  end
211
- standard_dump(ignore_tables: [ /test_comments/i ]).should_not =~ /add_foreign_key "test_comments"/
211
+ expect(standard_dump(ignore_tables: [ /test_comments/i ])).not_to match(/add_foreign_key "test_comments"/)
212
212
  end
213
213
 
214
214
  it "should include foreign keys referencing ignored table names in schema dump" do
215
215
  schema_define do
216
216
  add_foreign_key :test_comments, :test_posts
217
217
  end
218
- standard_dump(ignore_tables: %w(test_posts)).should =~ /add_foreign_key "test_comments"/
218
+ expect(standard_dump(ignore_tables: %w(test_posts))).to match(/add_foreign_key "test_comments"/)
219
219
  end
220
220
 
221
221
  it "should include foreign keys referencing ignored table regexes in schema dump" do
222
222
  schema_define do
223
223
  add_foreign_key :test_comments, :test_posts
224
224
  end
225
- standard_dump(ignore_tables: [ /test_posts/i ]).should =~ /add_foreign_key "test_comments"/
225
+ expect(standard_dump(ignore_tables: [ /test_posts/i ])).to match(/add_foreign_key "test_comments"/)
226
226
  end
227
227
 
228
228
  it "should include composite foreign keys" do
@@ -241,7 +241,7 @@ describe "OracleEnhancedAdapter schema dump" do
241
241
 
242
242
  add_foreign_key :test_comments, :test_posts, columns: ["baz_id", "fooz_id"], name: 'comments_posts_baz_fooz_fk'
243
243
  end
244
- standard_dump.should =~ /add_foreign_key "test_comments", "test_posts", columns: \["baz_id", "fooz_id"\], name: "comments_posts_baz_fooz_fk"/
244
+ expect(standard_dump).to match(/add_foreign_key "test_comments", "test_posts", columns: \["baz_id", "fooz_id"\], name: "comments_posts_baz_fooz_fk"/)
245
245
  end
246
246
  it "should include foreign keys following all tables" do
247
247
  # if foreign keys preceed declaration of all tables
@@ -250,7 +250,7 @@ describe "OracleEnhancedAdapter schema dump" do
250
250
  add_foreign_key :test_comments, :test_posts
251
251
  end
252
252
  dump = standard_dump
253
- dump.rindex("create_table").should < dump.index("add_foreign_key")
253
+ expect(dump.rindex("create_table")).to be < dump.index("add_foreign_key")
254
254
  end
255
255
 
256
256
  it "should include primary_key when reference column name is not 'id'" do
@@ -269,7 +269,7 @@ describe "OracleEnhancedAdapter schema dump" do
269
269
  ADD CONSTRAINT TEST_COMMENTS_BAZ_ID_FK FOREIGN KEY (baz_id) REFERENCES test_posts(baz_id)
270
270
  SQL
271
271
 
272
- standard_dump.should =~ /add_foreign_key "test_comments", "test_posts", column: "baz_id", primary_key: "baz_id", name: "test_comments_baz_id_fk"/
272
+ expect(standard_dump).to match(/add_foreign_key "test_comments", "test_posts", column: "baz_id", primary_key: "baz_id", name: "test_comments_baz_id_fk"/)
273
273
  end
274
274
 
275
275
  end
@@ -285,35 +285,35 @@ describe "OracleEnhancedAdapter schema dump" do
285
285
  schema_define do
286
286
  add_synonym :test_synonym, "schema_name.table_name", force: true
287
287
  end
288
- standard_dump.should =~ /add_synonym "test_synonym", "schema_name.table_name", force: true/
288
+ expect(standard_dump).to match(/add_synonym "test_synonym", "schema_name.table_name", force: true/)
289
289
  end
290
290
 
291
291
  it "should include synonym to other database table in schema dump" do
292
292
  schema_define do
293
293
  add_synonym :test_synonym, "table_name@link_name", force: true
294
294
  end
295
- standard_dump.should =~ /add_synonym "test_synonym", "table_name@link_name(\.[-A-Za-z0-9_]+)*", force: true/
295
+ expect(standard_dump).to match(/add_synonym "test_synonym", "table_name@link_name(\.[-A-Za-z0-9_]+)*", force: true/)
296
296
  end
297
297
 
298
298
  it "should not include ignored table names in schema dump" do
299
299
  schema_define do
300
300
  add_synonym :test_synonym, "schema_name.table_name", force: true
301
301
  end
302
- standard_dump(ignore_tables: %w(test_synonym)).should_not =~ /add_synonym "test_synonym"/
302
+ expect(standard_dump(ignore_tables: %w(test_synonym))).not_to match(/add_synonym "test_synonym"/)
303
303
  end
304
304
 
305
305
  it "should not include ignored table regexes in schema dump" do
306
306
  schema_define do
307
307
  add_synonym :test_synonym, "schema_name.table_name", force: true
308
308
  end
309
- standard_dump(ignore_tables: [ /test_synonym/i ]).should_not =~ /add_synonym "test_synonym"/
309
+ expect(standard_dump(ignore_tables: [ /test_synonym/i ])).not_to match(/add_synonym "test_synonym"/)
310
310
  end
311
311
 
312
312
  it "should include synonyms to ignored table regexes in schema dump" do
313
313
  schema_define do
314
314
  add_synonym :test_synonym, "schema_name.table_name", force: true
315
315
  end
316
- standard_dump(ignore_tables: [ /table_name/i ]).should =~ /add_synonym "test_synonym"/
316
+ expect(standard_dump(ignore_tables: [ /table_name/i ])).to match(/add_synonym "test_synonym"/)
317
317
  end
318
318
 
319
319
  end
@@ -325,7 +325,7 @@ describe "OracleEnhancedAdapter schema dump" do
325
325
 
326
326
  it "should include temporary options" do
327
327
  create_test_posts_table(temporary: true)
328
- standard_dump.should =~ /create_table "test_posts", temporary: true/
328
+ expect(standard_dump).to match(/create_table "test_posts", temporary: true/)
329
329
  end
330
330
  end
331
331
 
@@ -336,20 +336,20 @@ describe "OracleEnhancedAdapter schema dump" do
336
336
 
337
337
  it "should not specify default tablespace in add index" do
338
338
  create_test_posts_table
339
- standard_dump.should =~ /add_index "test_posts", \["title"\], name: "index_test_posts_on_title"$/
339
+ expect(standard_dump).to match(/add_index "test_posts", \["title"\], name: "index_test_posts_on_title"$/)
340
340
  end
341
341
 
342
342
  it "should specify non-default tablespace in add index" do
343
343
  tablespace_name = @conn.default_tablespace
344
- @conn.stub(:default_tablespace).and_return('dummy')
344
+ allow(@conn).to receive(:default_tablespace).and_return('dummy')
345
345
  create_test_posts_table
346
- standard_dump.should =~ /add_index "test_posts", \["title"\], name: "index_test_posts_on_title", tablespace: "#{tablespace_name}"$/
346
+ expect(standard_dump).to match(/add_index "test_posts", \["title"\], name: "index_test_posts_on_title", tablespace: "#{tablespace_name}"$/)
347
347
  end
348
348
 
349
349
  it "should create and dump function-based indexes" do
350
350
  create_test_posts_table
351
351
  @conn.add_index :test_posts, "NVL(created_at, updated_at)", name: "index_test_posts_cr_upd_at"
352
- standard_dump.should =~ /add_index "test_posts", \["NVL\(\\"CREATED_AT\\",\\"UPDATED_AT\\"\)"\], name: "index_test_posts_cr_upd_at"$/
352
+ expect(standard_dump).to match(/add_index "test_posts", \["NVL\(\\"CREATED_AT\\",\\"UPDATED_AT\\"\)"\], name: "index_test_posts_cr_upd_at"$/)
353
353
  end
354
354
 
355
355
  end
@@ -363,7 +363,7 @@ describe "OracleEnhancedAdapter schema dump" do
363
363
  it "should not include materialized views in schema dump" do
364
364
  create_test_posts_table
365
365
  @conn.execute "CREATE MATERIALIZED VIEW test_posts_mv AS SELECT * FROM test_posts"
366
- standard_dump.should_not =~ /create_table "test_posts_mv"/
366
+ expect(standard_dump).not_to match(/create_table "test_posts_mv"/)
367
367
  end
368
368
  end
369
369
 
@@ -401,12 +401,12 @@ describe "OracleEnhancedAdapter schema dump" do
401
401
  end
402
402
 
403
403
  it 'should dump correctly' do
404
- standard_dump.should =~ /t\.virtual "full_name",(\s*)limit: 512,(\s*)as: "\\"FIRST_NAME\\"\|\|', '\|\|\\"LAST_NAME\\"",(\s*)type: :string/
405
- standard_dump.should =~ /t\.virtual "short_name",(\s*)limit: 300,(\s*)as:(.*),(\s*)type: :string/
406
- standard_dump.should =~ /t\.virtual "full_name_length",(\s*)precision: 38,(\s*)as:(.*),(\s*)type: :integer/
407
- standard_dump.should =~ /t\.virtual "name_ratio",(\s*)as:(.*)\"$/ # no :type
408
- standard_dump.should =~ /t\.virtual "abbrev_name",(\s*)limit: 100,(\s*)as:(.*),(\s*)type: :string/
409
- standard_dump.should =~ /t\.virtual "field_with_leading_space",(\s*)limit: 300,(\s*)as: "' '\|\|\\"FIRST_NAME\\"\|\|' '",(\s*)type: :string/
404
+ expect(standard_dump).to match(/t\.virtual "full_name",(\s*)limit: 512,(\s*)as: "\\"FIRST_NAME\\"\|\|', '\|\|\\"LAST_NAME\\"",(\s*)type: :string/)
405
+ expect(standard_dump).to match(/t\.virtual "short_name",(\s*)limit: 300,(\s*)as:(.*),(\s*)type: :string/)
406
+ expect(standard_dump).to match(/t\.virtual "full_name_length",(\s*)precision: 38,(\s*)as:(.*),(\s*)type: :integer/)
407
+ expect(standard_dump).to match(/t\.virtual "name_ratio",(\s*)as:(.*)\"$/) # no :type
408
+ expect(standard_dump).to match(/t\.virtual "abbrev_name",(\s*)limit: 100,(\s*)as:(.*),(\s*)type: :string/)
409
+ expect(standard_dump).to match(/t\.virtual "field_with_leading_space",(\s*)limit: 300,(\s*)as: "' '\|\|\\"FIRST_NAME\\"\|\|' '",(\s*)type: :string/)
410
410
  end
411
411
 
412
412
  context 'with column cache' do
@@ -419,14 +419,14 @@ describe "OracleEnhancedAdapter schema dump" do
419
419
  end
420
420
  it 'should not change column defaults after several dumps' do
421
421
  col = TestName.columns.detect{|c| c.name == 'full_name'}
422
- col.should_not be_nil
423
- col.virtual_column_data_default.should_not =~ /:as/
422
+ expect(col).not_to be_nil
423
+ expect(col.virtual_column_data_default).not_to match(/:as/)
424
424
 
425
425
  standard_dump
426
- col.virtual_column_data_default.should_not =~ /:as/
426
+ expect(col.virtual_column_data_default).not_to match(/:as/)
427
427
 
428
428
  standard_dump
429
- col.virtual_column_data_default.should_not =~ /:as/
429
+ expect(col.virtual_column_data_default).not_to match(/:as/)
430
430
  end
431
431
  end
432
432
 
@@ -446,8 +446,8 @@ describe "OracleEnhancedAdapter schema dump" do
446
446
  end
447
447
  end
448
448
  it 'should dump correctly' do
449
- standard_dump.should_not =~ /add_index "test_names".+FIRST_NAME.+$/
450
- standard_dump.should =~ /add_index "test_names".+field_with_leading_space.+$/
449
+ expect(standard_dump).not_to match(/add_index "test_names".+FIRST_NAME.+$/)
450
+ expect(standard_dump).to match(/add_index "test_names".+field_with_leading_space.+$/)
451
451
  end
452
452
  end
453
453
  end
@@ -468,7 +468,47 @@ describe "OracleEnhancedAdapter schema dump" do
468
468
  end
469
469
 
470
470
  it "should dump float type correctly" do
471
- standard_dump.should =~ /t\.float "hourly_rate"$/
471
+ expect(standard_dump).to match(/t\.float "hourly_rate"$/)
472
+ end
473
+ end
474
+
475
+ describe "table comments" do
476
+ before(:each) do
477
+ schema_define do
478
+ create_table :test_table_comments, :comment => "this is a \"table comment\"!", force: true do |t|
479
+ t.string :blah
480
+ end
481
+ end
482
+ end
483
+
484
+ after(:each) do
485
+ schema_define do
486
+ drop_table :test_table_comments
487
+ end
488
+ end
489
+
490
+ it "should dump table comments" do
491
+ standard_dump.should =~ /comment: "this is a \\"table comment\\"!"/
492
+ end
493
+ end
494
+
495
+ describe "column comments" do
496
+ before(:each) do
497
+ schema_define do
498
+ create_table :test_column_comments, force: true do |t|
499
+ t.string :blah, :comment => "this is a \"column comment\"!"
500
+ end
501
+ end
502
+ end
503
+
504
+ after(:each) do
505
+ schema_define do
506
+ drop_table :test_column_comments
507
+ end
508
+ end
509
+
510
+ it "should dump column comments" do
511
+ standard_dump.should =~ /comment: "this is a \\"column comment\\"!"/
472
512
  end
473
513
  end
474
514