sequel 4.22.0 → 4.23.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +22 -0
  3. data/README.rdoc +6 -0
  4. data/Rakefile +59 -81
  5. data/doc/migration.rdoc +2 -0
  6. data/doc/release_notes/4.23.0.txt +65 -0
  7. data/doc/sharding.rdoc +16 -14
  8. data/doc/testing.rdoc +61 -77
  9. data/lib/sequel/adapters/jdbc.rb +1 -0
  10. data/lib/sequel/adapters/mock.rb +0 -1
  11. data/lib/sequel/adapters/postgres.rb +1 -0
  12. data/lib/sequel/adapters/postgresql.rb +1 -0
  13. data/lib/sequel/adapters/shared/postgres.rb +3 -3
  14. data/lib/sequel/connection_pool/sharded_threaded.rb +5 -0
  15. data/lib/sequel/connection_pool/threaded.rb +9 -1
  16. data/lib/sequel/database/connecting.rb +1 -1
  17. data/lib/sequel/database/transactions.rb +2 -1
  18. data/lib/sequel/dataset/prepared_statements.rb +1 -1
  19. data/lib/sequel/extensions/constraint_validations.rb +12 -12
  20. data/lib/sequel/extensions/date_arithmetic.rb +0 -4
  21. data/lib/sequel/extensions/pagination.rb +14 -2
  22. data/lib/sequel/extensions/pg_enum.rb +2 -2
  23. data/lib/sequel/extensions/pg_hstore.rb +1 -1
  24. data/lib/sequel/extensions/pg_json_ops.rb +2 -2
  25. data/lib/sequel/plugins/csv_serializer.rb +2 -0
  26. data/lib/sequel/plugins/delay_add_association.rb +50 -0
  27. data/lib/sequel/plugins/list.rb +2 -2
  28. data/lib/sequel/plugins/nested_attributes.rb +8 -28
  29. data/lib/sequel/plugins/update_refresh.rb +50 -0
  30. data/lib/sequel/plugins/validate_associated.rb +55 -0
  31. data/lib/sequel/version.rb +1 -1
  32. data/spec/adapters/db2_spec.rb +29 -29
  33. data/spec/adapters/firebird_spec.rb +97 -103
  34. data/spec/adapters/informix_spec.rb +25 -25
  35. data/spec/adapters/mssql_spec.rb +156 -172
  36. data/spec/adapters/mysql_spec.rb +334 -359
  37. data/spec/adapters/oracle_spec.rb +67 -69
  38. data/spec/adapters/postgres_spec.rb +1298 -1249
  39. data/spec/adapters/spec_helper.rb +2 -35
  40. data/spec/adapters/sqlanywhere_spec.rb +39 -39
  41. data/spec/adapters/sqlite_spec.rb +203 -200
  42. data/spec/bin_spec.rb +57 -59
  43. data/spec/core/connection_pool_spec.rb +402 -401
  44. data/spec/core/database_spec.rb +953 -944
  45. data/spec/core/dataset_spec.rb +2178 -2168
  46. data/spec/core/deprecated_spec.rb +19 -19
  47. data/spec/core/expression_filters_spec.rb +415 -415
  48. data/spec/core/mock_adapter_spec.rb +212 -212
  49. data/spec/core/object_graph_spec.rb +73 -73
  50. data/spec/core/placeholder_literalizer_spec.rb +71 -71
  51. data/spec/core/schema_generator_spec.rb +44 -44
  52. data/spec/core/schema_spec.rb +470 -472
  53. data/spec/core/spec_helper.rb +5 -20
  54. data/spec/core/version_spec.rb +2 -2
  55. data/spec/core_extensions_spec.rb +320 -320
  56. data/spec/extensions/accessed_columns_spec.rb +12 -12
  57. data/spec/extensions/active_model_spec.rb +3 -3
  58. data/spec/extensions/after_initialize_spec.rb +2 -2
  59. data/spec/extensions/arbitrary_servers_spec.rb +23 -23
  60. data/spec/extensions/association_dependencies_spec.rb +34 -34
  61. data/spec/extensions/association_pks_spec.rb +98 -98
  62. data/spec/extensions/association_proxies_spec.rb +33 -33
  63. data/spec/extensions/auto_validations_spec.rb +46 -46
  64. data/spec/extensions/blacklist_security_spec.rb +19 -18
  65. data/spec/extensions/blank_spec.rb +36 -36
  66. data/spec/extensions/boolean_readers_spec.rb +36 -36
  67. data/spec/extensions/caching_spec.rb +82 -82
  68. data/spec/extensions/class_table_inheritance_spec.rb +72 -72
  69. data/spec/extensions/column_conflicts_spec.rb +19 -14
  70. data/spec/extensions/column_select_spec.rb +19 -19
  71. data/spec/extensions/columns_introspection_spec.rb +43 -43
  72. data/spec/extensions/composition_spec.rb +64 -64
  73. data/spec/extensions/connection_validator_spec.rb +92 -90
  74. data/spec/extensions/constraint_validations_plugin_spec.rb +92 -92
  75. data/spec/extensions/constraint_validations_spec.rb +80 -80
  76. data/spec/extensions/core_refinements_spec.rb +220 -220
  77. data/spec/extensions/csv_serializer_spec.rb +44 -44
  78. data/spec/extensions/current_datetime_timestamp_spec.rb +8 -8
  79. data/spec/extensions/dataset_associations_spec.rb +65 -65
  80. data/spec/extensions/dataset_source_alias_spec.rb +16 -16
  81. data/spec/extensions/date_arithmetic_spec.rb +51 -58
  82. data/spec/extensions/defaults_setter_spec.rb +19 -19
  83. data/spec/extensions/delay_add_association_spec.rb +52 -0
  84. data/spec/extensions/dirty_spec.rb +51 -51
  85. data/spec/extensions/eager_each_spec.rb +8 -8
  86. data/spec/extensions/empty_array_ignore_nulls_spec.rb +10 -10
  87. data/spec/extensions/error_splitter_spec.rb +2 -2
  88. data/spec/extensions/error_sql_spec.rb +4 -4
  89. data/spec/extensions/eval_inspect_spec.rb +3 -3
  90. data/spec/extensions/filter_having_spec.rb +8 -8
  91. data/spec/extensions/force_encoding_spec.rb +30 -30
  92. data/spec/extensions/from_block_spec.rb +7 -7
  93. data/spec/extensions/graph_each_spec.rb +19 -19
  94. data/spec/extensions/hash_aliases_spec.rb +5 -5
  95. data/spec/extensions/hook_class_methods_spec.rb +100 -100
  96. data/spec/extensions/inflector_spec.rb +54 -54
  97. data/spec/extensions/input_transformer_spec.rb +10 -10
  98. data/spec/extensions/insert_returning_select_spec.rb +8 -8
  99. data/spec/extensions/instance_filters_spec.rb +26 -26
  100. data/spec/extensions/instance_hooks_spec.rb +85 -85
  101. data/spec/extensions/json_serializer_spec.rb +68 -68
  102. data/spec/extensions/lazy_attributes_spec.rb +49 -49
  103. data/spec/extensions/list_spec.rb +77 -75
  104. data/spec/extensions/looser_typecasting_spec.rb +16 -16
  105. data/spec/extensions/many_through_many_spec.rb +627 -627
  106. data/spec/extensions/meta_def_spec.rb +7 -7
  107. data/spec/extensions/migration_spec.rb +217 -217
  108. data/spec/extensions/modification_detection_spec.rb +20 -20
  109. data/spec/extensions/mssql_optimistic_locking_spec.rb +21 -21
  110. data/spec/extensions/named_timezones_spec.rb +18 -18
  111. data/spec/extensions/nested_attributes_spec.rb +107 -107
  112. data/spec/extensions/null_dataset_spec.rb +24 -24
  113. data/spec/extensions/optimistic_locking_spec.rb +21 -21
  114. data/spec/extensions/pagination_spec.rb +52 -52
  115. data/spec/extensions/pg_array_associations_spec.rb +273 -273
  116. data/spec/extensions/pg_array_ops_spec.rb +52 -52
  117. data/spec/extensions/pg_array_spec.rb +152 -152
  118. data/spec/extensions/pg_enum_spec.rb +13 -13
  119. data/spec/extensions/pg_hstore_ops_spec.rb +63 -63
  120. data/spec/extensions/pg_hstore_spec.rb +84 -84
  121. data/spec/extensions/pg_inet_spec.rb +15 -15
  122. data/spec/extensions/pg_interval_spec.rb +29 -29
  123. data/spec/extensions/pg_json_ops_spec.rb +86 -84
  124. data/spec/extensions/pg_json_spec.rb +104 -104
  125. data/spec/extensions/pg_loose_count_spec.rb +6 -6
  126. data/spec/extensions/pg_range_ops_spec.rb +24 -24
  127. data/spec/extensions/pg_range_spec.rb +143 -143
  128. data/spec/extensions/pg_row_ops_spec.rb +14 -14
  129. data/spec/extensions/pg_row_plugin_spec.rb +12 -12
  130. data/spec/extensions/pg_row_spec.rb +118 -118
  131. data/spec/extensions/pg_static_cache_updater_spec.rb +28 -28
  132. data/spec/extensions/pg_typecast_on_load_spec.rb +21 -21
  133. data/spec/extensions/prepared_statements_associations_spec.rb +42 -42
  134. data/spec/extensions/prepared_statements_safe_spec.rb +18 -18
  135. data/spec/extensions/prepared_statements_spec.rb +28 -28
  136. data/spec/extensions/prepared_statements_with_pk_spec.rb +11 -11
  137. data/spec/extensions/pretty_table_spec.rb +16 -16
  138. data/spec/extensions/query_literals_spec.rb +37 -37
  139. data/spec/extensions/query_spec.rb +32 -32
  140. data/spec/extensions/rcte_tree_spec.rb +141 -141
  141. data/spec/extensions/round_timestamps_spec.rb +21 -21
  142. data/spec/extensions/schema_caching_spec.rb +8 -8
  143. data/spec/extensions/schema_dumper_spec.rb +78 -78
  144. data/spec/extensions/schema_spec.rb +31 -27
  145. data/spec/extensions/scissors_spec.rb +3 -3
  146. data/spec/extensions/select_remove_spec.rb +14 -14
  147. data/spec/extensions/sequel_3_dataset_methods_spec.rb +28 -28
  148. data/spec/extensions/serialization_modification_detection_spec.rb +33 -33
  149. data/spec/extensions/serialization_spec.rb +79 -78
  150. data/spec/extensions/server_block_spec.rb +17 -17
  151. data/spec/extensions/set_overrides_spec.rb +30 -30
  152. data/spec/extensions/sharding_spec.rb +65 -65
  153. data/spec/extensions/shared_caching_spec.rb +29 -29
  154. data/spec/extensions/single_table_inheritance_spec.rb +79 -79
  155. data/spec/extensions/skip_create_refresh_spec.rb +3 -3
  156. data/spec/extensions/spec_helper.rb +4 -29
  157. data/spec/extensions/split_array_nil_spec.rb +9 -9
  158. data/spec/extensions/split_values_spec.rb +7 -7
  159. data/spec/extensions/sql_expr_spec.rb +32 -32
  160. data/spec/extensions/static_cache_spec.rb +123 -123
  161. data/spec/extensions/string_date_time_spec.rb +34 -34
  162. data/spec/extensions/string_stripper_spec.rb +15 -15
  163. data/spec/extensions/subclasses_spec.rb +31 -31
  164. data/spec/extensions/table_select_spec.rb +15 -15
  165. data/spec/extensions/tactical_eager_loading_spec.rb +23 -23
  166. data/spec/extensions/thread_local_timezones_spec.rb +13 -13
  167. data/spec/extensions/timestamps_spec.rb +40 -40
  168. data/spec/extensions/to_dot_spec.rb +34 -34
  169. data/spec/extensions/touch_spec.rb +52 -52
  170. data/spec/extensions/tree_spec.rb +72 -72
  171. data/spec/extensions/typecast_on_load_spec.rb +25 -25
  172. data/spec/extensions/unlimited_update_spec.rb +2 -2
  173. data/spec/extensions/update_or_create_spec.rb +36 -36
  174. data/spec/extensions/update_primary_key_spec.rb +35 -35
  175. data/spec/extensions/update_refresh_spec.rb +41 -0
  176. data/spec/extensions/validate_associated_spec.rb +52 -0
  177. data/spec/extensions/validation_class_methods_spec.rb +314 -317
  178. data/spec/extensions/validation_helpers_spec.rb +195 -195
  179. data/spec/extensions/xml_serializer_spec.rb +48 -48
  180. data/spec/guards_helper.rb +55 -0
  181. data/spec/integration/associations_test.rb +1089 -1088
  182. data/spec/integration/database_test.rb +29 -29
  183. data/spec/integration/dataset_test.rb +661 -661
  184. data/spec/integration/eager_loader_test.rb +147 -147
  185. data/spec/integration/migrator_test.rb +122 -122
  186. data/spec/integration/model_test.rb +70 -70
  187. data/spec/integration/plugin_test.rb +682 -640
  188. data/spec/integration/prepared_statement_test.rb +172 -172
  189. data/spec/integration/schema_test.rb +245 -245
  190. data/spec/integration/spec_helper.rb +1 -64
  191. data/spec/integration/timezone_test.rb +17 -17
  192. data/spec/integration/transaction_test.rb +87 -87
  193. data/spec/integration/type_test.rb +33 -33
  194. data/spec/model/association_reflection_spec.rb +130 -121
  195. data/spec/model/associations_spec.rb +1112 -1113
  196. data/spec/model/base_spec.rb +197 -196
  197. data/spec/model/class_dataset_methods_spec.rb +118 -118
  198. data/spec/model/dataset_methods_spec.rb +49 -49
  199. data/spec/model/eager_loading_spec.rb +705 -702
  200. data/spec/model/hooks_spec.rb +169 -168
  201. data/spec/model/inflector_spec.rb +5 -5
  202. data/spec/model/model_spec.rb +287 -297
  203. data/spec/model/plugins_spec.rb +47 -47
  204. data/spec/model/record_spec.rb +534 -535
  205. data/spec/model/spec_helper.rb +3 -21
  206. data/spec/model/validations_spec.rb +72 -70
  207. data/spec/spec_config.rb +8 -0
  208. metadata +41 -9
  209. data/lib/sequel/adapters/fdbsql.rb +0 -286
  210. data/lib/sequel/adapters/jdbc/fdbsql.rb +0 -66
  211. data/lib/sequel/adapters/openbase.rb +0 -54
  212. data/lib/sequel/adapters/shared/fdbsql.rb +0 -550
  213. data/spec/adapters/fdbsql_spec.rb +0 -429
  214. data/spec/rspec_helper.rb +0 -22
@@ -13,20 +13,20 @@ describe "Database schema parser" do
13
13
  DB.drop_table?(:items)
14
14
  end
15
15
 
16
- specify "should handle a database with a identifier methods" do
16
+ it "should handle a database with a identifier methods" do
17
17
  DB.identifier_output_method = :reverse
18
18
  DB.identifier_input_method = :reverse
19
19
  DB.quote_identifiers = true
20
20
  DB.create_table!(:items){Integer :number}
21
21
  begin
22
- DB.schema(:items, :reload=>true).should be_a_kind_of(Array)
23
- DB.schema(:items, :reload=>true).first.first.should == :number
22
+ DB.schema(:items, :reload=>true).must_be_kind_of(Array)
23
+ DB.schema(:items, :reload=>true).first.first.must_equal :number
24
24
  ensure
25
25
  DB.drop_table(:items)
26
26
  end
27
27
  end
28
28
 
29
- specify "should handle a dataset with identifier methods different than the database's" do
29
+ it "should handle a dataset with identifier methods different than the database's" do
30
30
  DB.identifier_output_method = :reverse
31
31
  DB.identifier_input_method = :reverse
32
32
  DB.quote_identifiers = true
@@ -37,8 +37,8 @@ describe "Database schema parser" do
37
37
  ds.identifier_output_method = :reverse
38
38
  ds.identifier_input_method = :reverse
39
39
  begin
40
- DB.schema(ds, :reload=>true).should be_a_kind_of(Array)
41
- DB.schema(ds, :reload=>true).first.first.should == :number
40
+ DB.schema(ds, :reload=>true).must_be_kind_of(Array)
41
+ DB.schema(ds, :reload=>true).first.first.must_equal :number
42
42
  ensure
43
43
  DB.identifier_output_method = :reverse
44
44
  DB.identifier_input_method = :reverse
@@ -46,124 +46,124 @@ describe "Database schema parser" do
46
46
  end
47
47
  end
48
48
 
49
- specify "should not issue an sql query if the schema has been loaded unless :reload is true" do
49
+ it "should not issue an sql query if the schema has been loaded unless :reload is true" do
50
50
  DB.create_table!(:items){Integer :number}
51
51
  DB.schema(:items, :reload=>true)
52
52
  DB.schema(:items)
53
53
  DB.schema(:items, :reload=>true)
54
54
  end
55
55
 
56
- specify "Model schema should include columns in the table, even if they aren't selected" do
56
+ it "Model schema should include columns in the table, even if they aren't selected" do
57
57
  DB.create_table!(:items){String :a; Integer :number}
58
58
  m = Sequel::Model(DB[:items].select(:a))
59
- m.columns.should == [:a]
60
- m.db_schema[:number][:type].should == :integer
59
+ m.columns.must_equal [:a]
60
+ m.db_schema[:number][:type].must_equal :integer
61
61
  end
62
62
 
63
- specify "should raise an error when the table doesn't exist" do
64
- proc{DB.schema(:no_table)}.should raise_error(Sequel::Error)
63
+ it "should raise an error when the table doesn't exist" do
64
+ proc{DB.schema(:no_table)}.must_raise(Sequel::Error, Sequel::DatabaseError)
65
65
  end
66
66
 
67
- specify "should return the schema correctly" do
67
+ it "should return the schema correctly" do
68
68
  DB.create_table!(:items){Integer :number}
69
69
  schema = DB.schema(:items, :reload=>true)
70
- schema.should be_a_kind_of(Array)
71
- schema.length.should == 1
70
+ schema.must_be_kind_of(Array)
71
+ schema.length.must_equal 1
72
72
  col = schema.first
73
- col.should be_a_kind_of(Array)
74
- col.length.should == 2
75
- col.first.should == :number
73
+ col.must_be_kind_of(Array)
74
+ col.length.must_equal 2
75
+ col.first.must_equal :number
76
76
  col_info = col.last
77
- col_info.should be_a_kind_of(Hash)
78
- col_info[:type].should == :integer
77
+ col_info.must_be_kind_of(Hash)
78
+ col_info[:type].must_equal :integer
79
79
  DB.schema(:items)
80
80
  end
81
81
 
82
- specify "should parse primary keys from the schema properly" do
82
+ it "should parse primary keys from the schema properly" do
83
83
  DB.create_table!(:items){Integer :number}
84
- DB.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.should == []
84
+ DB.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.must_equal []
85
85
  DB.create_table!(:items){primary_key :number}
86
- DB.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.should == [:number]
86
+ DB.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.must_equal [:number]
87
87
  DB.create_table!(:items){Integer :number1; Integer :number2; primary_key [:number1, :number2]}
88
- DB.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.should == [:number1, :number2]
88
+ DB.schema(:items).collect{|k,v| k if v[:primary_key]}.compact.must_equal [:number1, :number2]
89
89
  end
90
90
 
91
- cspecify "should parse autoincrementing primary keys from the schema properly", :sqlite, :oracle, :fdbsql do
91
+ cspecify "should parse autoincrementing primary keys from the schema properly", :sqlite, :oracle do
92
92
  DB.create_table!(:items){Integer :number}
93
- DB.schema(:items).collect{|k,v| k if v[:primary_key] && v[:auto_increment]}.compact.should == []
93
+ DB.schema(:items).collect{|k,v| k if v[:primary_key] && v[:auto_increment]}.compact.must_equal []
94
94
  DB.create_table!(:items){primary_key :number}
95
- DB.schema(:items).collect{|k,v| k if v[:primary_key] && v[:auto_increment]}.compact.should == [:number]
95
+ DB.schema(:items).collect{|k,v| k if v[:primary_key] && v[:auto_increment]}.compact.must_equal [:number]
96
96
  DB.create_table!(:items){Integer :number, :primary_key=>true}
97
- DB.schema(:items).collect{|k,v| k if v[:primary_key] && v[:auto_increment]}.compact.should == []
97
+ DB.schema(:items).collect{|k,v| k if v[:primary_key] && v[:auto_increment]}.compact.must_equal []
98
98
  end
99
99
 
100
- specify "should parse NULL/NOT NULL from the schema properly" do
100
+ it "should parse NULL/NOT NULL from the schema properly" do
101
101
  DB.create_table!(:items){Integer :number, :null=>true}
102
- DB.schema(:items).first.last[:allow_null].should == true
102
+ DB.schema(:items).first.last[:allow_null].must_equal true
103
103
  DB.create_table!(:items){Integer :number, :null=>false}
104
- DB.schema(:items).first.last[:allow_null].should == false
104
+ DB.schema(:items).first.last[:allow_null].must_equal false
105
105
  end
106
106
 
107
- specify "should parse defaults from the schema properly" do
107
+ it "should parse defaults from the schema properly" do
108
108
  DB.create_table!(:items){Integer :number}
109
- DB.schema(:items).first.last[:ruby_default].should == nil
109
+ DB.schema(:items).first.last[:ruby_default].must_equal nil
110
110
  DB.create_table!(:items){Integer :number, :default=>0}
111
- DB.schema(:items).first.last[:ruby_default].should == 0
111
+ DB.schema(:items).first.last[:ruby_default].must_equal 0
112
112
  DB.create_table!(:items){String :a, :default=>"blah"}
113
- DB.schema(:items).first.last[:ruby_default].should == 'blah'
113
+ DB.schema(:items).first.last[:ruby_default].must_equal 'blah'
114
114
  end
115
115
 
116
- specify "should make :default nil for a NULL default" do
116
+ it "should make :default nil for a NULL default" do
117
117
  DB.create_table!(:items){Integer :number}
118
- DB.schema(:items).first.last[:default].should == nil
118
+ DB.schema(:items).first.last[:default].must_equal nil
119
119
  DB.create_table!(:items){Integer :number, :default=>0}
120
- DB.schema(:items).first.last[:default].should_not == nil
120
+ DB.schema(:items).first.last[:default].wont_equal nil
121
121
  end
122
122
 
123
- specify "should parse current timestamp defaults from the schema properly" do
123
+ it "should parse current timestamp defaults from the schema properly" do
124
124
  DB.create_table!(:items){Time :a, :default=>Sequel::CURRENT_TIMESTAMP}
125
- DB.schema(:items).first.last[:ruby_default].should == Sequel::CURRENT_TIMESTAMP
125
+ DB.schema(:items).first.last[:ruby_default].must_equal Sequel::CURRENT_TIMESTAMP
126
126
  end
127
127
 
128
128
  cspecify "should parse current date defaults from the schema properly", :mysql, :oracle do
129
129
  DB.create_table!(:items){Date :a, :default=>Sequel::CURRENT_DATE}
130
- DB.schema(:items).first.last[:ruby_default].should == Sequel::CURRENT_DATE
130
+ DB.schema(:items).first.last[:ruby_default].must_equal Sequel::CURRENT_DATE
131
131
  end
132
132
 
133
133
  cspecify "should parse types from the schema properly", [:jdbc, :db2], :oracle do
134
134
  DB.create_table!(:items){Integer :number}
135
- DB.schema(:items).first.last[:type].should == :integer
135
+ DB.schema(:items).first.last[:type].must_equal :integer
136
136
  DB.create_table!(:items){Fixnum :number}
137
- DB.schema(:items).first.last[:type].should == :integer
137
+ DB.schema(:items).first.last[:type].must_equal :integer
138
138
  DB.create_table!(:items){Bignum :number}
139
- DB.schema(:items).first.last[:type].should == :integer
139
+ DB.schema(:items).first.last[:type].must_equal :integer
140
140
  DB.create_table!(:items){Float :number}
141
- DB.schema(:items).first.last[:type].should == :float
141
+ DB.schema(:items).first.last[:type].must_equal :float
142
142
  DB.create_table!(:items){BigDecimal :number, :size=>[11, 2]}
143
- DB.schema(:items).first.last[:type].should == :decimal
143
+ DB.schema(:items).first.last[:type].must_equal :decimal
144
144
  DB.create_table!(:items){Numeric :number, :size=>[12, 0]}
145
- DB.schema(:items).first.last[:type].should == :integer
145
+ DB.schema(:items).first.last[:type].must_equal :integer
146
146
  DB.create_table!(:items){String :number}
147
- DB.schema(:items).first.last[:type].should == :string
147
+ DB.schema(:items).first.last[:type].must_equal :string
148
148
  DB.create_table!(:items){Date :number}
149
- DB.schema(:items).first.last[:type].should == :date
149
+ DB.schema(:items).first.last[:type].must_equal :date
150
150
  DB.create_table!(:items){Time :number}
151
- DB.schema(:items).first.last[:type].should == :datetime
151
+ DB.schema(:items).first.last[:type].must_equal :datetime
152
152
  DB.create_table!(:items){DateTime :number}
153
- DB.schema(:items).first.last[:type].should == :datetime
153
+ DB.schema(:items).first.last[:type].must_equal :datetime
154
154
  DB.create_table!(:items){File :number}
155
- DB.schema(:items).first.last[:type].should == :blob
155
+ DB.schema(:items).first.last[:type].must_equal :blob
156
156
  DB.create_table!(:items){TrueClass :number}
157
- DB.schema(:items).first.last[:type].should == :boolean
157
+ DB.schema(:items).first.last[:type].must_equal :boolean
158
158
  DB.create_table!(:items){FalseClass :number}
159
- DB.schema(:items).first.last[:type].should == :boolean
159
+ DB.schema(:items).first.last[:type].must_equal :boolean
160
160
  end
161
161
 
162
- specify "should parse maximum length for string columns" do
162
+ it "should parse maximum length for string columns" do
163
163
  DB.create_table!(:items){String :a, :size=>4}
164
- DB.schema(:items).first.last[:max_length].should == 4
164
+ DB.schema(:items).first.last[:max_length].must_equal 4
165
165
  DB.create_table!(:items){String :a, :fixed=>true, :size=>3}
166
- DB.schema(:items).first.last[:max_length].should == 3
166
+ DB.schema(:items).first.last[:max_length].must_equal 3
167
167
  end
168
168
  end if DB.supports_schema_parsing?
169
169
 
@@ -172,36 +172,36 @@ describe "Database index parsing" do
172
172
  DB.drop_table?(:items)
173
173
  end
174
174
 
175
- specify "should parse indexes into a hash" do
175
+ it "should parse indexes into a hash" do
176
176
  # Delete :deferrable entry, since not all adapters implement it
177
177
  f = lambda{h = DB.indexes(:items); h.values.each{|h2| h2.delete(:deferrable)}; h}
178
178
 
179
179
  DB.create_table!(:items){Integer :n; Integer :a}
180
- f.call.should == {}
180
+ f.call.must_equal({})
181
181
  DB.add_index(:items, :n)
182
- f.call.should == {:items_n_index=>{:columns=>[:n], :unique=>false}}
182
+ f.call.must_equal(:items_n_index=>{:columns=>[:n], :unique=>false})
183
183
  DB.drop_index(:items, :n)
184
- f.call.should == {}
184
+ f.call.must_equal({})
185
185
  DB.add_index(:items, :n, :unique=>true, :name=>:blah_blah_index)
186
- f.call.should == {:blah_blah_index=>{:columns=>[:n], :unique=>true}}
186
+ f.call.must_equal(:blah_blah_index=>{:columns=>[:n], :unique=>true})
187
187
  DB.add_index(:items, [:n, :a])
188
- f.call.should == {:blah_blah_index=>{:columns=>[:n], :unique=>true}, :items_n_a_index=>{:columns=>[:n, :a], :unique=>false}}
188
+ f.call.must_equal(:blah_blah_index=>{:columns=>[:n], :unique=>true}, :items_n_a_index=>{:columns=>[:n, :a], :unique=>false})
189
189
  DB.drop_index(:items, :n, :name=>:blah_blah_index)
190
- f.call.should == {:items_n_a_index=>{:columns=>[:n, :a], :unique=>false}}
190
+ f.call.must_equal(:items_n_a_index=>{:columns=>[:n, :a], :unique=>false})
191
191
  DB.drop_index(:items, [:n, :a])
192
- f.call.should == {}
192
+ f.call.must_equal({})
193
193
  end
194
194
 
195
- specify "should not include a primary key index" do
195
+ it "should not include a primary key index" do
196
196
  DB.create_table!(:items){primary_key :n}
197
- DB.indexes(:items).should == {}
197
+ DB.indexes(:items).must_equal({})
198
198
  DB.create_table!(:items){Integer :n; Integer :a; primary_key [:n, :a]}
199
- DB.indexes(:items).should == {}
199
+ DB.indexes(:items).must_equal({})
200
200
  end
201
201
 
202
202
  cspecify "should not include partial indexes", :sqlite do
203
203
  DB.create_table!(:items){Integer :n; Integer :a; index :n, :where=>proc{n > 10}}
204
- DB.indexes(:items).should == {}
204
+ DB.indexes(:items).must_equal({})
205
205
  end if DB.supports_partial_indexes?
206
206
  end if DB.supports_index_parsing?
207
207
 
@@ -219,16 +219,16 @@ describe "Database foreign key parsing" do
219
219
  e.last.shift
220
220
  end
221
221
  end
222
- a.should == e
222
+ a.must_equal e
223
223
  end
224
- actual.length.should == expected.length
224
+ actual.length.must_equal expected.length
225
225
  end
226
226
  end
227
227
  after do
228
228
  @db.drop_table?(:b, :a)
229
229
  end
230
230
 
231
- specify "should parse foreign key information into an array of hashes" do
231
+ it "should parse foreign key information into an array of hashes" do
232
232
  @db.create_table!(:a, :engine=>:InnoDB){primary_key :c; Integer :d, :null => false, :unique => true}
233
233
  @db.create_table!(:b, :engine=>:InnoDB){foreign_key :e, :a}
234
234
  @pr[:a]
@@ -250,11 +250,11 @@ describe "Database foreign key parsing" do
250
250
  @db.alter_table(:b){drop_foreign_key :e}
251
251
  @pr[:b, [[:f], :a, [:c]], [[:f], :a, [:d]]]
252
252
 
253
- proc{@db.alter_table(:b){drop_foreign_key :f}}.should raise_error(Sequel::Error)
253
+ proc{@db.alter_table(:b){drop_foreign_key :f}}.must_raise(Sequel::Error, Sequel::DatabaseError)
254
254
  @pr[:b, [[:f], :a, [:c]], [[:f], :a, [:d]]]
255
255
  end
256
256
 
257
- specify "should handle composite foreign and primary keys" do
257
+ it "should handle composite foreign and primary keys" do
258
258
  @db.create_table!(:a, :engine=>:InnoDB){Integer :b, :null=>false; Integer :c, :null=>false; Integer :d, :null=>false; primary_key [:b, :c]; unique [:d, :c]}
259
259
  @db.create_table!(:b, :engine=>:InnoDB){Integer :e, :null=>false; Integer :f, :null=>false; Integer :g, :null=>false; foreign_key [:e, :f], :a; foreign_key [:g, :f], :a, :key=>[:d, :c]}
260
260
  @pr[:b, [[:e, :f], :a, [:pk, :b, :c]], [[:g, :f], :a, [:d, :c]]]
@@ -272,32 +272,32 @@ describe "Database schema modifiers" do
272
272
  @db.drop_table(:items2) rescue nil
273
273
  end
274
274
 
275
- specify "should create tables correctly" do
275
+ it "should create tables correctly" do
276
276
  @db.create_table!(:items){Integer :number}
277
- @db.table_exists?(:items).should == true
278
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:number]
277
+ @db.table_exists?(:items).must_equal true
278
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:number]
279
279
  @ds.insert([10])
280
- @ds.columns!.should == [:number]
280
+ @ds.columns!.must_equal [:number]
281
281
  end
282
282
 
283
- specify "should create tables from select statements correctly" do
283
+ it "should create tables from select statements correctly" do
284
284
  @db.create_table!(:items){Integer :number}
285
285
  @ds.insert([10])
286
286
  @db.create_table(:items2, :as=>@db[:items])
287
- @db.schema(:items2, :reload=>true).map{|x| x.first}.should == [:number]
288
- @db[:items2].columns.should == [:number]
289
- @db[:items2].all.should == [{:number=>10}]
287
+ @db.schema(:items2, :reload=>true).map{|x| x.first}.must_equal [:number]
288
+ @db[:items2].columns.must_equal [:number]
289
+ @db[:items2].all.must_equal [{:number=>10}]
290
290
  end
291
291
 
292
- specify "should not raise an error if table doesn't exist when using drop_table :if_exists" do
293
- proc{@db.drop_table(:items, :if_exists=>true)}.should_not raise_error
292
+ it "should not raise an error if table doesn't exist when using drop_table :if_exists" do
293
+ @db.drop_table(:items, :if_exists=>true)
294
294
  end if DB.supports_drop_table_if_exists?
295
295
 
296
296
  describe "views" do
297
297
  before do
298
298
  @db.drop_view(:items_view2) rescue nil
299
299
  @db.drop_view(:items_view) rescue nil
300
- @db.create_table(:items){Integer :number}
300
+ @db.create_table!(:items){Integer :number}
301
301
  @ds.insert(:number=>1)
302
302
  @ds.insert(:number=>2)
303
303
  end
@@ -306,228 +306,228 @@ describe "Database schema modifiers" do
306
306
  @db.drop_view(:items_view) rescue nil
307
307
  end
308
308
 
309
- specify "should create views correctly" do
309
+ it "should create views correctly" do
310
310
  @db.create_view(:items_view, @ds.where(:number=>1))
311
- @db[:items_view].map(:number).should == [1]
311
+ @db[:items_view].map(:number).must_equal [1]
312
312
  end
313
313
 
314
- specify "should create views with check options correctly" do
314
+ it "should create views with check options correctly" do
315
315
  @db.create_view(:items_view, @ds.where{number > 2}, :check=>true)
316
- proc{@db[:items_view].insert(1)}.should raise_error(Sequel::DatabaseError)
316
+ proc{@db[:items_view].insert(1)}.must_raise(Sequel::DatabaseError)
317
317
  @db[:items_view].insert(3)
318
- @db[:items_view].select_order_map(:number).should == [3]
318
+ @db[:items_view].select_order_map(:number).must_equal [3]
319
319
  @db.create_view(:items_view2, @db[:items_view].where{number > 1}, :check=>true)
320
- proc{@db[:items_view2].insert(1)}.should raise_error(Sequel::DatabaseError)
321
- proc{@db[:items_view2].insert(2)}.should raise_error(Sequel::DatabaseError)
320
+ proc{@db[:items_view2].insert(1)}.must_raise(Sequel::DatabaseError)
321
+ proc{@db[:items_view2].insert(2)}.must_raise(Sequel::DatabaseError)
322
322
  @db[:items_view2].insert(4)
323
- @db[:items_view2].select_order_map(:number).should == [3, 4]
324
- @ds.select_order_map(:number).should == [1, 2, 3, 4]
323
+ @db[:items_view2].select_order_map(:number).must_equal [3, 4]
324
+ @ds.select_order_map(:number).must_equal [1, 2, 3, 4]
325
325
  end if DB.supports_views_with_check_option?
326
326
 
327
- specify "should create views with local check options correctly" do
327
+ it "should create views with local check options correctly" do
328
328
  @db.create_view(:items_view, @ds.where{number > 2})
329
329
  @db[:items_view].insert(3)
330
- @db[:items_view].select_order_map(:number).should == [3]
330
+ @db[:items_view].select_order_map(:number).must_equal [3]
331
331
  @db.create_view(:items_view2, @db[:items_view].where{number > 1}, :check=>:local)
332
- proc{@db[:items_view2].insert(1)}.should raise_error(Sequel::DatabaseError)
332
+ proc{@db[:items_view2].insert(1)}.must_raise(Sequel::DatabaseError)
333
333
  @db[:items_view2].insert(2)
334
334
  @db[:items_view2].insert(4)
335
- @db[:items_view2].select_order_map(:number).should == [3, 4]
336
- @ds.select_order_map(:number).should == [1, 2, 2, 3, 4]
335
+ @db[:items_view2].select_order_map(:number).must_equal [3, 4]
336
+ @ds.select_order_map(:number).must_equal [1, 2, 2, 3, 4]
337
337
  end if DB.supports_views_with_local_check_option?
338
338
 
339
339
  cspecify "should create views with explicit columns correctly", :sqlite do
340
340
  @db.create_view(:items_view, @ds.where(:number=>1), :columns=>[:n])
341
- @db[:items_view].map(:n).should == [1]
341
+ @db[:items_view].map(:n).must_equal [1]
342
342
  end
343
343
 
344
- specify "should drop views correctly" do
344
+ it "should drop views correctly" do
345
345
  @db.create_view(:items_view, @ds.where(:number=>1))
346
346
  @db.drop_view(:items_view)
347
- proc{@db[:items_view].map(:number)}.should raise_error(Sequel::DatabaseError)
347
+ proc{@db[:items_view].map(:number)}.must_raise(Sequel::DatabaseError)
348
348
  end
349
349
 
350
- specify "should not raise an error if view doesn't exist when using drop_view :if_exists" do
351
- proc{@db.drop_view(:items_view, :if_exists=>true)}.should_not raise_error
350
+ it "should not raise an error if view doesn't exist when using drop_view :if_exists" do
351
+ @db.drop_view(:items_view, :if_exists=>true)
352
352
  end if DB.supports_drop_table_if_exists?
353
353
 
354
- specify "should create or replace views correctly" do
354
+ it "should create or replace views correctly" do
355
355
  @db.create_or_replace_view(:items_view, @ds.where(:number=>1))
356
- @db[:items_view].map(:number).should == [1]
356
+ @db[:items_view].map(:number).must_equal [1]
357
357
  @db.create_or_replace_view(:items_view, @ds.where(:number=>2))
358
- @db[:items_view].map(:number).should == [2]
358
+ @db[:items_view].map(:number).must_equal [2]
359
359
  end
360
360
  end
361
361
 
362
- specify "should handle create table in a rolled back transaction" do
362
+ it "should handle create table in a rolled back transaction" do
363
363
  @db.drop_table?(:items)
364
364
  @db.transaction(:rollback=>:always){@db.create_table(:items){Integer :number}}
365
- @db.table_exists?(:items).should == false
365
+ @db.table_exists?(:items).must_equal false
366
366
  end if DB.supports_transactional_ddl?
367
367
 
368
368
  describe "join tables" do
369
369
  after do
370
370
  @db.drop_join_table(:cat_id=>:cats, :dog_id=>:dogs) if @db.table_exists?(:cats_dogs)
371
371
  @db.drop_table(:cats, :dogs)
372
- @db.table_exists?(:cats_dogs).should == false
372
+ @db.table_exists?(:cats_dogs).must_equal false
373
373
  end
374
374
 
375
- specify "should create join tables correctly" do
375
+ it "should create join tables correctly" do
376
376
  @db.create_table!(:cats){primary_key :id}
377
377
  @db.create_table!(:dogs){primary_key :id}
378
378
  @db.create_join_table(:cat_id=>:cats, :dog_id=>:dogs)
379
- @db.table_exists?(:cats_dogs).should == true
379
+ @db.table_exists?(:cats_dogs).must_equal true
380
380
  end
381
381
  end
382
382
 
383
- cspecify "should create temporary tables without raising an exception", :fdbsql do
383
+ it "should create temporary tables without raising an exception" do
384
384
  @db.create_table!(:items_temp, :temp=>true){Integer :number}
385
385
  end
386
386
 
387
- specify "should have create_table? only create the table if it doesn't already exist" do
387
+ it "should have create_table? only create the table if it doesn't already exist" do
388
388
  @db.create_table!(:items){String :a}
389
389
  @db.create_table?(:items){String :b}
390
- @db[:items].columns.should == [:a]
390
+ @db[:items].columns.must_equal [:a]
391
391
  @db.drop_table?(:items)
392
392
  @db.create_table?(:items){String :b}
393
- @db[:items].columns.should == [:b]
393
+ @db[:items].columns.must_equal [:b]
394
394
  end
395
395
 
396
- specify "should have create_table? work correctly with indexes" do
396
+ it "should have create_table? work correctly with indexes" do
397
397
  @db.create_table!(:items){String :a, :index=>true}
398
398
  @db.create_table?(:items){String :b, :index=>true}
399
- @db[:items].columns.should == [:a]
399
+ @db[:items].columns.must_equal [:a]
400
400
  @db.drop_table?(:items)
401
401
  @db.create_table?(:items){String :b, :index=>true}
402
- @db[:items].columns.should == [:b]
402
+ @db[:items].columns.must_equal [:b]
403
403
  end
404
404
 
405
- specify "should rename tables correctly" do
405
+ it "should rename tables correctly" do
406
406
  @db.drop_table?(:items)
407
407
  @db.create_table!(:items2){Integer :number}
408
408
  @db.rename_table(:items2, :items)
409
- @db.table_exists?(:items).should == true
410
- @db.table_exists?(:items2).should == false
411
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:number]
409
+ @db.table_exists?(:items).must_equal true
410
+ @db.table_exists?(:items2).must_equal false
411
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:number]
412
412
  @ds.insert([10])
413
- @ds.columns!.should == [:number]
413
+ @ds.columns!.must_equal [:number]
414
414
  end
415
415
 
416
- specify "should allow creating indexes with tables" do
416
+ it "should allow creating indexes with tables" do
417
417
  @db.create_table!(:items){Integer :number; index :number}
418
- @db.table_exists?(:items).should == true
419
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:number]
418
+ @db.table_exists?(:items).must_equal true
419
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:number]
420
420
  @ds.insert([10])
421
- @ds.columns!.should == [:number]
421
+ @ds.columns!.must_equal [:number]
422
422
  end
423
423
 
424
- specify "should allow creating partial indexes with tables" do
424
+ it "should allow creating partial indexes with tables" do
425
425
  @db.create_table!(:items){Integer :number; index :number, :where=>proc{number > 10}}
426
- @db.table_exists?(:items).should == true
427
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:number]
426
+ @db.table_exists?(:items).must_equal true
427
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:number]
428
428
  @ds.insert([10])
429
- @ds.columns!.should == [:number]
429
+ @ds.columns!.must_equal [:number]
430
430
  end if DB.supports_partial_indexes?
431
431
 
432
- specify "should handle combination of default, unique, and not null" do
432
+ it "should handle combination of default, unique, and not null" do
433
433
  @db.create_table!(:items){Integer :number, :default=>0, :null=>false, :unique=>true}
434
- @db.table_exists?(:items).should == true
435
- @db.schema(:items, :reload=>true).map{|x| x.last}.first.values_at(:ruby_default, :allow_null).should == [0, false]
434
+ @db.table_exists?(:items).must_equal true
435
+ @db.schema(:items, :reload=>true).map{|x| x.last}.first.values_at(:ruby_default, :allow_null).must_equal [0, false]
436
436
  @ds.insert([10])
437
437
  end
438
438
 
439
- cspecify "should be able to specify constraint names for column constraints", :fdbsql do
439
+ it "should be able to specify constraint names for column constraints" do
440
440
  @db.create_table!(:items2){primary_key :id, :primary_key_constraint_name=>:foo_pk}
441
441
  @db.create_table!(:items){foreign_key :id, :items2, :unique=>true, :foreign_key_constraint_name => :foo_fk, :unique_constraint_name => :foo_uk, :null=>false}
442
442
  @db.alter_table(:items){drop_constraint :foo_fk, :type=>:foreign_key; drop_constraint :foo_uk, :type=>:unique}
443
443
  @db.alter_table(:items2){drop_constraint :foo_pk, :type=>:primary_key}
444
444
  end
445
445
 
446
- specify "should handle foreign keys correctly when creating tables" do
446
+ it "should handle foreign keys correctly when creating tables" do
447
447
  @db.create_table!(:items) do
448
448
  primary_key :id
449
449
  foreign_key :item_id, :items
450
450
  unique [:item_id, :id]
451
451
  foreign_key [:id, :item_id], :items, :key=>[:item_id, :id]
452
452
  end
453
- @db.table_exists?(:items).should == true
454
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id, :item_id]
455
- @ds.columns!.should == [:id, :item_id]
453
+ @db.table_exists?(:items).must_equal true
454
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id, :item_id]
455
+ @ds.columns!.must_equal [:id, :item_id]
456
456
  end
457
457
 
458
- specify "should add columns to tables correctly" do
458
+ it "should add columns to tables correctly" do
459
459
  @db.create_table!(:items){Integer :number}
460
460
  @ds.insert(:number=>10)
461
461
  @db.alter_table(:items){add_column :name, String}
462
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:number, :name]
463
- @ds.columns!.should == [:number, :name]
464
- @ds.all.should == [{:number=>10, :name=>nil}]
462
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:number, :name]
463
+ @ds.columns!.must_equal [:number, :name]
464
+ @ds.all.must_equal [{:number=>10, :name=>nil}]
465
465
  end
466
466
 
467
467
  cspecify "should add primary key columns to tables correctly", :derby do
468
468
  @db.create_table!(:items){Integer :number}
469
469
  @ds.insert(:number=>10)
470
470
  @db.alter_table(:items){add_primary_key :id}
471
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:number, :id]
472
- @ds.columns!.should == [:number, :id]
473
- @ds.map(:number).should == [10]
474
- proc{@ds.insert(:id=>@ds.map(:id).first)}.should raise_error
471
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:number, :id]
472
+ @ds.columns!.must_equal [:number, :id]
473
+ @ds.map(:number).must_equal [10]
474
+ proc{@ds.insert(:id=>@ds.map(:id).first)}.must_raise Sequel::UniqueConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError
475
475
  end
476
476
 
477
- specify "should drop primary key constraints from tables correctly" do
477
+ it "should drop primary key constraints from tables correctly" do
478
478
  @db.create_table!(:items){Integer :number; primary_key [:number], :name=>:items_pk}
479
479
  @ds.insert(:number=>10)
480
480
  @db.alter_table(:items){drop_constraint :items_pk, :type=>:primary_key}
481
- @ds.map(:number).should == [10]
482
- proc{@ds.insert(10)}.should_not raise_error
481
+ @ds.map(:number).must_equal [10]
482
+ @ds.insert(10)
483
483
  end
484
484
 
485
- specify "should add foreign key columns to tables correctly" do
485
+ it "should add foreign key columns to tables correctly" do
486
486
  @db.create_table!(:items){primary_key :id}
487
487
  @ds.insert
488
488
  i = @ds.get(:id)
489
489
  @db.alter_table(:items){add_foreign_key :item_id, :items}
490
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id, :item_id]
491
- @ds.columns!.should == [:id, :item_id]
492
- @ds.all.should == [{:id=>i, :item_id=>nil}]
490
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id, :item_id]
491
+ @ds.columns!.must_equal [:id, :item_id]
492
+ @ds.all.must_equal [{:id=>i, :item_id=>nil}]
493
493
  end
494
494
 
495
- specify "should not allow NULLs in a primary key" do
495
+ it "should not allow NULLs in a primary key" do
496
496
  @db.create_table!(:items){String :id, :primary_key=>true}
497
- proc{@ds.insert(:id=>nil)}.should raise_error(Sequel::DatabaseError)
497
+ proc{@ds.insert(:id=>nil)}.must_raise(Sequel::NotNullConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError)
498
498
  end
499
499
 
500
- specify "should rename columns correctly" do
500
+ it "should rename columns correctly" do
501
501
  @db.create_table!(:items){Integer :id}
502
502
  @ds.insert(:id=>10)
503
503
  @db.alter_table(:items){rename_column :id, :id2}
504
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id2]
505
- @ds.columns!.should == [:id2]
506
- @ds.all.should == [{:id2=>10}]
504
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id2]
505
+ @ds.columns!.must_equal [:id2]
506
+ @ds.all.must_equal [{:id2=>10}]
507
507
  end
508
508
 
509
- specify "should rename columns with defaults correctly" do
509
+ it "should rename columns with defaults correctly" do
510
510
  @db.create_table!(:items){String :n, :default=>'blah'}
511
511
  @ds.insert
512
512
  @db.alter_table(:items){rename_column :n, :n2}
513
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:n2]
514
- @ds.columns!.should == [:n2]
513
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:n2]
514
+ @ds.columns!.must_equal [:n2]
515
515
  @ds.insert
516
- @ds.all.should == [{:n2=>'blah'}, {:n2=>'blah'}]
516
+ @ds.all.must_equal [{:n2=>'blah'}, {:n2=>'blah'}]
517
517
  end
518
518
 
519
- specify "should rename columns with not null constraints" do
519
+ it "should rename columns with not null constraints" do
520
520
  @db.create_table!(:items, :engine=>:InnoDB){String :n, :null=>false}
521
521
  @ds.insert(:n=>'blah')
522
522
  @db.alter_table(:items){rename_column :n, :n2}
523
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:n2]
524
- @ds.columns!.should == [:n2]
523
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:n2]
524
+ @ds.columns!.must_equal [:n2]
525
525
  @ds.insert(:n2=>'blah')
526
- @ds.all.should == [{:n2=>'blah'}, {:n2=>'blah'}]
527
- proc{@ds.insert(:n=>nil)}.should raise_error(Sequel::DatabaseError)
526
+ @ds.all.must_equal [{:n2=>'blah'}, {:n2=>'blah'}]
527
+ proc{@ds.insert(:n=>nil)}.must_raise(Sequel::DatabaseError)
528
528
  end
529
529
 
530
- specify "should rename columns when the table is referenced by a foreign key" do
530
+ it "should rename columns when the table is referenced by a foreign key" do
531
531
  @db.create_table!(:items2){primary_key :id; Integer :a}
532
532
  @db.create_table!(:items){Integer :id, :primary_key=>true; foreign_key :items_id, :items2}
533
533
  @db[:items2].insert(:a=>10)
@@ -535,106 +535,106 @@ describe "Database schema modifiers" do
535
535
  @db.alter_table(:items2){rename_column :a, :b}
536
536
  @db[:items2].insert(:b=>20)
537
537
  @ds.insert(:id=>2)
538
- @db[:items2].select_order_map([:id, :b]).should == [[1, 10], [2, 20]]
538
+ @db[:items2].select_order_map([:id, :b]).must_equal [[1, 10], [2, 20]]
539
539
  end
540
540
 
541
541
  cspecify "should rename primary_key columns correctly", :db2 do
542
542
  @db.create_table!(:items){Integer :id, :primary_key=>true}
543
543
  @ds.insert(:id=>10)
544
544
  @db.alter_table(:items){rename_column :id, :id2}
545
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id2]
546
- @ds.columns!.should == [:id2]
547
- @ds.all.should == [{:id2=>10}]
545
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id2]
546
+ @ds.columns!.must_equal [:id2]
547
+ @ds.all.must_equal [{:id2=>10}]
548
548
  end
549
549
 
550
550
  cspecify "should set column NULL/NOT NULL correctly", [:jdbc, :db2], [:db2] do
551
551
  @db.create_table!(:items, :engine=>:InnoDB){Integer :id}
552
552
  @ds.insert(:id=>10)
553
553
  @db.alter_table(:items){set_column_allow_null :id, false}
554
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id]
555
- @ds.columns!.should == [:id]
556
- proc{@ds.insert(:id=>nil)}.should raise_error(Sequel::DatabaseError)
554
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id]
555
+ @ds.columns!.must_equal [:id]
556
+ proc{@ds.insert(:id=>nil)}.must_raise(Sequel::NotNullConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError)
557
557
  @db.alter_table(:items){set_column_allow_null :id, true}
558
558
  @ds.insert(:id=>nil)
559
- @ds.all.should == [{:id=>10}, {:id=>nil}]
559
+ @ds.all.must_equal [{:id=>10}, {:id=>nil}]
560
560
  end
561
561
 
562
- specify "should set column defaults correctly" do
562
+ it "should set column defaults correctly" do
563
563
  @db.create_table!(:items){Integer :id}
564
564
  @ds.insert(:id=>10)
565
565
  @db.alter_table(:items){set_column_default :id, 20}
566
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id]
567
- @ds.columns!.should == [:id]
566
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id]
567
+ @ds.columns!.must_equal [:id]
568
568
  @ds.insert
569
- @ds.all.should == [{:id=>10}, {:id=>20}]
569
+ @ds.all.must_equal [{:id=>10}, {:id=>20}]
570
570
  end
571
571
 
572
572
  cspecify "should set column types correctly", [:jdbc, :db2], [:db2], :oracle do
573
573
  @db.create_table!(:items){Integer :id}
574
574
  @ds.insert(:id=>10)
575
575
  @db.alter_table(:items){set_column_type :id, String}
576
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id]
577
- @ds.columns!.should == [:id]
576
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id]
577
+ @ds.columns!.must_equal [:id]
578
578
  @ds.insert(:id=>'20')
579
- @ds.all.should == [{:id=>"10"}, {:id=>"20"}]
579
+ @ds.all.must_equal [{:id=>"10"}, {:id=>"20"}]
580
580
  end
581
581
 
582
582
  cspecify "should set column types without modifying NULL/NOT NULL", [:jdbc, :db2], [:db2], :oracle, :derby do
583
583
  @db.create_table!(:items){Integer :id, :null=>false, :default=>2}
584
- proc{@ds.insert(:id=>nil)}.should raise_error(Sequel::DatabaseError)
584
+ proc{@ds.insert(:id=>nil)}.must_raise(Sequel::NotNullConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError)
585
585
  @db.alter_table(:items){set_column_type :id, String}
586
- proc{@ds.insert(:id=>nil)}.should raise_error(Sequel::DatabaseError)
586
+ proc{@ds.insert(:id=>nil)}.must_raise(Sequel::NotNullConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError)
587
587
 
588
588
  @db.create_table!(:items){Integer :id}
589
589
  @ds.insert(:id=>nil)
590
590
  @db.alter_table(:items){set_column_type :id, String}
591
591
  @ds.insert(:id=>nil)
592
- @ds.map(:id).should == [nil, nil]
592
+ @ds.map(:id).must_equal [nil, nil]
593
593
  end
594
594
 
595
595
  cspecify "should set column types without modifying defaults", [:jdbc, :db2], [:db2], :oracle, :derby do
596
596
  @db.create_table!(:items){Integer :id, :default=>0}
597
597
  @ds.insert
598
- @ds.map(:id).should == [0]
598
+ @ds.map(:id).must_equal [0]
599
599
  @db.alter_table(:items){set_column_type :id, String}
600
600
  @ds.insert
601
- @ds.map(:id).should == ['0', '0']
601
+ @ds.map(:id).must_equal ['0', '0']
602
602
 
603
603
  @db.create_table!(:items){String :id, :default=>'a'}
604
604
  @ds.insert
605
- @ds.map(:id).should == %w'a'
605
+ @ds.map(:id).must_equal %w'a'
606
606
  @db.alter_table(:items){set_column_type :id, String, :size=>1}
607
607
  @ds.insert
608
- @ds.map(:id).should == %w'a a'
608
+ @ds.map(:id).must_equal %w'a a'
609
609
  end
610
610
 
611
- specify "should add unnamed unique constraints and foreign key table constraints correctly" do
611
+ it "should add unnamed unique constraints and foreign key table constraints correctly" do
612
612
  @db.create_table!(:items, :engine=>:InnoDB){Integer :id, :null => false; Integer :item_id, :null => false}
613
613
  @db.alter_table(:items) do
614
614
  add_unique_constraint [:item_id, :id]
615
615
  add_foreign_key [:id, :item_id], :items, :key=>[:item_id, :id]
616
616
  end
617
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id, :item_id]
618
- @ds.columns!.should == [:id, :item_id]
619
- proc{@ds.insert(1, 1)}.should_not raise_error
620
- proc{@ds.insert(1, 1)}.should raise_error
621
- proc{@ds.insert(1, 2)}.should raise_error
617
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id, :item_id]
618
+ @ds.columns!.must_equal [:id, :item_id]
619
+ @ds.insert(1, 1)
620
+ proc{@ds.insert(1, 1)}.must_raise Sequel::UniqueConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError
621
+ proc{@ds.insert(1, 2)}.must_raise Sequel::ForeignKeyConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError
622
622
  end
623
623
 
624
- specify "should add named unique constraints and foreign key table constraints correctly" do
624
+ it "should add named unique constraints and foreign key table constraints correctly" do
625
625
  @db.create_table!(:items, :engine=>:InnoDB){Integer :id, :null=>false; Integer :item_id, :null=>false}
626
626
  @db.alter_table(:items) do
627
627
  add_unique_constraint [:item_id, :id], :name=>:unique_iii
628
628
  add_foreign_key [:id, :item_id], :items, :key=>[:item_id, :id], :name=>:fk_iii
629
629
  end
630
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id, :item_id]
631
- @ds.columns!.should == [:id, :item_id]
632
- proc{@ds.insert(1, 1)}.should_not raise_error
633
- proc{@ds.insert(1, 1)}.should raise_error
634
- proc{@ds.insert(1, 2)}.should raise_error
630
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id, :item_id]
631
+ @ds.columns!.must_equal [:id, :item_id]
632
+ @ds.insert(1, 1)
633
+ proc{@ds.insert(1, 1)}.must_raise Sequel::UniqueConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError
634
+ proc{@ds.insert(1, 2)}.must_raise Sequel::ForeignKeyConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError
635
635
  end
636
636
 
637
- specify "should drop unique constraints and foreign key table constraints correctly" do
637
+ it "should drop unique constraints and foreign key table constraints correctly" do
638
638
  @db.create_table!(:items) do
639
639
  Integer :id
640
640
  Integer :item_id
@@ -645,33 +645,33 @@ describe "Database schema modifiers" do
645
645
  drop_constraint(:items_fk, :type=>:foreign_key)
646
646
  drop_constraint(:items_uk, :type=>:unique)
647
647
  end
648
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id, :item_id]
649
- @ds.columns!.should == [:id, :item_id]
650
- proc{@ds.insert(1, 2)}.should_not raise_error
651
- proc{@ds.insert(1, 2)}.should_not raise_error
648
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id, :item_id]
649
+ @ds.columns!.must_equal [:id, :item_id]
650
+ @ds.insert(1, 2)
651
+ @ds.insert(1, 2)
652
652
  end
653
653
 
654
- specify "should remove columns from tables correctly" do
654
+ it "should remove columns from tables correctly" do
655
655
  @db.create_table!(:items) do
656
656
  primary_key :id
657
657
  Integer :i
658
658
  end
659
659
  @ds.insert(:i=>10)
660
660
  @db.drop_column(:items, :i)
661
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id]
661
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id]
662
662
  end
663
663
 
664
- specify "should remove columns with defaults from tables correctly" do
664
+ it "should remove columns with defaults from tables correctly" do
665
665
  @db.create_table!(:items) do
666
666
  primary_key :id
667
667
  Integer :i, :default=>20
668
668
  end
669
669
  @ds.insert(:i=>10)
670
670
  @db.drop_column(:items, :i)
671
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id]
671
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id]
672
672
  end
673
673
 
674
- specify "should remove foreign key columns from tables correctly" do
674
+ it "should remove foreign key columns from tables correctly" do
675
675
  @db.create_table!(:items, :engine=>:InnoDB) do
676
676
  primary_key :id
677
677
  Integer :i
@@ -679,25 +679,25 @@ describe "Database schema modifiers" do
679
679
  end
680
680
  @ds.insert(:i=>10)
681
681
  @db.alter_table(:items){drop_foreign_key :item_id}
682
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id, :i]
682
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id, :i]
683
683
  end if DB.supports_foreign_key_parsing?
684
684
 
685
- specify "should remove multiple columns in a single alter_table block" do
685
+ it "should remove multiple columns in a single alter_table block" do
686
686
  @db.create_table!(:items) do
687
687
  primary_key :id
688
688
  String :name
689
689
  Integer :number
690
690
  end
691
691
  @ds.insert(:number=>10)
692
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id, :name, :number]
692
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id, :name, :number]
693
693
  @db.alter_table(:items) do
694
694
  drop_column :name
695
695
  drop_column :number
696
696
  end
697
- @db.schema(:items, :reload=>true).map{|x| x.first}.should == [:id]
697
+ @db.schema(:items, :reload=>true).map{|x| x.first}.must_equal [:id]
698
698
  end
699
699
 
700
- cspecify "should work correctly with many operations in a single alter_table call", [:jdbc, :db2], [:db2], :fdbsql do
700
+ cspecify "should work correctly with many operations in a single alter_table call", [:jdbc, :db2], [:db2] do
701
701
  @db.create_table!(:items) do
702
702
  primary_key :id
703
703
  String :name2
@@ -714,33 +714,33 @@ describe "Database schema modifiers" do
714
714
  set_column_default :name, 'A13'
715
715
  add_constraint :foo, Sequel.like(:name, 'A%')
716
716
  end
717
- @db[:items].first.should == {:id=>1, :name=>'A12', :number=>nil}
717
+ @db[:items].first.must_equal(:id=>1, :name=>'A12', :number=>nil)
718
718
  @db[:items].delete
719
- proc{@db[:items].insert(:name=>nil)}.should raise_error(Sequel::DatabaseError)
719
+ proc{@db[:items].insert(:name=>nil)}.must_raise(Sequel::NotNullConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError)
720
720
  @db[:items].insert(:number=>1)
721
- @db[:items].get(:name).should == 'A13'
721
+ @db[:items].get(:name).must_equal 'A13'
722
722
  end
723
723
 
724
- specify "should support deferrable foreign key constraints" do
724
+ it "should support deferrable foreign key constraints" do
725
725
  @db.create_table!(:items2){Integer :id, :primary_key=>true}
726
726
  @db.create_table!(:items){foreign_key :id, :items2, :deferrable=>true}
727
- proc{@db[:items].insert(1)}.should raise_error(Sequel::DatabaseError)
728
- proc{@db.transaction{proc{@db[:items].insert(1)}.should_not raise_error}}.should raise_error(Sequel::DatabaseError)
727
+ proc{@db[:items].insert(1)}.must_raise(Sequel::ForeignKeyConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError)
728
+ @db.transaction{proc{@db[:items].insert(1)}}.must_raise(Sequel::ForeignKeyConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError)
729
729
  end if DB.supports_deferrable_foreign_key_constraints?
730
730
 
731
- specify "should support deferrable unique constraints when creating or altering tables" do
731
+ it "should support deferrable unique constraints when creating or altering tables" do
732
732
  @db.create_table!(:items){Integer :t; unique [:t], :name=>:atest_def, :deferrable=>true, :using=>:btree}
733
733
  @db[:items].insert(1)
734
734
  @db[:items].insert(2)
735
- proc{@db[:items].insert(2)}.should raise_error(Sequel::DatabaseError)
736
- proc{@db.transaction{proc{@db[:items].insert(2)}.should_not raise_error}}.should raise_error(Sequel::DatabaseError)
735
+ proc{@db[:items].insert(2)}.must_raise(Sequel::DatabaseError, Sequel::UniqueConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError)
736
+ @db.transaction{proc{@db[:items].insert(2)}}.must_raise(Sequel::DatabaseError, Sequel::UniqueConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError)
737
737
 
738
738
  @db.create_table!(:items){Integer :t}
739
739
  @db.alter_table(:items){add_unique_constraint [:t], :name=>:atest_def, :deferrable=>true, :using=>:btree}
740
740
  @db[:items].insert(1)
741
741
  @db[:items].insert(2)
742
- proc{@db[:items].insert(2)}.should raise_error(Sequel::DatabaseError)
743
- proc{@db.transaction{proc{@db[:items].insert(2)}.should_not raise_error}}.should raise_error(Sequel::DatabaseError)
742
+ proc{@db[:items].insert(2)}.must_raise(Sequel::DatabaseError, Sequel::UniqueConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError)
743
+ @db.transaction{proc{@db[:items].insert(2)}}.must_raise(Sequel::DatabaseError, Sequel::UniqueConstraintViolation, Sequel::ConstraintViolation, Sequel::DatabaseError)
744
744
  end if DB.supports_deferrable_constraints?
745
745
  end
746
746
 
@@ -765,18 +765,18 @@ describe "Database#tables" do
765
765
  @db.drop_table :sequel_test_table
766
766
  end
767
767
 
768
- specify "should return an array of symbols" do
768
+ it "should return an array of symbols" do
769
769
  ts = @db.tables
770
- ts.should be_a_kind_of(Array)
771
- ts.each{|t| t.should be_a_kind_of(Symbol)}
772
- ts.should include(:sequel_test_table)
773
- ts.should_not include(:sequel_test_view)
770
+ ts.must_be_kind_of(Array)
771
+ ts.each{|t| t.must_be_kind_of(Symbol)}
772
+ ts.must_include(:sequel_test_table)
773
+ ts.wont_include(:sequel_test_view)
774
774
  end
775
775
 
776
- specify "should respect the database's identifier_output_method" do
776
+ it "should respect the database's identifier_output_method" do
777
777
  @db.identifier_output_method = :xxxxx
778
778
  @db.identifier_input_method = :xxxxx
779
- @db.tables.each{|t| t.to_s.should =~ /\Ax{5}\d+\z/}
779
+ @db.tables.each{|t| t.to_s.must_match(/\Ax{5}\d+\z/)}
780
780
  end
781
781
  end if DB.supports_table_listing?
782
782
 
@@ -801,17 +801,17 @@ describe "Database#views" do
801
801
  @db.drop_table :sequel_test_table
802
802
  end
803
803
 
804
- specify "should return an array of symbols" do
804
+ it "should return an array of symbols" do
805
805
  ts = @db.views
806
- ts.should be_a_kind_of(Array)
807
- ts.each{|t| t.should be_a_kind_of(Symbol)}
808
- ts.should_not include(:sequel_test_table)
809
- ts.should include(:sequel_test_view)
806
+ ts.must_be_kind_of(Array)
807
+ ts.each{|t| t.must_be_kind_of(Symbol)}
808
+ ts.wont_include(:sequel_test_table)
809
+ ts.must_include(:sequel_test_view)
810
810
  end
811
811
 
812
- specify "should respect the database's identifier_output_method" do
812
+ it "should respect the database's identifier_output_method" do
813
813
  @db.identifier_output_method = :xxxxx
814
814
  @db.identifier_input_method = :xxxxx
815
- @db.views.each{|t| t.to_s.should =~ /\Ax{5}\d+\z/}
815
+ @db.views.each{|t| t.to_s.must_match(/\Ax{5}\d+\z/)}
816
816
  end
817
817
  end if DB.supports_view_listing?