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
@@ -26,42 +26,42 @@ describe Sequel::Model, ".plugin" do
26
26
  end
27
27
 
28
28
  it "should raise LoadError if the plugin is not found" do
29
- proc{@c.plugin :something_or_other}.should raise_error(LoadError)
29
+ proc{@c.plugin :something_or_other}.must_raise(LoadError)
30
30
  end
31
31
 
32
32
  it "should store the plugin in .plugins" do
33
- @c.plugins.should_not include(@t)
33
+ @c.plugins.wont_include(@t)
34
34
  @c.plugin @t
35
- @c.plugins.should include(@t)
35
+ @c.plugins.must_include(@t)
36
36
  end
37
37
 
38
38
  it "should be inherited in subclasses" do
39
- @c.plugins.should_not include(@t)
39
+ @c.plugins.wont_include(@t)
40
40
  c1 = Class.new(@c)
41
41
  @c.plugin @t
42
42
  c2 = Class.new(@c)
43
- @c.plugins.should include(@t)
44
- c1.plugins.should_not include(@t)
45
- c2.plugins.should include(@t)
43
+ @c.plugins.must_include(@t)
44
+ c1.plugins.wont_include(@t)
45
+ c2.plugins.must_include(@t)
46
46
  end
47
47
 
48
48
  it "should accept a symbol and load the module from the Sequel::Plugins namespace" do
49
49
  @c.plugin :timestamped
50
- @c.plugins.should include(@t)
50
+ @c.plugins.must_include(@t)
51
51
  end
52
52
 
53
53
  it "should accept a module" do
54
54
  m = Module.new
55
55
  @c.plugin m
56
- @c.plugins.should include(m)
56
+ @c.plugins.must_include(m)
57
57
  end
58
58
 
59
59
  it "should not attempt to load a plugin twice" do
60
- @c.plugins.should_not include(@t)
60
+ @c.plugins.wont_include(@t)
61
61
  @c.plugin @t
62
- @c.plugins.reject{|m| m != @t}.length.should == 1
62
+ @c.plugins.reject{|m| m != @t}.length.must_equal 1
63
63
  @c.plugin @t
64
- @c.plugins.reject{|m| m != @t}.length.should == 1
64
+ @c.plugins.reject{|m| m != @t}.length.must_equal 1
65
65
  end
66
66
 
67
67
  it "should call apply and configure if the plugin responds to it, with the args and block used" do
@@ -86,15 +86,15 @@ describe Sequel::Model, ".plugin" do
86
86
  b = lambda{42}
87
87
  @c.plugin(m, 123, 1=>2, &b)
88
88
 
89
- m.args.should == [123, {1=>2}]
90
- m.block.should == b
91
- m.block_call.should == 42
92
- @c.new.blah.should == 43
89
+ m.args.must_equal [123, {1=>2}]
90
+ m.block.must_equal b
91
+ m.block_call.must_equal 42
92
+ @c.new.blah.must_equal 43
93
93
 
94
- m.args2.should == [123, {1=>2}]
95
- m.block2.should == b
96
- m.block2_call.should == 42
97
- @c.new.blag.should == 44
94
+ m.args2.must_equal [123, {1=>2}]
95
+ m.block2.must_equal b
96
+ m.block2_call.must_equal 42
97
+ @c.new.blag.must_equal 44
98
98
  end
99
99
 
100
100
  it "should call configure even if the plugin has already been loaded" do
@@ -108,11 +108,11 @@ describe Sequel::Model, ".plugin" do
108
108
 
109
109
  b = lambda{42}
110
110
  @c.plugin(m, 123, 1=>2, &b)
111
- m.args.should == [[b, 123, {1=>2}]]
111
+ m.args.must_equal [[b, 123, {1=>2}]]
112
112
 
113
113
  b2 = lambda{44}
114
114
  @c.plugin(m, 234, 2=>3, &b2)
115
- m.args.should == [[b, 123, {1=>2}], [b2, 234, {2=>3}]]
115
+ m.args.must_equal [[b, 123, {1=>2}], [b2, 234, {2=>3}]]
116
116
  end
117
117
 
118
118
  it "should call things in the following order: apply, ClassMethods, InstanceMethods, DatasetMethods, configure" do
@@ -144,43 +144,43 @@ describe Sequel::Model, ".plugin" do
144
144
 
145
145
  b = lambda{44}
146
146
  @c.plugin(m, 123, 1=>2, &b)
147
- m.args.should == [:apply, :cm, :im, :dm, :configure]
147
+ m.args.must_equal [:apply, :cm, :im, :dm, :configure]
148
148
  @c.plugin(m, 234, 2=>3, &b)
149
- m.args.should == [:apply, :cm, :im, :dm, :configure, :configure]
149
+ m.args.must_equal [:apply, :cm, :im, :dm, :configure, :configure]
150
150
  end
151
151
 
152
152
  it "should include an InstanceMethods module in the class if the plugin includes it" do
153
153
  @c.plugin @t
154
154
  m = @c.new
155
- m.should respond_to(:get_stamp)
156
- m.should respond_to(:abc)
157
- m.abc.should == 123
155
+ m.must_respond_to(:get_stamp)
156
+ m.must_respond_to(:abc)
157
+ m.abc.must_equal 123
158
158
  t = Time.now
159
159
  m[:stamp] = t
160
- m.get_stamp.should == t
160
+ m.get_stamp.must_equal t
161
161
  end
162
162
 
163
163
  it "should extend the class with a ClassMethods module if the plugin includes it" do
164
164
  @c.plugin @t
165
- @c.def.should == 234
165
+ @c.def.must_equal 234
166
166
  end
167
167
 
168
168
  it "should extend the class's dataset with a DatasetMethods module if the plugin includes it" do
169
169
  @c.plugin @t
170
- @c.dataset.ghi.should == 345
170
+ @c.dataset.ghi.must_equal 345
171
171
  end
172
172
 
173
173
  it "should save the DatasetMethods module and apply it later if the class doesn't have a dataset" do
174
174
  c = Class.new(Sequel::Model)
175
175
  c.plugin @t
176
176
  c.dataset = DB[:i]
177
- c.dataset.ghi.should == 345
177
+ c.dataset.ghi.must_equal 345
178
178
  end
179
179
 
180
180
  it "should save the DatasetMethods module and apply it later if the class has a dataset" do
181
181
  @c.plugin @t
182
182
  @c.dataset = DB[:i]
183
- @c.dataset.ghi.should == 345
183
+ @c.dataset.ghi.must_equal 345
184
184
  end
185
185
 
186
186
  it "should not define class methods for private instance methods in DatasetMethod" do
@@ -192,11 +192,11 @@ describe Sequel::Model, ".plugin" do
192
192
  end
193
193
  end
194
194
  @c.plugin m
195
- @c.dataset.b.should == 2
196
- lambda{@c.dataset.a}.should raise_error(NoMethodError)
197
- @c.dataset.send(:a).should == 1
198
- lambda{@c.a}.should raise_error(NoMethodError)
199
- lambda{@c.send(:a)}.should raise_error(NoMethodError)
195
+ @c.dataset.b.must_equal 2
196
+ lambda{@c.dataset.a}.must_raise(NoMethodError)
197
+ @c.dataset.send(:a).must_equal 1
198
+ lambda{@c.a}.must_raise(NoMethodError)
199
+ lambda{@c.send(:a)}.must_raise(NoMethodError)
200
200
  end
201
201
 
202
202
  it "should not raise an error if the DatasetMethod module has no public instance methods" do
@@ -206,24 +206,24 @@ describe Sequel::Model, ".plugin" do
206
206
  def a; 1; end
207
207
  end
208
208
  end
209
- lambda{@c.plugin m}.should_not raise_error
209
+ @c.plugin m
210
210
  end
211
211
 
212
212
  it "should not raise an error if plugin submodule names exist higher up in the namespace hierarchy" do
213
213
  class ::ClassMethods; end
214
214
  @c.plugin(m = Module.new)
215
215
  Object.send(:remove_const, :ClassMethods)
216
- @c.plugins.should include(m)
216
+ @c.plugins.must_include(m)
217
217
 
218
218
  class ::InstanceMethods; end
219
219
  @c.plugin(m = Module.new)
220
220
  Object.send(:remove_const, :InstanceMethods)
221
- @c.plugins.should include(m)
221
+ @c.plugins.must_include(m)
222
222
 
223
223
  class ::DatasetMethods; end
224
224
  @c.plugin(m = Module.new)
225
225
  Object.send(:remove_const, :DatasetMethods)
226
- @c.plugins.should include(m)
226
+ @c.plugins.must_include(m)
227
227
  end
228
228
  end
229
229
 
@@ -244,7 +244,7 @@ describe Sequel::Plugins do
244
244
  end
245
245
  end
246
246
  @c.plugin m
247
- @c.one.should == 1
247
+ @c.one.must_equal 1
248
248
  end
249
249
 
250
250
  it "should have def_dataset_methods accept an array with multiple methods" do
@@ -262,8 +262,8 @@ describe Sequel::Plugins do
262
262
  end
263
263
  end
264
264
  @c.plugin m
265
- @c.one.should == 1
266
- @c.two.should == 2
265
+ @c.one.must_equal 1
266
+ @c.two.must_equal 2
267
267
  end
268
268
 
269
269
  it "should have inherited_instance_variables add instance variables to copy into the subclass" do
@@ -277,7 +277,7 @@ describe Sequel::Plugins do
277
277
  end
278
278
  end
279
279
  @c.plugin m
280
- Class.new(@c).one.should == 1
280
+ Class.new(@c).one.must_equal 1
281
281
  end
282
282
 
283
283
  it "should have after_set_dataset add a method to call after set_dataset" do
@@ -291,9 +291,9 @@ describe Sequel::Plugins do
291
291
  end
292
292
  end
293
293
  @c.plugin m
294
- @c.dataset.opts[:foo].should == nil
294
+ @c.dataset.opts[:foo].must_equal nil
295
295
  @c.set_dataset :blah
296
- @c.dataset.opts[:foo].should == 1
296
+ @c.dataset.opts[:foo].must_equal 1
297
297
  end
298
298
  end
299
299
 
@@ -7,12 +7,12 @@ describe "Model#values" do
7
7
 
8
8
  it "should return the hash of model values" do
9
9
  hash = {:x=>1}
10
- @c.load(hash).values.should equal(hash)
10
+ @c.load(hash).values.must_be_same_as(hash)
11
11
  end
12
12
 
13
13
  it "should be aliased as to_hash" do
14
14
  hash = {:x=>1}
15
- @c.load(hash).to_hash.should equal(hash)
15
+ @c.load(hash).to_hash.must_be_same_as(hash)
16
16
  end
17
17
  end
18
18
 
@@ -24,10 +24,10 @@ describe "Model#get_column_value and set_column_value" do
24
24
  end
25
25
 
26
26
  it "should get and set column values" do
27
- @o.get_column_value(:x).should == 1
27
+ @o.get_column_value(:x).must_equal 1
28
28
  @o.set_column_value(:x=, 2)
29
- @o.get_column_value(:x).should == 2
30
- @o.x.should == 2
29
+ @o.get_column_value(:x).must_equal 2
30
+ @o.x.must_equal 2
31
31
  end
32
32
  end
33
33
 
@@ -41,14 +41,14 @@ describe "Model#save server use" do
41
41
  end
42
42
 
43
43
  it "should use the :default server if the model doesn't have one already specified" do
44
- @c.new(:x=>1).save.should == @c.load(:x=>1, :id=>10)
45
- @db.sqls.should == ["INSERT INTO items (x) VALUES (1)", 'SELECT * FROM items WHERE (id = 10) LIMIT 1']
44
+ @c.new(:x=>1).save.must_equal @c.load(:x=>1, :id=>10)
45
+ @db.sqls.must_equal ["INSERT INTO items (x) VALUES (1)", 'SELECT * FROM items WHERE (id = 10) LIMIT 1']
46
46
  end
47
47
 
48
48
  it "should use the model's server if the model has one already specified" do
49
49
  @c.dataset = @c.dataset.server(:blah)
50
- @c.new(:x=>1).save.should == @c.load(:x=>1, :id=>10)
51
- @db.sqls.should == ["INSERT INTO items (x) VALUES (1) -- blah", 'SELECT * FROM items WHERE (id = 10) LIMIT 1 -- blah']
50
+ @c.new(:x=>1).save.must_equal @c.load(:x=>1, :id=>10)
51
+ @db.sqls.must_equal ["INSERT INTO items (x) VALUES (1) -- blah", 'SELECT * FROM items WHERE (id = 10) LIMIT 1 -- blah']
52
52
  end
53
53
  end
54
54
 
@@ -64,7 +64,7 @@ describe "Model#save" do
64
64
  it "should insert a record for a new model instance" do
65
65
  o = @c.new(:x => 1)
66
66
  o.save
67
- DB.sqls.should == ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 13) LIMIT 1"]
67
+ DB.sqls.must_equal ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 13) LIMIT 1"]
68
68
  end
69
69
 
70
70
  it "should use dataset's insert_select method if present" do
@@ -77,13 +77,13 @@ describe "Model#save" do
77
77
  o = @c.new(:x => 1)
78
78
  o.save
79
79
 
80
- o.values.should == {:y=>2}
81
- DB.sqls.should == ["INSERT INTO items (y) VALUES (2) RETURNING *"]
80
+ o.values.must_equal(:y=>2)
81
+ DB.sqls.must_equal ["INSERT INTO items (y) VALUES (2) RETURNING *"]
82
82
  end
83
83
 
84
84
  it "should not use dataset's insert_select method if specific columns are selected" do
85
85
  ds = @c.dataset = @c.dataset.select(:y)
86
- ds.should_not_receive(:insert_select)
86
+ def ds.insert_select(*) raise; end
87
87
  @c.new(:x => 1).save
88
88
  end
89
89
 
@@ -100,28 +100,28 @@ describe "Model#save" do
100
100
  o = @c.new(:x => 1)
101
101
  o.save
102
102
 
103
- o.values.should == {:y=>2}
104
- DB.sqls.should == ["INSERT INTO items (y) VALUES (2) RETURNING y"]
103
+ o.values.must_equal(:y=>2)
104
+ DB.sqls.must_equal ["INSERT INTO items (y) VALUES (2) RETURNING y"]
105
105
  end
106
106
 
107
107
  it "should use value returned by insert as the primary key and refresh the object" do
108
108
  o = @c.new(:x => 11)
109
109
  o.save
110
- DB.sqls.should == ["INSERT INTO items (x) VALUES (11)",
110
+ DB.sqls.must_equal ["INSERT INTO items (x) VALUES (11)",
111
111
  "SELECT * FROM items WHERE (id = 13) LIMIT 1"]
112
112
  end
113
113
 
114
114
  it "should allow you to skip refreshing by overridding _save_refresh" do
115
115
  @c.send(:define_method, :_save_refresh){}
116
116
  @c.create(:x => 11)
117
- DB.sqls.should == ["INSERT INTO items (x) VALUES (11)"]
117
+ DB.sqls.must_equal ["INSERT INTO items (x) VALUES (11)"]
118
118
  end
119
119
 
120
120
  it "should work correctly for inserting a record without a primary key" do
121
121
  @c.no_primary_key
122
122
  o = @c.new(:x => 11)
123
123
  o.save
124
- DB.sqls.should == ["INSERT INTO items (x) VALUES (11)"]
124
+ DB.sqls.must_equal ["INSERT INTO items (x) VALUES (11)"]
125
125
  end
126
126
 
127
127
  it "should set the autoincrementing_primary_key value to the value returned by insert" do
@@ -131,65 +131,65 @@ describe "Model#save" do
131
131
  def o.autoincrementing_primary_key() :y end
132
132
  o.save
133
133
  sqls = DB.sqls
134
- sqls.length.should == 2
135
- sqls.first.should == "INSERT INTO items (x) VALUES (11)"
136
- sqls.last.should =~ %r{SELECT \* FROM items WHERE \(\([xy] = 1[13]\) AND \([xy] = 1[13]\)\) LIMIT 1}
134
+ sqls.length.must_equal 2
135
+ sqls.first.must_equal "INSERT INTO items (x) VALUES (11)"
136
+ sqls.last.must_match %r{SELECT \* FROM items WHERE \(\([xy] = 1[13]\) AND \([xy] = 1[13]\)\) LIMIT 1}
137
137
  end
138
138
 
139
139
  it "should update a record for an existing model instance" do
140
140
  o = @c.load(:id => 3, :x => 1)
141
141
  o.save
142
- DB.sqls.should == ["UPDATE items SET x = 1 WHERE (id = 3)"]
142
+ DB.sqls.must_equal ["UPDATE items SET x = 1 WHERE (id = 3)"]
143
143
  end
144
144
 
145
145
  it "should raise a NoExistingObject exception if the dataset update call doesn't return 1, unless require_modification is false" do
146
146
  o = @c.load(:id => 3, :x => 1)
147
147
  t = o.this
148
148
  t.numrows = 0
149
- proc{o.save}.should raise_error(Sequel::NoExistingObject)
149
+ proc{o.save}.must_raise(Sequel::NoExistingObject)
150
150
  t.numrows = 2
151
- proc{o.save}.should raise_error(Sequel::NoExistingObject)
151
+ proc{o.save}.must_raise(Sequel::NoExistingObject)
152
152
  t.numrows = 1
153
- proc{o.save}.should_not raise_error
153
+ o.save
154
154
 
155
155
  o.require_modification = false
156
156
  t.numrows = 0
157
- proc{o.save}.should_not raise_error
157
+ o.save
158
158
  t.numrows = 2
159
- proc{o.save}.should_not raise_error
159
+ o.save
160
160
  end
161
161
 
162
162
  it "should respect the :columns option to specify the columns to save" do
163
163
  o = @c.load(:id => 3, :x => 1, :y => nil)
164
164
  o.save(:columns=>:y)
165
- DB.sqls.first.should == "UPDATE items SET y = NULL WHERE (id = 3)"
165
+ DB.sqls.first.must_equal "UPDATE items SET y = NULL WHERE (id = 3)"
166
166
  end
167
167
 
168
168
  it "should mark saved columns as not changed" do
169
169
  o = @c.load(:id => 3, :x => 1, :y => nil)
170
170
  o[:y] = 4
171
- o.changed_columns.should == [:y]
171
+ o.changed_columns.must_equal [:y]
172
172
  o.save(:columns=>:x)
173
- o.changed_columns.should == [:y]
173
+ o.changed_columns.must_equal [:y]
174
174
  o.save(:columns=>:y)
175
- o.changed_columns.should == []
175
+ o.changed_columns.must_equal []
176
176
  end
177
177
 
178
178
  it "should mark all columns as not changed if this is a new record" do
179
179
  o = @c.new(:x => 1, :y => nil)
180
180
  o.x = 4
181
- o.changed_columns.should == [:x]
181
+ o.changed_columns.must_equal [:x]
182
182
  o.save
183
- o.changed_columns.should == []
183
+ o.changed_columns.must_equal []
184
184
  end
185
185
 
186
186
  it "should mark all columns as not changed if this is a new record and insert_select was used" do
187
187
  def (@c.dataset).insert_select(h) h.merge(:id=>1) end
188
188
  o = @c.new(:x => 1, :y => nil)
189
189
  o.x = 4
190
- o.changed_columns.should == [:x]
190
+ o.changed_columns.must_equal [:x]
191
191
  o.save
192
- o.changed_columns.should == []
192
+ o.changed_columns.must_equal []
193
193
  end
194
194
 
195
195
  it "should store previous value of @new in @was_new and as well as the hash used for updating in @columns_updated until after hooks finish running" do
@@ -198,44 +198,44 @@ describe "Model#save" do
198
198
  o = @c.new(:x => 1, :y => nil)
199
199
  o[:x] = 2
200
200
  o.save
201
- res.should == [nil, true]
201
+ res.must_equal [nil, true]
202
202
  o.after_save
203
- res.should == [nil, nil]
203
+ res.must_equal [nil, nil]
204
204
 
205
205
  res = nil
206
206
  o = @c.load(:id => 23,:x => 1, :y => nil)
207
207
  o[:x] = 2
208
208
  o.save
209
- res.should == [{:x => 2, :y => nil}, nil]
209
+ res.must_equal [{:x => 2, :y => nil}, nil]
210
210
  o.after_save
211
- res.should == [nil, nil]
211
+ res.must_equal [nil, nil]
212
212
 
213
213
  res = nil
214
214
  o = @c.load(:id => 23,:x => 2, :y => nil)
215
215
  o[:x] = 2
216
216
  o[:y] = 22
217
217
  o.save(:columns=>:x)
218
- res.should == [{:x=>2},nil]
218
+ res.must_equal [{:x=>2},nil]
219
219
  o.after_save
220
- res.should == [nil, nil]
220
+ res.must_equal [nil, nil]
221
221
  end
222
222
 
223
223
  it "should use Model's use_transactions setting by default" do
224
224
  @c.use_transactions = true
225
225
  @c.load(:id => 3, :x => 1, :y => nil).save(:columns=>:y)
226
- DB.sqls.should == ["BEGIN", "UPDATE items SET y = NULL WHERE (id = 3)", "COMMIT"]
226
+ DB.sqls.must_equal ["BEGIN", "UPDATE items SET y = NULL WHERE (id = 3)", "COMMIT"]
227
227
  @c.use_transactions = false
228
228
  @c.load(:id => 3, :x => 1, :y => nil).save(:columns=>:y)
229
- DB.sqls.should == ["UPDATE items SET y = NULL WHERE (id = 3)"]
229
+ DB.sqls.must_equal ["UPDATE items SET y = NULL WHERE (id = 3)"]
230
230
  end
231
231
 
232
232
  it "should inherit Model's use_transactions setting" do
233
233
  @c.use_transactions = true
234
234
  Class.new(@c).load(:id => 3, :x => 1, :y => nil).save(:columns=>:y)
235
- DB.sqls.should == ["BEGIN", "UPDATE items SET y = NULL WHERE (id = 3)", "COMMIT"]
235
+ DB.sqls.must_equal ["BEGIN", "UPDATE items SET y = NULL WHERE (id = 3)", "COMMIT"]
236
236
  @c.use_transactions = false
237
237
  Class.new(@c).load(:id => 3, :x => 1, :y => nil).save(:columns=>:y)
238
- DB.sqls.should == ["UPDATE items SET y = NULL WHERE (id = 3)"]
238
+ DB.sqls.must_equal ["UPDATE items SET y = NULL WHERE (id = 3)"]
239
239
  end
240
240
 
241
241
  it "should use object's use_transactions setting" do
@@ -243,23 +243,23 @@ describe "Model#save" do
243
243
  o.use_transactions = false
244
244
  @c.use_transactions = true
245
245
  o.save(:columns=>:y)
246
- DB.sqls.should == ["UPDATE items SET y = NULL WHERE (id = 3)"]
246
+ DB.sqls.must_equal ["UPDATE items SET y = NULL WHERE (id = 3)"]
247
247
  o = @c.load(:id => 3, :x => 1, :y => nil)
248
248
  o.use_transactions = true
249
249
  @c.use_transactions = false
250
250
  o.save(:columns=>:y)
251
- DB.sqls.should == ["BEGIN", "UPDATE items SET y = NULL WHERE (id = 3)", "COMMIT"]
251
+ DB.sqls.must_equal ["BEGIN", "UPDATE items SET y = NULL WHERE (id = 3)", "COMMIT"]
252
252
  end
253
253
 
254
254
  it "should use :transaction option if given" do
255
255
  o = @c.load(:id => 3, :x => 1, :y => nil)
256
256
  o.use_transactions = true
257
257
  o.save(:columns=>:y, :transaction=>false)
258
- DB.sqls.should == ["UPDATE items SET y = NULL WHERE (id = 3)"]
258
+ DB.sqls.must_equal ["UPDATE items SET y = NULL WHERE (id = 3)"]
259
259
  o = @c.load(:id => 3, :x => 1, :y => nil)
260
260
  o.use_transactions = false
261
261
  o.save(:columns=>:y, :transaction=>true)
262
- DB.sqls.should == ["BEGIN", "UPDATE items SET y = NULL WHERE (id = 3)", "COMMIT"]
262
+ DB.sqls.must_equal ["BEGIN", "UPDATE items SET y = NULL WHERE (id = 3)", "COMMIT"]
263
263
  end
264
264
 
265
265
  it "should rollback if before_save returns false and raise_on_save_failure = true" do
@@ -269,8 +269,8 @@ describe "Model#save" do
269
269
  def o.before_save
270
270
  false
271
271
  end
272
- proc { o.save(:columns=>:y) }.should raise_error(Sequel::HookFailed)
273
- DB.sqls.should == ["BEGIN", "ROLLBACK"]
272
+ proc { o.save(:columns=>:y) }.must_raise(Sequel::HookFailed)
273
+ DB.sqls.must_equal ["BEGIN", "ROLLBACK"]
274
274
  end
275
275
 
276
276
  it "should rollback if before_save calls cancel_action and raise_on_save_failure = true" do
@@ -280,8 +280,8 @@ describe "Model#save" do
280
280
  def o.before_save
281
281
  cancel_action
282
282
  end
283
- proc { o.save(:columns=>:y) }.should raise_error(Sequel::HookFailed)
284
- DB.sqls.should == ["BEGIN", "ROLLBACK"]
283
+ proc { o.save(:columns=>:y) }.must_raise(Sequel::HookFailed)
284
+ DB.sqls.must_equal ["BEGIN", "ROLLBACK"]
285
285
  end
286
286
 
287
287
  it "should rollback if before_save returns false and :raise_on_failure option is true" do
@@ -291,8 +291,8 @@ describe "Model#save" do
291
291
  def o.before_save
292
292
  false
293
293
  end
294
- proc { o.save(:columns=>:y, :raise_on_failure => true) }.should raise_error(Sequel::HookFailed)
295
- DB.sqls.should == ["BEGIN", "ROLLBACK"]
294
+ proc { o.save(:columns=>:y, :raise_on_failure => true) }.must_raise(Sequel::HookFailed)
295
+ DB.sqls.must_equal ["BEGIN", "ROLLBACK"]
296
296
  end
297
297
 
298
298
  it "should not rollback outer transactions if before_save returns false and raise_on_save_failure = false" do
@@ -303,10 +303,10 @@ describe "Model#save" do
303
303
  false
304
304
  end
305
305
  DB.transaction do
306
- o.save(:columns=>:y).should == nil
306
+ o.save(:columns=>:y).must_equal nil
307
307
  DB.run "BLAH"
308
308
  end
309
- DB.sqls.should == ["BEGIN", "BLAH", "COMMIT"]
309
+ DB.sqls.must_equal ["BEGIN", "BLAH", "COMMIT"]
310
310
  end
311
311
 
312
312
  it "should rollback if before_save returns false and raise_on_save_failure = false" do
@@ -316,8 +316,8 @@ describe "Model#save" do
316
316
  def o.before_save
317
317
  false
318
318
  end
319
- o.save(:columns=>:y).should == nil
320
- DB.sqls.should == ["BEGIN", "ROLLBACK"]
319
+ o.save(:columns=>:y).must_equal nil
320
+ DB.sqls.must_equal ["BEGIN", "ROLLBACK"]
321
321
  end
322
322
 
323
323
  it "should not rollback if before_save throws Rollback and use_transactions = false" do
@@ -326,8 +326,8 @@ describe "Model#save" do
326
326
  def o.before_save
327
327
  raise Sequel::Rollback
328
328
  end
329
- proc { o.save(:columns=>:y) }.should raise_error(Sequel::Rollback)
330
- DB.sqls.should == []
329
+ proc { o.save(:columns=>:y) }.must_raise(Sequel::Rollback)
330
+ DB.sqls.must_equal []
331
331
  end
332
332
 
333
333
  it "should support a :server option to set the server/shard to use" do
@@ -337,9 +337,9 @@ describe "Model#save" do
337
337
  db.sqls
338
338
  o = c.new(:x => 1)
339
339
  o.save(:server=>:s1)
340
- db.sqls.should == ["INSERT INTO items (x) VALUES (1) -- s1", "SELECT * FROM items WHERE (id = 13) LIMIT 1 -- s1"]
340
+ db.sqls.must_equal ["INSERT INTO items (x) VALUES (1) -- s1", "SELECT * FROM items WHERE (id = 13) LIMIT 1 -- s1"]
341
341
  o.save(:server=>:s1, :transaction=>true)
342
- db.sqls.should == ["BEGIN -- s1", "UPDATE items SET x = 1 WHERE (id = 13) -- s1", 'COMMIT -- s1']
342
+ db.sqls.must_equal ["BEGIN -- s1", "UPDATE items SET x = 1 WHERE (id = 13) -- s1", 'COMMIT -- s1']
343
343
  end
344
344
  end
345
345
 
@@ -354,46 +354,46 @@ describe "Model#set_server" do
354
354
 
355
355
  it "should set the server to use when inserting" do
356
356
  @c.new(:x => 1).set_server(:s1).save
357
- @db.sqls.should == ["INSERT INTO items (x) VALUES (1) -- s1", "SELECT * FROM items WHERE (id = 13) LIMIT 1 -- s1"]
357
+ @db.sqls.must_equal ["INSERT INTO items (x) VALUES (1) -- s1", "SELECT * FROM items WHERE (id = 13) LIMIT 1 -- s1"]
358
358
  end
359
359
 
360
360
  it "should set the server to use when updating" do
361
361
  @c.load(:id=>13, :x => 1).set_server(:s1).save
362
- @db.sqls.should == ["UPDATE items SET x = 1 WHERE (id = 13) -- s1"]
362
+ @db.sqls.must_equal ["UPDATE items SET x = 1 WHERE (id = 13) -- s1"]
363
363
  end
364
364
 
365
365
  it "should set the server to use for transactions when saving" do
366
366
  @c.load(:id=>13, :x => 1).set_server(:s1).save(:transaction=>true)
367
- @db.sqls.should == ["BEGIN -- s1", "UPDATE items SET x = 1 WHERE (id = 13) -- s1", 'COMMIT -- s1']
367
+ @db.sqls.must_equal ["BEGIN -- s1", "UPDATE items SET x = 1 WHERE (id = 13) -- s1", 'COMMIT -- s1']
368
368
  end
369
369
 
370
370
  it "should set the server to use when deleting" do
371
371
  @c.load(:id=>13).set_server(:s1).delete
372
- @db.sqls.should == ["DELETE FROM items WHERE (id = 13) -- s1"]
372
+ @db.sqls.must_equal ["DELETE FROM items WHERE (id = 13) -- s1"]
373
373
  end
374
374
 
375
375
  it "should set the server to use when deleting when using optimized delete" do
376
376
  @c.set_primary_key :id
377
377
  @c.load(:id=>13).set_server(:s1).delete
378
- @db.sqls.should == ["DELETE FROM items WHERE id = 13 -- s1"]
378
+ @db.sqls.must_equal ["DELETE FROM items WHERE id = 13 -- s1"]
379
379
  end
380
380
 
381
381
  it "should set the server to use for transactions when destroying" do
382
382
  o = @c.load(:id=>13).set_server(:s1)
383
383
  o.use_transactions = true
384
384
  o.destroy
385
- @db.sqls.should == ["BEGIN -- s1", "DELETE FROM items WHERE (id = 13) -- s1", 'COMMIT -- s1']
385
+ @db.sqls.must_equal ["BEGIN -- s1", "DELETE FROM items WHERE (id = 13) -- s1", 'COMMIT -- s1']
386
386
  end
387
387
 
388
388
  it "should set the server on this if this is already loaded" do
389
389
  o = @c.load(:id=>13, :x => 1)
390
390
  o.this
391
391
  o.set_server(:s1)
392
- o.this.opts[:server].should == :s1
392
+ o.this.opts[:server].must_equal :s1
393
393
  end
394
394
 
395
395
  it "should set the server on this if this is not already loaded" do
396
- @c.load(:id=>13, :x => 1).set_server(:s1).this.opts[:server].should == :s1
396
+ @c.load(:id=>13, :x => 1).set_server(:s1).this.opts[:server].must_equal :s1
397
397
  end
398
398
  end
399
399
 
@@ -413,20 +413,20 @@ describe "Model#freeze" do
413
413
  end
414
414
 
415
415
  it "should freeze the object" do
416
- @o.frozen?.should == true
416
+ @o.frozen?.must_equal true
417
417
  end
418
418
 
419
419
  it "should freeze the object if the model doesn't have a primary key" do
420
420
  Album.no_primary_key
421
421
  @o = Album.load(:id=>1).freeze
422
- @o.frozen?.should == true
422
+ @o.frozen?.must_equal true
423
423
  end
424
424
 
425
425
  it "should freeze the object's values, associations, changed_columns, errors, and this" do
426
- @o.values.frozen?.should == true
427
- @o.changed_columns.frozen?.should == true
428
- @o.errors.frozen?.should == true
429
- @o.this.frozen?.should == true
426
+ @o.values.frozen?.must_equal true
427
+ @o.changed_columns.frozen?.must_equal true
428
+ @o.errors.frozen?.must_equal true
429
+ @o.this.frozen?.must_equal true
430
430
  end
431
431
 
432
432
  it "should still have working class attr overriddable methods" do
@@ -434,33 +434,33 @@ describe "Model#freeze" do
434
434
  end
435
435
 
436
436
  it "should have working new? method" do
437
- @o.new?.should == false
438
- Album.new.freeze.new?.should == true
437
+ @o.new?.must_equal false
438
+ Album.new.freeze.new?.must_equal true
439
439
  end
440
440
 
441
441
  it "should have working valid? method" do
442
- @o.valid?.should == true
442
+ @o.valid?.must_equal true
443
443
  o = Album.new
444
444
  def o.validate() errors.add(:foo, '') end
445
445
  o.freeze
446
- o.valid?.should == false
446
+ o.valid?.must_equal false
447
447
  end
448
448
 
449
449
  it "should not call validate if errors is already frozen" do
450
- @o.valid?.should == true
450
+ @o.valid?.must_equal true
451
451
  o = Album.new
452
452
  o.errors.freeze
453
453
  def o.validate() errors.add(:foo, '') end
454
- proc{o.freeze}.should_not raise_error
455
- o.valid?.should == true
454
+ o.freeze
455
+ o.valid?.must_equal true
456
456
  end
457
457
 
458
458
  it "should raise an Error if trying to save/destroy/delete/refresh" do
459
- proc{@o.save}.should raise_error(Sequel::Error)
460
- proc{@o.destroy}.should raise_error(Sequel::Error)
461
- proc{@o.delete}.should raise_error(Sequel::Error)
462
- proc{@o.refresh}.should raise_error(Sequel::Error)
463
- @o.db.sqls.should == []
459
+ proc{@o.save}.must_raise(Sequel::Error)
460
+ proc{@o.destroy}.must_raise(Sequel::Error)
461
+ proc{@o.delete}.must_raise(Sequel::Error)
462
+ proc{@o.refresh}.must_raise(Sequel::Error)
463
+ @o.db.sqls.must_equal []
464
464
  end
465
465
  end
466
466
 
@@ -472,32 +472,32 @@ describe "Model#dup" do
472
472
  end
473
473
 
474
474
  it "should be equal to existing object" do
475
- @o.dup.should == @o
476
- @o.dup.values.should == @o.values
477
- @o.dup.changed_columns.should == @o.changed_columns
478
- @o.dup.errors.should == @o.errors
479
- @o.dup.this.should == @o.this
475
+ @o.dup.must_equal @o
476
+ @o.dup.values.must_equal @o.values
477
+ @o.dup.changed_columns.must_equal @o.changed_columns
478
+ @o.dup.errors.must_equal @o.errors
479
+ @o.dup.this.must_equal @o.this
480
480
  end
481
481
 
482
482
  it "should not use identical structures" do
483
- @o.dup.should_not equal(@o)
484
- @o.dup.values.should_not equal(@o.values)
485
- @o.dup.changed_columns.should_not equal(@o.changed_columns)
486
- @o.dup.errors.should_not equal(@o.errors)
487
- @o.dup.this.should_not equal(@o.this)
483
+ @o.dup.wont_be_same_as(@o)
484
+ @o.dup.values.wont_be_same_as(@o.values)
485
+ @o.dup.changed_columns.wont_be_same_as(@o.changed_columns)
486
+ @o.dup.errors.wont_be_same_as(@o.errors)
487
+ @o.dup.this.wont_be_same_as(@o.this)
488
488
  end
489
489
 
490
490
  it "should keep new status" do
491
- @o.dup.new?.should == false
492
- @Album.new.dup.new?.should == true
491
+ @o.dup.new?.must_equal false
492
+ @Album.new.dup.new?.must_equal true
493
493
  end
494
494
 
495
495
  it "should not copy frozen status" do
496
- @o.freeze.dup.should_not be_frozen
497
- @o.freeze.dup.values.should_not be_frozen
498
- @o.freeze.dup.changed_columns.should_not be_frozen
499
- @o.freeze.dup.errors.should_not be_frozen
500
- @o.freeze.dup.this.should_not be_frozen
496
+ @o.freeze.dup.wont_be :frozen?
497
+ @o.freeze.dup.values.wont_be :frozen?
498
+ @o.freeze.dup.changed_columns.wont_be :frozen?
499
+ @o.freeze.dup.errors.wont_be :frozen?
500
+ @o.freeze.dup.this.wont_be :frozen?
501
501
  end
502
502
  end
503
503
 
@@ -509,32 +509,32 @@ describe "Model#clone" do
509
509
  end
510
510
 
511
511
  it "should be equal to existing object" do
512
- @o.clone.should == @o
513
- @o.clone.values.should == @o.values
514
- @o.clone.changed_columns.should == @o.changed_columns
515
- @o.clone.errors.should == @o.errors
516
- @o.clone.this.should == @o.this
512
+ @o.clone.must_equal @o
513
+ @o.clone.values.must_equal @o.values
514
+ @o.clone.changed_columns.must_equal @o.changed_columns
515
+ @o.clone.errors.must_equal @o.errors
516
+ @o.clone.this.must_equal @o.this
517
517
  end
518
518
 
519
519
  it "should not use identical structures" do
520
- @o.clone.should_not equal(@o)
521
- @o.clone.values.should_not equal(@o.values)
522
- @o.clone.changed_columns.should_not equal(@o.changed_columns)
523
- @o.clone.errors.should_not equal(@o.errors)
524
- @o.clone.this.should_not equal(@o.this)
520
+ @o.clone.wont_be_same_as(@o)
521
+ @o.clone.values.wont_be_same_as(@o.values)
522
+ @o.clone.changed_columns.wont_be_same_as(@o.changed_columns)
523
+ @o.clone.errors.wont_be_same_as(@o.errors)
524
+ @o.clone.this.wont_be_same_as(@o.this)
525
525
  end
526
526
 
527
527
  it "should keep new status" do
528
- @o.clone.new?.should == false
529
- @Album.new.clone.new?.should == true
528
+ @o.clone.new?.must_equal false
529
+ @Album.new.clone.new?.must_equal true
530
530
  end
531
531
 
532
532
  it "should copy frozen status" do
533
- @o.freeze.clone.should be_frozen
534
- @o.freeze.clone.values.should be_frozen
535
- @o.freeze.clone.changed_columns.should be_frozen
536
- @o.freeze.clone.errors.should be_frozen
537
- @o.freeze.clone.this.should be_frozen
533
+ @o.freeze.clone.must_be :frozen?
534
+ @o.freeze.clone.values.must_be :frozen?
535
+ @o.freeze.clone.changed_columns.must_be :frozen?
536
+ @o.freeze.clone.errors.must_be :frozen?
537
+ @o.freeze.clone.this.must_be :frozen?
538
538
  end
539
539
  end
540
540
 
@@ -553,21 +553,21 @@ describe "Model#marshallable" do
553
553
  s = nil
554
554
  i2 = nil
555
555
  i.marshallable!
556
- proc{s = Marshal.dump(i)}.should_not raise_error
557
- proc{i2 = Marshal.load(s)}.should_not raise_error
558
- i2.should == i
556
+ s = Marshal.dump(i)
557
+ i2 = Marshal.load(s)
558
+ i2.must_equal i
559
559
 
560
560
  i.save
561
561
  i.marshallable!
562
- proc{s = Marshal.dump(i)}.should_not raise_error
563
- proc{i2 = Marshal.load(s)}.should_not raise_error
564
- i2.should == i
562
+ s = Marshal.dump(i)
563
+ i2 = Marshal.load(s)
564
+ i2.must_equal i
565
565
 
566
566
  i.save
567
567
  i.marshallable!
568
- proc{s = Marshal.dump(i)}.should_not raise_error
569
- proc{i2 = Marshal.load(s)}.should_not raise_error
570
- i2.should == i
568
+ s = Marshal.dump(i)
569
+ i2 = Marshal.load(s)
570
+ i2.must_equal i
571
571
  end
572
572
  end
573
573
 
@@ -582,51 +582,51 @@ describe "Model#modified?" do
582
582
  end
583
583
 
584
584
  it "should be true if the object is new" do
585
- @c.new.modified?.should == true
585
+ @c.new.modified?.must_equal true
586
586
  end
587
587
 
588
588
  it "should be false if the object has not been modified" do
589
- @c.load(:id=>1).modified?.should == false
589
+ @c.load(:id=>1).modified?.must_equal false
590
590
  end
591
591
 
592
592
  it "should be true if the object has been modified" do
593
593
  o = @c.load(:id=>1, :x=>2)
594
594
  o.x = 3
595
- o.modified?.should == true
595
+ o.modified?.must_equal true
596
596
  end
597
597
 
598
598
  it "should be true if the object is marked modified!" do
599
599
  o = @c.load(:id=>1, :x=>2)
600
600
  o.modified!
601
- o.modified?.should == true
601
+ o.modified?.must_equal true
602
602
  end
603
603
 
604
604
  it "should be false if the object is marked modified! after saving until modified! again" do
605
605
  o = @c.load(:id=>1, :x=>2)
606
606
  o.modified!
607
607
  o.save
608
- o.modified?.should == false
608
+ o.modified?.must_equal false
609
609
  o.modified!
610
- o.modified?.should == true
610
+ o.modified?.must_equal true
611
611
  end
612
612
 
613
613
  it "should be false if a column value is set that is the same as the current value after typecasting" do
614
614
  o = @c.load(:id=>1, :x=>2)
615
615
  o.x = '2'
616
- o.modified?.should == false
616
+ o.modified?.must_equal false
617
617
  end
618
618
 
619
619
  it "should be true if a column value is set that is the different as the current value after typecasting" do
620
620
  o = @c.load(:id=>1, :x=>'2')
621
621
  o.x = '2'
622
- o.modified?.should == true
622
+ o.modified?.must_equal true
623
623
  end
624
624
 
625
625
  it "should be true if given a column argument and the column has been changed" do
626
626
  o = @c.new
627
- o.modified?(:id).should == false
627
+ o.modified?(:id).must_equal false
628
628
  o.id = 1
629
- o.modified?(:id).should == true
629
+ o.modified?(:id).must_equal true
630
630
  end
631
631
  end
632
632
 
@@ -645,20 +645,20 @@ describe "Model#modified!" do
645
645
  values[:x] = 3
646
646
  end
647
647
  o.update({})
648
- o.x.should == 2
648
+ o.x.must_equal 2
649
649
 
650
650
  o.modified!
651
651
  o.update({})
652
- o.x.should == 3
653
- o.db.sqls.should == []
652
+ o.x.must_equal 3
653
+ o.db.sqls.must_equal []
654
654
  end
655
655
 
656
656
  it "should mark given column argument as modified" do
657
657
  o = @c.load(:id=>1, :x=>2)
658
658
  o.modified!(:x)
659
- o.changed_columns.should == [:x]
659
+ o.changed_columns.must_equal [:x]
660
660
  o.save
661
- o.db.sqls.should == ["UPDATE items SET x = 2 WHERE (id = 1)"]
661
+ o.db.sqls.must_equal ["UPDATE items SET x = 2 WHERE (id = 1)"]
662
662
  end
663
663
  end
664
664
 
@@ -674,29 +674,29 @@ describe "Model#save_changes" do
674
674
  it "should always save if the object is new" do
675
675
  o = @c.new(:x => 1)
676
676
  o.save_changes
677
- DB.sqls.first.should == "INSERT INTO items (x) VALUES (1)"
677
+ DB.sqls.first.must_equal "INSERT INTO items (x) VALUES (1)"
678
678
  end
679
679
 
680
680
  it "should take options passed to save" do
681
681
  o = @c.new(:x => 1)
682
682
  def o.before_validation; false; end
683
- proc{o.save_changes}.should raise_error(Sequel::Error)
684
- DB.sqls.should == []
683
+ proc{o.save_changes}.must_raise(Sequel::HookFailed)
684
+ DB.sqls.must_equal []
685
685
  o.save_changes(:validate=>false)
686
- DB.sqls.first.should == "INSERT INTO items (x) VALUES (1)"
686
+ DB.sqls.first.must_equal "INSERT INTO items (x) VALUES (1)"
687
687
  end
688
688
 
689
689
  it "should do nothing if no changed columns" do
690
690
  o = @c.load(:id => 3, :x => 1, :y => nil)
691
691
  o.save_changes
692
- DB.sqls.should == []
692
+ DB.sqls.must_equal []
693
693
  end
694
694
 
695
695
  it "should do nothing if modified? is false" do
696
696
  o = @c.load(:id => 3, :x => 1, :y => nil)
697
697
  def o.modified?; false; end
698
698
  o.save_changes
699
- DB.sqls.should == []
699
+ DB.sqls.must_equal []
700
700
  end
701
701
 
702
702
  it "should update only changed columns" do
@@ -704,17 +704,17 @@ describe "Model#save_changes" do
704
704
  o.x = 2
705
705
 
706
706
  o.save_changes
707
- DB.sqls.should == ["UPDATE items SET x = 2 WHERE (id = 3)"]
707
+ DB.sqls.must_equal ["UPDATE items SET x = 2 WHERE (id = 3)"]
708
708
  o.save_changes
709
709
  o.save_changes
710
- DB.sqls.should == []
710
+ DB.sqls.must_equal []
711
711
 
712
712
  o.y = 4
713
713
  o.save_changes
714
- DB.sqls.should == ["UPDATE items SET y = 4 WHERE (id = 3)"]
714
+ DB.sqls.must_equal ["UPDATE items SET y = 4 WHERE (id = 3)"]
715
715
  o.save_changes
716
716
  o.save_changes
717
- DB.sqls.should == []
717
+ DB.sqls.must_equal []
718
718
  end
719
719
 
720
720
  it "should not consider columns changed if the values did not change" do
@@ -722,55 +722,55 @@ describe "Model#save_changes" do
722
722
  o.x = 1
723
723
 
724
724
  o.save_changes
725
- DB.sqls.should == []
725
+ DB.sqls.must_equal []
726
726
  o.x = 3
727
727
  o.save_changes
728
- DB.sqls.should == ["UPDATE items SET x = 3 WHERE (id = 3)"]
728
+ DB.sqls.must_equal ["UPDATE items SET x = 3 WHERE (id = 3)"]
729
729
 
730
730
  o[:y] = nil
731
731
  o.save_changes
732
- DB.sqls.should == []
732
+ DB.sqls.must_equal []
733
733
  o[:y] = 4
734
734
  o.save_changes
735
- DB.sqls.should == ["UPDATE items SET y = 4 WHERE (id = 3)"]
735
+ DB.sqls.must_equal ["UPDATE items SET y = 4 WHERE (id = 3)"]
736
736
  end
737
737
 
738
738
  it "should clear changed_columns" do
739
739
  o = @c.load(:id => 3, :x => 1, :y => nil)
740
740
  o.x = 4
741
- o.changed_columns.should == [:x]
741
+ o.changed_columns.must_equal [:x]
742
742
  o.save_changes
743
- o.changed_columns.should == []
743
+ o.changed_columns.must_equal []
744
744
  end
745
745
 
746
746
  it "should update columns changed in a before_update hook" do
747
747
  o = @c.load(:id => 3, :x => 1, :y => nil)
748
748
  @c.send(:define_method, :before_update){self.x += 1}
749
749
  o.save_changes
750
- DB.sqls.should == []
750
+ DB.sqls.must_equal []
751
751
  o.x = 2
752
752
  o.save_changes
753
- DB.sqls.should == ["UPDATE items SET x = 3 WHERE (id = 3)"]
753
+ DB.sqls.must_equal ["UPDATE items SET x = 3 WHERE (id = 3)"]
754
754
  o.save_changes
755
- DB.sqls.should == []
755
+ DB.sqls.must_equal []
756
756
  o.x = 4
757
757
  o.save_changes
758
- DB.sqls.should == ["UPDATE items SET x = 5 WHERE (id = 3)"]
758
+ DB.sqls.must_equal ["UPDATE items SET x = 5 WHERE (id = 3)"]
759
759
  end
760
760
 
761
761
  it "should update columns changed in a before_save hook" do
762
762
  o = @c.load(:id => 3, :x => 1, :y => nil)
763
763
  @c.send(:define_method, :before_update){self.x += 1}
764
764
  o.save_changes
765
- DB.sqls.should == []
765
+ DB.sqls.must_equal []
766
766
  o.x = 2
767
767
  o.save_changes
768
- DB.sqls.should == ["UPDATE items SET x = 3 WHERE (id = 3)"]
768
+ DB.sqls.must_equal ["UPDATE items SET x = 3 WHERE (id = 3)"]
769
769
  o.save_changes
770
- DB.sqls.should == []
770
+ DB.sqls.must_equal []
771
771
  o.x = 4
772
772
  o.save_changes
773
- DB.sqls.should == ["UPDATE items SET x = 5 WHERE (id = 3)"]
773
+ DB.sqls.must_equal ["UPDATE items SET x = 5 WHERE (id = 3)"]
774
774
  end
775
775
  end
776
776
 
@@ -785,41 +785,41 @@ describe "Model#new?" do
785
785
 
786
786
  it "should be true for a new instance" do
787
787
  n = @c.new(:x => 1)
788
- n.should be_new
788
+ n.must_be :new?
789
789
  end
790
790
 
791
791
  it "should be false after saving" do
792
792
  n = @c.new(:x => 1)
793
793
  n.save
794
- n.should_not be_new
794
+ n.wont_be :new?
795
795
  end
796
796
  end
797
797
 
798
798
  describe Sequel::Model, "with a primary key" do
799
799
  it "should default to :id" do
800
800
  model_a = Class.new Sequel::Model
801
- model_a.primary_key.should == :id
801
+ model_a.primary_key.must_equal :id
802
802
  end
803
803
 
804
804
  it "should be changed through 'set_primary_key'" do
805
805
  model_a = Class.new(Sequel::Model){ set_primary_key :a }
806
- model_a.primary_key.should == :a
806
+ model_a.primary_key.must_equal :a
807
807
  end
808
808
 
809
809
  it "should accept single argument composite keys" do
810
810
  model_a = Class.new(Sequel::Model){ set_primary_key [:a, :b] }
811
- model_a.primary_key.should == [:a, :b]
811
+ model_a.primary_key.must_equal [:a, :b]
812
812
  end
813
813
  end
814
814
 
815
815
  describe Sequel::Model, "without a primary key" do
816
816
  it "should return nil for primary key" do
817
- Class.new(Sequel::Model){no_primary_key}.primary_key.should be_nil
817
+ Class.new(Sequel::Model){no_primary_key}.primary_key.must_equal nil
818
818
  end
819
819
 
820
820
  it "should raise a Sequel::Error on 'this'" do
821
821
  instance = Class.new(Sequel::Model){no_primary_key}.new
822
- proc{instance.this}.should raise_error(Sequel::Error)
822
+ proc{instance.this}.must_raise(Sequel::Error)
823
823
  end
824
824
  end
825
825
 
@@ -831,26 +831,26 @@ describe Sequel::Model, "#this" do
831
831
 
832
832
  it "should return a dataset identifying the record" do
833
833
  instance = @example.load(:id => 3)
834
- instance.this.sql.should == "SELECT * FROM examples WHERE (id = 3) LIMIT 1"
834
+ instance.this.sql.must_equal "SELECT * FROM examples WHERE (id = 3) LIMIT 1"
835
835
  end
836
836
 
837
837
  it "should support arbitary primary keys" do
838
838
  @example.set_primary_key :a
839
839
 
840
840
  instance = @example.load(:a => 3)
841
- instance.this.sql.should == "SELECT * FROM examples WHERE (a = 3) LIMIT 1"
841
+ instance.this.sql.must_equal "SELECT * FROM examples WHERE (a = 3) LIMIT 1"
842
842
  end
843
843
 
844
844
  it "should use a qualified primary key if the dataset is joined" do
845
845
  @example.dataset = @example.dataset.cross_join(:a)
846
846
  instance = @example.load(:id => 3)
847
- instance.this.sql.should == "SELECT * FROM examples CROSS JOIN a WHERE (examples.id = 3) LIMIT 1"
847
+ instance.this.sql.must_equal "SELECT * FROM examples CROSS JOIN a WHERE (examples.id = 3) LIMIT 1"
848
848
  end
849
849
 
850
850
  it "should support composite primary keys" do
851
851
  @example.set_primary_key [:x, :y]
852
852
  instance = @example.load(:x => 4, :y => 5)
853
- instance.this.sql.should =~ /SELECT \* FROM examples WHERE \(\([xy] = [45]\) AND \([xy] = [45]\)\) LIMIT 1/
853
+ instance.this.sql.must_match(/SELECT \* FROM examples WHERE \(\([xy] = [45]\) AND \([xy] = [45]\)\) LIMIT 1/)
854
854
  end
855
855
  end
856
856
 
@@ -862,29 +862,29 @@ describe "Model#pk" do
862
862
 
863
863
  it "should by default return the value of the :id column" do
864
864
  m = @m.load(:id => 111, :x => 2, :y => 3)
865
- m.pk.should == 111
865
+ m.pk.must_equal 111
866
866
  end
867
867
 
868
868
  it "should return the primary key value for custom primary key" do
869
869
  @m.set_primary_key :x
870
870
  m = @m.load(:id => 111, :x => 2, :y => 3)
871
- m.pk.should == 2
871
+ m.pk.must_equal 2
872
872
  end
873
873
 
874
874
  it "should return the primary key value for composite primary key" do
875
875
  @m.set_primary_key [:y, :x]
876
876
  m = @m.load(:id => 111, :x => 2, :y => 3)
877
- m.pk.should == [3, 2]
877
+ m.pk.must_equal [3, 2]
878
878
  end
879
879
 
880
880
  it "should raise if no primary key" do
881
881
  @m.set_primary_key nil
882
882
  m = @m.new(:id => 111, :x => 2, :y => 3)
883
- proc {m.pk}.should raise_error(Sequel::Error)
883
+ proc {m.pk}.must_raise(Sequel::Error)
884
884
 
885
885
  @m.no_primary_key
886
886
  m = @m.new(:id => 111, :x => 2, :y => 3)
887
- proc {m.pk}.should raise_error(Sequel::Error)
887
+ proc {m.pk}.must_raise(Sequel::Error)
888
888
  end
889
889
  end
890
890
 
@@ -896,29 +896,29 @@ describe "Model#pk_hash" do
896
896
 
897
897
  it "should by default return a hash with the value of the :id column" do
898
898
  m = @m.load(:id => 111, :x => 2, :y => 3)
899
- m.pk_hash.should == {:id => 111}
899
+ m.pk_hash.must_equal(:id => 111)
900
900
  end
901
901
 
902
902
  it "should return a hash with the primary key value for custom primary key" do
903
903
  @m.set_primary_key :x
904
904
  m = @m.load(:id => 111, :x => 2, :y => 3)
905
- m.pk_hash.should == {:x => 2}
905
+ m.pk_hash.must_equal(:x => 2)
906
906
  end
907
907
 
908
908
  it "should return a hash with the primary key values for composite primary key" do
909
909
  @m.set_primary_key [:y, :x]
910
910
  m = @m.load(:id => 111, :x => 2, :y => 3)
911
- m.pk_hash.should == {:y => 3, :x => 2}
911
+ m.pk_hash.must_equal(:y => 3, :x => 2)
912
912
  end
913
913
 
914
914
  it "should raise if no primary key" do
915
915
  @m.set_primary_key nil
916
916
  m = @m.new(:id => 111, :x => 2, :y => 3)
917
- proc{m.pk_hash}.should raise_error(Sequel::Error)
917
+ proc{m.pk_hash}.must_raise(Sequel::Error)
918
918
 
919
919
  @m.no_primary_key
920
920
  m = @m.new(:id => 111, :x => 2, :y => 3)
921
- proc{m.pk_hash}.should raise_error(Sequel::Error)
921
+ proc{m.pk_hash}.must_raise(Sequel::Error)
922
922
  end
923
923
  end
924
924
 
@@ -930,34 +930,34 @@ describe "Model#qualified_pk_hash" do
930
930
 
931
931
  it "should by default return a hash with the value of the :id column" do
932
932
  m = @m.load(:id => 111, :x => 2, :y => 3)
933
- m.qualified_pk_hash.should == {Sequel.qualify(:items, :id) => 111}
933
+ m.qualified_pk_hash.must_equal(Sequel.qualify(:items, :id) => 111)
934
934
  end
935
935
 
936
936
  it "should accept a custom qualifier" do
937
937
  m = @m.load(:id => 111, :x => 2, :y => 3)
938
- m.qualified_pk_hash(:foo).should == {Sequel.qualify(:foo, :id) => 111}
938
+ m.qualified_pk_hash(:foo).must_equal(Sequel.qualify(:foo, :id) => 111)
939
939
  end
940
940
 
941
941
  it "should return a hash with the primary key value for custom primary key" do
942
942
  @m.set_primary_key :x
943
943
  m = @m.load(:id => 111, :x => 2, :y => 3)
944
- m.qualified_pk_hash.should == {Sequel.qualify(:items, :x) => 2}
944
+ m.qualified_pk_hash.must_equal(Sequel.qualify(:items, :x) => 2)
945
945
  end
946
946
 
947
947
  it "should return a hash with the primary key values for composite primary key" do
948
948
  @m.set_primary_key [:y, :x]
949
949
  m = @m.load(:id => 111, :x => 2, :y => 3)
950
- m.qualified_pk_hash.should == {Sequel.qualify(:items, :y) => 3, Sequel.qualify(:items, :x) => 2}
950
+ m.qualified_pk_hash.must_equal(Sequel.qualify(:items, :y) => 3, Sequel.qualify(:items, :x) => 2)
951
951
  end
952
952
 
953
953
  it "should raise if no primary key" do
954
954
  @m.set_primary_key nil
955
955
  m = @m.new(:id => 111, :x => 2, :y => 3)
956
- proc{m.qualified_pk_hash}.should raise_error(Sequel::Error)
956
+ proc{m.qualified_pk_hash}.must_raise(Sequel::Error)
957
957
 
958
958
  @m.no_primary_key
959
959
  m = @m.new(:id => 111, :x => 2, :y => 3)
960
- proc{m.qualified_pk_hash}.should raise_error(Sequel::Error)
960
+ proc{m.qualified_pk_hash}.must_raise(Sequel::Error)
961
961
  end
962
962
  end
963
963
 
@@ -975,75 +975,74 @@ describe Sequel::Model, "#set" do
975
975
 
976
976
  it "should filter the given params using the model columns" do
977
977
  @o1.set(:x => 1, :z => 2)
978
- @o1.values.should == {:x => 1}
979
- DB.sqls.should == []
978
+ @o1.values.must_equal(:x => 1)
979
+ DB.sqls.must_equal []
980
980
 
981
981
  @o2.set(:y => 1, :abc => 2)
982
- @o2.values.should == {:y => 1, :id=> 5}
983
- DB.sqls.should == []
982
+ @o2.values.must_equal(:y => 1, :id=> 5)
983
+ DB.sqls.must_equal []
984
984
  end
985
985
 
986
986
  it "should work with both strings and symbols" do
987
987
  @o1.set('x'=> 1, 'z'=> 2)
988
- @o1.values.should == {:x => 1}
989
- DB.sqls.should == []
988
+ @o1.values.must_equal(:x => 1)
989
+ DB.sqls.must_equal []
990
990
 
991
991
  @o2.set('y'=> 1, 'abc'=> 2)
992
- @o2.values.should == {:y => 1, :id=> 5}
993
- DB.sqls.should == []
992
+ @o2.values.must_equal(:y => 1, :id=> 5)
993
+ DB.sqls.must_equal []
994
994
  end
995
995
 
996
996
  it "should support virtual attributes" do
997
997
  @c.send(:define_method, :blah=){|v| self.x = v}
998
998
  @o1.set(:blah => 333)
999
- @o1.values.should == {:x => 333}
1000
- DB.sqls.should == []
999
+ @o1.values.must_equal(:x => 333)
1000
+ DB.sqls.must_equal []
1001
1001
  @o1.set('blah'=> 334)
1002
- @o1.values.should == {:x => 334}
1003
- DB.sqls.should == []
1002
+ @o1.values.must_equal(:x => 334)
1003
+ DB.sqls.must_equal []
1004
1004
  end
1005
1005
 
1006
1006
  it "should not modify the primary key" do
1007
1007
  @o1.set(:x => 1, :id => 2)
1008
- @o1.values.should == {:x => 1}
1009
- DB.sqls.should == []
1008
+ @o1.values.must_equal(:x => 1)
1009
+ DB.sqls.must_equal []
1010
1010
  @o2.set('y'=> 1, 'id'=> 2)
1011
- @o2.values.should == {:y => 1, :id=> 5}
1012
- DB.sqls.should == []
1011
+ @o2.values.must_equal(:y => 1, :id=> 5)
1012
+ DB.sqls.must_equal []
1013
1013
  end
1014
1014
 
1015
1015
  it "should return self" do
1016
1016
  returned_value = @o1.set(:x => 1, :z => 2)
1017
- returned_value.should == @o1
1018
- DB.sqls.should == []
1017
+ returned_value.must_equal @o1
1018
+ DB.sqls.must_equal []
1019
1019
  end
1020
1020
 
1021
1021
  it "should raise error if strict_param_setting is true and method does not exist" do
1022
1022
  @o1.strict_param_setting = true
1023
- proc{@o1.set('foo' => 1)}.should raise_error(Sequel::MassAssignmentRestriction)
1023
+ proc{@o1.set('foo' => 1)}.must_raise(Sequel::MassAssignmentRestriction)
1024
1024
  end
1025
1025
 
1026
1026
  it "should raise error if strict_param_setting is true and column is a primary key" do
1027
1027
  @o1.strict_param_setting = true
1028
- proc{@o1.set('id' => 1)}.should raise_error(Sequel::MassAssignmentRestriction)
1028
+ proc{@o1.set('id' => 1)}.must_raise(Sequel::MassAssignmentRestriction)
1029
1029
  end
1030
1030
 
1031
1031
  it "should raise error if strict_param_setting is true and column is restricted" do
1032
1032
  @o1.strict_param_setting = true
1033
1033
  @c.set_allowed_columns
1034
- proc{@o1.set('x' => 1)}.should raise_error(Sequel::MassAssignmentRestriction)
1034
+ proc{@o1.set('x' => 1)}.must_raise(Sequel::MassAssignmentRestriction)
1035
1035
  end
1036
1036
 
1037
1037
  it "should not create a symbol if strict_param_setting is true and string is given" do
1038
1038
  @o1.strict_param_setting = true
1039
- l = Symbol.all_symbols.length
1040
- proc{@o1.set('sadojafdso' => 1)}.should raise_error(Sequel::MassAssignmentRestriction)
1041
- Symbol.all_symbols.length.should == l
1039
+ proc{@o1.set('sadojafdso' => 1)}.must_raise(Sequel::MassAssignmentRestriction)
1040
+ Symbol.all_symbols.map(&:to_s).wont_include('sadojafdso')
1042
1041
  end
1043
1042
 
1044
1043
  it "#set should correctly handle cases where an instance method is added to the class" do
1045
1044
  @o1.set(:x => 1)
1046
- @o1.values.should == {:x => 1}
1045
+ @o1.values.must_equal(:x => 1)
1047
1046
 
1048
1047
  @c.class_eval do
1049
1048
  def z=(v)
@@ -1051,23 +1050,23 @@ describe Sequel::Model, "#set" do
1051
1050
  end
1052
1051
  end
1053
1052
  @o1.set(:x => 2, :z => 3)
1054
- @o1.values.should == {:x => 2, :z=>3}
1053
+ @o1.values.must_equal(:x => 2, :z=>3)
1055
1054
  end
1056
1055
 
1057
1056
  it "#set should correctly handle cases where a singleton method is added to the object" do
1058
1057
  @o1.set(:x => 1)
1059
- @o1.values.should == {:x => 1}
1058
+ @o1.values.must_equal(:x => 1)
1060
1059
 
1061
1060
  def @o1.z=(v)
1062
1061
  self[:z] = v
1063
1062
  end
1064
1063
  @o1.set(:x => 2, :z => 3)
1065
- @o1.values.should == {:x => 2, :z=>3}
1064
+ @o1.values.must_equal(:x => 2, :z=>3)
1066
1065
  end
1067
1066
 
1068
1067
  it "#set should correctly handle cases where a module with a setter method is included in the class" do
1069
1068
  @o1.set(:x => 1)
1070
- @o1.values.should == {:x => 1}
1069
+ @o1.values.must_equal(:x => 1)
1071
1070
 
1072
1071
  @c.send(:include, Module.new do
1073
1072
  def z=(v)
@@ -1075,12 +1074,12 @@ describe Sequel::Model, "#set" do
1075
1074
  end
1076
1075
  end)
1077
1076
  @o1.set(:x => 2, :z => 3)
1078
- @o1.values.should == {:x => 2, :z=>3}
1077
+ @o1.values.must_equal(:x => 2, :z=>3)
1079
1078
  end
1080
1079
 
1081
1080
  it "#set should correctly handle cases where the object extends a module with a setter method " do
1082
1081
  @o1.set(:x => 1)
1083
- @o1.values.should == {:x => 1}
1082
+ @o1.values.must_equal(:x => 1)
1084
1083
 
1085
1084
  @o1.extend(Module.new do
1086
1085
  def z=(v)
@@ -1088,7 +1087,7 @@ describe Sequel::Model, "#set" do
1088
1087
  end
1089
1088
  end)
1090
1089
  @o1.set(:x => 2, :z => 3)
1091
- @o1.values.should == {:x => 2, :z=>3}
1090
+ @o1.values.must_equal(:x => 2, :z=>3)
1092
1091
  end
1093
1092
  end
1094
1093
 
@@ -1106,26 +1105,26 @@ describe Sequel::Model, "#update" do
1106
1105
 
1107
1106
  it "should filter the given params using the model columns" do
1108
1107
  @o1.update(:x => 1, :z => 2)
1109
- DB.sqls.should == ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1108
+ DB.sqls.must_equal ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1110
1109
 
1111
1110
  DB.reset
1112
1111
  @o2.update(:y => 1, :abc => 2)
1113
- DB.sqls.should == ["UPDATE items SET y = 1 WHERE (id = 5)"]
1112
+ DB.sqls.must_equal ["UPDATE items SET y = 1 WHERE (id = 5)"]
1114
1113
  end
1115
1114
 
1116
1115
  it "should support virtual attributes" do
1117
1116
  @c.send(:define_method, :blah=){|v| self.x = v}
1118
1117
  @o1.update(:blah => 333)
1119
- DB.sqls.should == ["INSERT INTO items (x) VALUES (333)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1118
+ DB.sqls.must_equal ["INSERT INTO items (x) VALUES (333)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1120
1119
  end
1121
1120
 
1122
1121
  it "should not modify the primary key" do
1123
1122
  @o1.update(:x => 1, :id => 2)
1124
- DB.sqls.should == ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1123
+ DB.sqls.must_equal ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1125
1124
  DB.reset
1126
1125
  @o2.update('y'=> 1, 'id'=> 2)
1127
- @o2.values.should == {:y => 1, :id=> 5}
1128
- DB.sqls.should == ["UPDATE items SET y = 1 WHERE (id = 5)"]
1126
+ @o2.values.must_equal(:y => 1, :id=> 5)
1127
+ DB.sqls.must_equal ["UPDATE items SET y = 1 WHERE (id = 5)"]
1129
1128
  end
1130
1129
  end
1131
1130
 
@@ -1141,70 +1140,70 @@ describe Sequel::Model, "#set_fields" do
1141
1140
 
1142
1141
  it "should set only the given fields" do
1143
1142
  @o1.set_fields({:x => 1, :y => 2, :z=>3, :id=>4}, [:x, :y])
1144
- @o1.values.should == {:x => 1, :y => 2}
1143
+ @o1.values.must_equal(:x => 1, :y => 2)
1145
1144
  @o1.set_fields({:x => 9, :y => 8, :z=>6, :id=>7}, [:x, :y, :id])
1146
- @o1.values.should == {:x => 9, :y => 8, :id=>7}
1147
- DB.sqls.should == []
1145
+ @o1.values.must_equal(:x => 9, :y => 8, :id=>7)
1146
+ DB.sqls.must_equal []
1148
1147
  end
1149
1148
 
1150
1149
  it "should lookup into the hash without checking if the entry exists" do
1151
1150
  @o1.set_fields({:x => 1}, [:x, :y])
1152
- @o1.values.should == {:x => 1, :y => nil}
1151
+ @o1.values.must_equal(:x => 1, :y => nil)
1153
1152
  @o1.set_fields(Hash.new(2), [:x, :y])
1154
- @o1.values.should == {:x => 2, :y => 2}
1153
+ @o1.values.must_equal(:x => 2, :y => 2)
1155
1154
  end
1156
1155
 
1157
1156
  it "should skip missing fields if :missing=>:skip option is used" do
1158
1157
  @o1.set_fields({:x => 3}, [:x, :y], :missing=>:skip)
1159
- @o1.values.should == {:x => 3}
1158
+ @o1.values.must_equal(:x => 3)
1160
1159
  @o1.set_fields({"x" => 4}, [:x, :y], :missing=>:skip)
1161
- @o1.values.should == {:x => 4}
1160
+ @o1.values.must_equal(:x => 4)
1162
1161
  @o1.set_fields(Hash.new(2).merge(:x=>2), [:x, :y], :missing=>:skip)
1163
- @o1.values.should == {:x => 2}
1162
+ @o1.values.must_equal(:x => 2)
1164
1163
  @o1.set_fields({:x => 1, :y => 2, :z=>3, :id=>4}, [:x, :y], :missing=>:skip)
1165
- @o1.values.should == {:x => 1, :y => 2}
1164
+ @o1.values.must_equal(:x => 1, :y => 2)
1166
1165
  end
1167
1166
 
1168
1167
  it "should raise for missing fields if :missing=>:raise option is used" do
1169
- proc{@o1.set_fields({:x => 1}, [:x, :y], :missing=>:raise)}.should raise_error(Sequel::Error)
1170
- proc{@o1.set_fields(Hash.new(2).merge(:x=>2), [:x, :y], :missing=>:raise)}.should raise_error(Sequel::Error)
1171
- proc{@o1.set_fields({"x" => 1}, [:x, :y], :missing=>:raise)}.should raise_error(Sequel::Error)
1168
+ proc{@o1.set_fields({:x => 1}, [:x, :y], :missing=>:raise)}.must_raise(Sequel::Error)
1169
+ proc{@o1.set_fields(Hash.new(2).merge(:x=>2), [:x, :y], :missing=>:raise)}.must_raise(Sequel::Error)
1170
+ proc{@o1.set_fields({"x" => 1}, [:x, :y], :missing=>:raise)}.must_raise(Sequel::Error)
1172
1171
  @o1.set_fields({:x => 5, "y"=>2}, [:x, :y], :missing=>:raise)
1173
- @o1.values.should == {:x => 5, :y => 2}
1172
+ @o1.values.must_equal(:x => 5, :y => 2)
1174
1173
  @o1.set_fields({:x => 1, :y => 3, :z=>3, :id=>4}, [:x, :y], :missing=>:raise)
1175
- @o1.values.should == {:x => 1, :y => 3}
1174
+ @o1.values.must_equal(:x => 1, :y => 3)
1176
1175
  end
1177
1176
 
1178
1177
  it "should use default behavior for an unrecognized :missing option" do
1179
1178
  @o1.set_fields({:x => 1, :y => 2, :z=>3, :id=>4}, [:x, :y], :missing=>:foo)
1180
- @o1.values.should == {:x => 1, :y => 2}
1179
+ @o1.values.must_equal(:x => 1, :y => 2)
1181
1180
  @o1.set_fields({:x => 9, :y => 8, :z=>6, :id=>7}, [:x, :y, :id], :missing=>:foo)
1182
- @o1.values.should == {:x => 9, :y => 8, :id=>7}
1183
- DB.sqls.should == []
1181
+ @o1.values.must_equal(:x => 9, :y => 8, :id=>7)
1182
+ DB.sqls.must_equal []
1184
1183
  end
1185
1184
 
1186
1185
  it "should respect model's default_set_fields_options" do
1187
1186
  @c.default_set_fields_options = {:missing=>:skip}
1188
1187
  @o1.set_fields({:x => 3}, [:x, :y])
1189
- @o1.values.should == {:x => 3}
1188
+ @o1.values.must_equal(:x => 3)
1190
1189
  @o1.set_fields({:x => 4}, [:x, :y], {})
1191
- @o1.values.should == {:x => 4}
1192
- proc{@o1.set_fields({:x => 3}, [:x, :y], :missing=>:raise)}.should raise_error(Sequel::Error)
1190
+ @o1.values.must_equal(:x => 4)
1191
+ proc{@o1.set_fields({:x => 3}, [:x, :y], :missing=>:raise)}.must_raise(Sequel::Error)
1193
1192
  @c.default_set_fields_options = {:missing=>:raise}
1194
- proc{@o1.set_fields({:x => 3}, [:x, :y])}.should raise_error(Sequel::Error)
1195
- proc{@o1.set_fields({:x => 3}, [:x, :y], {})}.should raise_error(Sequel::Error)
1193
+ proc{@o1.set_fields({:x => 3}, [:x, :y])}.must_raise(Sequel::Error)
1194
+ proc{@o1.set_fields({:x => 3}, [:x, :y], {})}.must_raise(Sequel::Error)
1196
1195
  @o1.set_fields({:x => 5}, [:x, :y], :missing=>:skip)
1197
- @o1.values.should == {:x => 5}
1196
+ @o1.values.must_equal(:x => 5)
1198
1197
  @o1.set_fields({:x => 5}, [:x, :y], :missing=>nil)
1199
- @o1.values.should == {:x => 5, :y=>nil}
1200
- DB.sqls.should == []
1198
+ @o1.values.must_equal(:x => 5, :y=>nil)
1199
+ DB.sqls.must_equal []
1201
1200
  end
1202
1201
 
1203
1202
  it "should respect model's default_set_fields_options in a subclass" do
1204
1203
  @c.default_set_fields_options = {:missing=>:skip}
1205
1204
  o = Class.new(@c).new
1206
1205
  o.set_fields({:x => 3}, [:x, :y])
1207
- o.values.should == {:x => 3}
1206
+ o.values.must_equal(:x => 3)
1208
1207
  end
1209
1208
 
1210
1209
  it "should respect set_column_value" do
@@ -1218,8 +1217,8 @@ describe Sequel::Model, "#set_fields" do
1218
1217
  end
1219
1218
  end
1220
1219
  @o1.set_fields({:model=>2, :x=>3}, [:model, :x])
1221
- @o1[:model].should == 2
1222
- @o1.x.should == 3
1220
+ @o1[:model].must_equal 2
1221
+ @o1.x.must_equal 3
1223
1222
  end
1224
1223
  end
1225
1224
 
@@ -1236,35 +1235,35 @@ describe Sequel::Model, "#update_fields" do
1236
1235
 
1237
1236
  it "should set only the given fields, and then save the changes to the record" do
1238
1237
  @o1.update_fields({:x => 1, :y => 2, :z=>3, :id=>4}, [:x, :y])
1239
- @o1.values.should == {:x => 1, :y => 2, :id=>1}
1238
+ @o1.values.must_equal(:x => 1, :y => 2, :id=>1)
1240
1239
  sqls = DB.sqls
1241
- sqls.pop.should =~ /UPDATE items SET [xy] = [12], [xy] = [12] WHERE \(id = 1\)/
1242
- sqls.should == []
1240
+ sqls.pop.must_match(/UPDATE items SET [xy] = [12], [xy] = [12] WHERE \(id = 1\)/)
1241
+ sqls.must_equal []
1243
1242
 
1244
1243
  @o1.update_fields({:x => 1, :y => 5, :z=>6, :id=>7}, [:x, :y])
1245
- @o1.values.should == {:x => 1, :y => 5, :id=>1}
1246
- DB.sqls.should == ["UPDATE items SET y = 5 WHERE (id = 1)"]
1244
+ @o1.values.must_equal(:x => 1, :y => 5, :id=>1)
1245
+ DB.sqls.must_equal ["UPDATE items SET y = 5 WHERE (id = 1)"]
1247
1246
  end
1248
1247
 
1249
1248
  it "should support :missing=>:skip option" do
1250
1249
  @o1.update_fields({:x => 1, :z=>3, :id=>4}, [:x, :y], :missing=>:skip)
1251
- @o1.values.should == {:x => 1, :id=>1}
1252
- DB.sqls.should == ["UPDATE items SET x = 1 WHERE (id = 1)"]
1250
+ @o1.values.must_equal(:x => 1, :id=>1)
1251
+ DB.sqls.must_equal ["UPDATE items SET x = 1 WHERE (id = 1)"]
1253
1252
  end
1254
1253
 
1255
1254
  it "should support :missing=>:raise option" do
1256
- proc{@o1.update_fields({:x => 1}, [:x, :y], :missing=>:raise)}.should raise_error(Sequel::Error)
1255
+ proc{@o1.update_fields({:x => 1}, [:x, :y], :missing=>:raise)}.must_raise(Sequel::Error)
1257
1256
  end
1258
1257
 
1259
1258
  it "should respect model's default_set_fields_options" do
1260
1259
  @c.default_set_fields_options = {:missing=>:skip}
1261
1260
  @o1.update_fields({:x => 3}, [:x, :y])
1262
- @o1.values.should == {:x => 3, :id=>1}
1263
- DB.sqls.should == ["UPDATE items SET x = 3 WHERE (id = 1)"]
1261
+ @o1.values.must_equal(:x => 3, :id=>1)
1262
+ DB.sqls.must_equal ["UPDATE items SET x = 3 WHERE (id = 1)"]
1264
1263
 
1265
1264
  @c.default_set_fields_options = {:missing=>:raise}
1266
- proc{@o1.update_fields({:x => 3}, [:x, :y])}.should raise_error(Sequel::Error)
1267
- DB.sqls.should == []
1265
+ proc{@o1.update_fields({:x => 3}, [:x, :y])}.must_raise(Sequel::Error)
1266
+ DB.sqls.must_equal []
1268
1267
  end
1269
1268
  end
1270
1269
 
@@ -1283,50 +1282,50 @@ describe Sequel::Model, "#(set|update)_(all|only)" do
1283
1282
  it "should raise errors if not all hash fields can be set and strict_param_setting is true" do
1284
1283
  @c.strict_param_setting = true
1285
1284
 
1286
- proc{@c.new.set_all(:x => 1, :y => 2, :z=>3, :use_after_commit_rollback => false)}.should raise_error(Sequel::MassAssignmentRestriction)
1285
+ proc{@c.new.set_all(:x => 1, :y => 2, :z=>3, :use_after_commit_rollback => false)}.must_raise(Sequel::MassAssignmentRestriction)
1287
1286
  (o = @c.new).set_all(:x => 1, :y => 2, :z=>3)
1288
- o.values.should == {:x => 1, :y => 2, :z=>3}
1287
+ o.values.must_equal(:x => 1, :y => 2, :z=>3)
1289
1288
 
1290
- proc{@c.new.set_only({:x => 1, :y => 2, :z=>3, :id=>4}, :x, :y)}.should raise_error(Sequel::MassAssignmentRestriction)
1291
- proc{@c.new.set_only({:x => 1, :y => 2, :z=>3}, :x, :y)}.should raise_error(Sequel::MassAssignmentRestriction)
1289
+ proc{@c.new.set_only({:x => 1, :y => 2, :z=>3, :id=>4}, :x, :y)}.must_raise(Sequel::MassAssignmentRestriction)
1290
+ proc{@c.new.set_only({:x => 1, :y => 2, :z=>3}, :x, :y)}.must_raise(Sequel::MassAssignmentRestriction)
1292
1291
  (o = @c.new).set_only({:x => 1, :y => 2}, :x, :y)
1293
- o.values.should == {:x => 1, :y => 2}
1292
+ o.values.must_equal(:x => 1, :y => 2)
1294
1293
  end
1295
1294
 
1296
1295
  it "#set_all should set all attributes including the primary key" do
1297
1296
  @o1.set_all(:x => 1, :y => 2, :z=>3, :id=>4)
1298
- @o1.values.should == {:id =>4, :x => 1, :y => 2, :z=>3}
1297
+ @o1.values.must_equal(:id =>4, :x => 1, :y => 2, :z=>3)
1299
1298
  end
1300
1299
 
1301
1300
  it "#set_all should set not set restricted fields" do
1302
1301
  @o1.set_all(:x => 1, :use_after_commit_rollback => false)
1303
- @o1.use_after_commit_rollback.should == true
1304
- @o1.values.should == {:x => 1}
1302
+ @o1.use_after_commit_rollback.must_equal true
1303
+ @o1.values.must_equal(:x => 1)
1305
1304
  end
1306
1305
 
1307
1306
  it "#set_only should only set given attributes" do
1308
1307
  @o1.set_only({:x => 1, :y => 2, :z=>3, :id=>4}, [:x, :y])
1309
- @o1.values.should == {:x => 1, :y => 2}
1308
+ @o1.values.must_equal(:x => 1, :y => 2)
1310
1309
  @o1.set_only({:x => 4, :y => 5, :z=>6, :id=>7}, :x, :y)
1311
- @o1.values.should == {:x => 4, :y => 5}
1310
+ @o1.values.must_equal(:x => 4, :y => 5)
1312
1311
  @o1.set_only({:x => 9, :y => 8, :z=>6, :id=>7}, :x, :y, :id)
1313
- @o1.values.should == {:x => 9, :y => 8, :id=>7}
1312
+ @o1.values.must_equal(:x => 9, :y => 8, :id=>7)
1314
1313
  end
1315
1314
 
1316
1315
  it "#update_all should update all attributes" do
1317
1316
  @c.new.update_all(:x => 1)
1318
- DB.sqls.should == ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1317
+ DB.sqls.must_equal ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1319
1318
  @c.new.update_all(:y => 1)
1320
- DB.sqls.should == ["INSERT INTO items (y) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1319
+ DB.sqls.must_equal ["INSERT INTO items (y) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1321
1320
  @c.new.update_all(:z => 1)
1322
- DB.sqls.should == ["INSERT INTO items (z) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1321
+ DB.sqls.must_equal ["INSERT INTO items (z) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1323
1322
  end
1324
1323
 
1325
1324
  it "#update_only should only update given attributes" do
1326
1325
  @o1.update_only({:x => 1, :y => 2, :z=>3, :id=>4}, [:x])
1327
- DB.sqls.should == ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1326
+ DB.sqls.must_equal ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1328
1327
  @c.new.update_only({:x => 1, :y => 2, :z=>3, :id=>4}, :x)
1329
- DB.sqls.should == ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1328
+ DB.sqls.must_equal ["INSERT INTO items (x) VALUES (1)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1330
1329
  end
1331
1330
  end
1332
1331
 
@@ -1340,22 +1339,22 @@ describe Sequel::Model, "#destroy with filtered dataset" do
1340
1339
 
1341
1340
  it "should raise a NoExistingObject exception if the dataset delete call doesn't return 1" do
1342
1341
  def (@instance.this).execute_dui(*a) 0 end
1343
- proc{@instance.delete}.should raise_error(Sequel::NoExistingObject)
1342
+ proc{@instance.delete}.must_raise(Sequel::NoExistingObject)
1344
1343
  def (@instance.this).execute_dui(*a) 2 end
1345
- proc{@instance.delete}.should raise_error(Sequel::NoExistingObject)
1344
+ proc{@instance.delete}.must_raise(Sequel::NoExistingObject)
1346
1345
  def (@instance.this).execute_dui(*a) 1 end
1347
- proc{@instance.delete}.should_not raise_error
1346
+ @instance.delete
1348
1347
 
1349
1348
  @instance.require_modification = false
1350
1349
  def (@instance.this).execute_dui(*a) 0 end
1351
- proc{@instance.delete}.should_not raise_error
1350
+ @instance.delete
1352
1351
  def (@instance.this).execute_dui(*a) 2 end
1353
- proc{@instance.delete}.should_not raise_error
1352
+ @instance.delete
1354
1353
  end
1355
1354
 
1356
1355
  it "should include WHERE clause when deleting" do
1357
1356
  @instance.destroy
1358
- DB.sqls.should == ["DELETE FROM items WHERE ((a = 1) AND (id = 1234))"]
1357
+ DB.sqls.must_equal ["DELETE FROM items WHERE ((a = 1) AND (id = 1234))"]
1359
1358
  end
1360
1359
  end
1361
1360
 
@@ -1369,53 +1368,53 @@ describe Sequel::Model, "#destroy" do
1369
1368
 
1370
1369
  it "should return self" do
1371
1370
  @model.send(:define_method, :after_destroy){3}
1372
- @instance.destroy.should == @instance
1371
+ @instance.destroy.must_equal @instance
1373
1372
  end
1374
1373
 
1375
1374
  it "should raise a NoExistingObject exception if the dataset delete call doesn't return 1" do
1376
1375
  def (@model.dataset).execute_dui(*a) 0 end
1377
- proc{@instance.delete}.should raise_error(Sequel::NoExistingObject)
1376
+ proc{@instance.delete}.must_raise(Sequel::NoExistingObject)
1378
1377
  def (@model.dataset).execute_dui(*a) 2 end
1379
- proc{@instance.delete}.should raise_error(Sequel::NoExistingObject)
1378
+ proc{@instance.delete}.must_raise(Sequel::NoExistingObject)
1380
1379
  def (@model.dataset).execute_dui(*a) 1 end
1381
- proc{@instance.delete}.should_not raise_error
1380
+ @instance.delete
1382
1381
 
1383
1382
  @instance.require_modification = false
1384
1383
  def (@model.dataset).execute_dui(*a) 0 end
1385
- proc{@instance.delete}.should_not raise_error
1384
+ @instance.delete
1386
1385
  def (@model.dataset).execute_dui(*a) 2 end
1387
- proc{@instance.delete}.should_not raise_error
1386
+ @instance.delete
1388
1387
  end
1389
1388
 
1390
1389
  it "should run within a transaction if use_transactions is true" do
1391
1390
  @instance.use_transactions = true
1392
1391
  @instance.destroy
1393
- DB.sqls.should == ["BEGIN", "DELETE FROM items WHERE id = 1234", "COMMIT"]
1392
+ DB.sqls.must_equal ["BEGIN", "DELETE FROM items WHERE id = 1234", "COMMIT"]
1394
1393
  end
1395
1394
 
1396
1395
  it "should not run within a transaction if use_transactions is false" do
1397
1396
  @instance.use_transactions = false
1398
1397
  @instance.destroy
1399
- DB.sqls.should == ["DELETE FROM items WHERE id = 1234"]
1398
+ DB.sqls.must_equal ["DELETE FROM items WHERE id = 1234"]
1400
1399
  end
1401
1400
 
1402
1401
  it "should run within a transaction if :transaction option is true" do
1403
1402
  @instance.use_transactions = false
1404
1403
  @instance.destroy(:transaction => true)
1405
- DB.sqls.should == ["BEGIN", "DELETE FROM items WHERE id = 1234", "COMMIT"]
1404
+ DB.sqls.must_equal ["BEGIN", "DELETE FROM items WHERE id = 1234", "COMMIT"]
1406
1405
  end
1407
1406
 
1408
1407
  it "should not run within a transaction if :transaction option is false" do
1409
1408
  @instance.use_transactions = true
1410
1409
  @instance.destroy(:transaction => false)
1411
- DB.sqls.should == ["DELETE FROM items WHERE id = 1234"]
1410
+ DB.sqls.must_equal ["DELETE FROM items WHERE id = 1234"]
1412
1411
  end
1413
1412
 
1414
1413
  it "should run before_destroy and after_destroy hooks" do
1415
1414
  @model.send(:define_method, :before_destroy){DB.execute('before blah')}
1416
1415
  @model.send(:define_method, :after_destroy){DB.execute('after blah')}
1417
1416
  @instance.destroy
1418
- DB.sqls.should == ["before blah", "DELETE FROM items WHERE id = 1234", "after blah"]
1417
+ DB.sqls.must_equal ["before blah", "DELETE FROM items WHERE id = 1234", "after blah"]
1419
1418
  end
1420
1419
  end
1421
1420
 
@@ -1427,18 +1426,18 @@ describe Sequel::Model, "#exists?" do
1427
1426
  end
1428
1427
 
1429
1428
  it "should do a query to check if the record exists" do
1430
- @model.load(:id=>1).exists?.should == true
1431
- DB.sqls.should == ['SELECT 1 AS one FROM items WHERE (id = 1) LIMIT 1']
1429
+ @model.load(:id=>1).exists?.must_equal true
1430
+ DB.sqls.must_equal ['SELECT 1 AS one FROM items WHERE (id = 1) LIMIT 1']
1432
1431
  end
1433
1432
 
1434
1433
  it "should return false when #this.count == 0" do
1435
- @model.load(:id=>2).exists?.should == false
1436
- DB.sqls.should == ['SELECT 1 AS one FROM items WHERE (id = 2) LIMIT 1']
1434
+ @model.load(:id=>2).exists?.must_equal false
1435
+ DB.sqls.must_equal ['SELECT 1 AS one FROM items WHERE (id = 2) LIMIT 1']
1437
1436
  end
1438
1437
 
1439
1438
  it "should return false without issuing a query if the model object is new" do
1440
- @model.new.exists?.should == false
1441
- DB.sqls.should == []
1439
+ @model.new.exists?.must_equal false
1440
+ DB.sqls.must_equal []
1442
1441
  end
1443
1442
  end
1444
1443
 
@@ -1449,10 +1448,10 @@ describe Sequel::Model, "#each" do
1449
1448
  @m = @model.load(:a => 1, :b => 2, :id => 4444)
1450
1449
  end
1451
1450
 
1452
- specify "should iterate over the values" do
1451
+ it "should iterate over the values" do
1453
1452
  h = {}
1454
1453
  @m.each{|k, v| h[k] = v}
1455
- h.should == {:a => 1, :b => 2, :id => 4444}
1454
+ h.must_equal(:a => 1, :b => 2, :id => 4444)
1456
1455
  end
1457
1456
  end
1458
1457
 
@@ -1463,40 +1462,40 @@ describe Sequel::Model, "#keys" do
1463
1462
  @m = @model.load(:a => 1, :b => 2, :id => 4444)
1464
1463
  end
1465
1464
 
1466
- specify "should return the value keys" do
1467
- @m.keys.sort_by{|k| k.to_s}.should == [:a, :b, :id]
1468
- @model.new.keys.should == []
1465
+ it "should return the value keys" do
1466
+ @m.keys.sort_by{|k| k.to_s}.must_equal [:a, :b, :id]
1467
+ @model.new.keys.must_equal []
1469
1468
  end
1470
1469
  end
1471
1470
 
1472
1471
  describe Sequel::Model, "#==" do
1473
- specify "should compare instances by values" do
1472
+ it "should compare instances by values" do
1474
1473
  z = Class.new(Sequel::Model)
1475
1474
  z.columns :id, :x
1476
1475
  a = z.load(:id => 1, :x => 3)
1477
1476
  b = z.load(:id => 1, :x => 4)
1478
1477
  c = z.load(:id => 1, :x => 3)
1479
1478
 
1480
- a.should_not == b
1481
- a.should == c
1482
- b.should_not == c
1479
+ a.wont_equal b
1480
+ a.must_equal c
1481
+ b.wont_equal c
1483
1482
  end
1484
1483
 
1485
- specify "should be aliased to #eql?" do
1484
+ it "should be aliased to #eql?" do
1486
1485
  z = Class.new(Sequel::Model)
1487
1486
  z.columns :id, :x
1488
1487
  a = z.load(:id => 1, :x => 3)
1489
1488
  b = z.load(:id => 1, :x => 4)
1490
1489
  c = z.load(:id => 1, :x => 3)
1491
1490
 
1492
- a.eql?(b).should == false
1493
- a.eql?(c).should == true
1494
- b.eql?(c).should == false
1491
+ a.eql?(b).must_equal false
1492
+ a.eql?(c).must_equal true
1493
+ b.eql?(c).must_equal false
1495
1494
  end
1496
1495
  end
1497
1496
 
1498
1497
  describe Sequel::Model, "#===" do
1499
- specify "should compare instances by class and pk if pk is not nil" do
1498
+ it "should compare instances by class and pk if pk is not nil" do
1500
1499
  z = Class.new(Sequel::Model)
1501
1500
  z.columns :id, :x
1502
1501
  y = Class.new(Sequel::Model)
@@ -1506,12 +1505,12 @@ describe Sequel::Model, "#===" do
1506
1505
  c = z.load(:id => 2, :x => 3)
1507
1506
  d = y.load(:id => 1, :x => 3)
1508
1507
 
1509
- a.should === b
1510
- a.should_not === c
1511
- a.should_not === d
1508
+ a.must_be :===, b
1509
+ a.wont_be :===, c
1510
+ a.wont_be :===, d
1512
1511
  end
1513
1512
 
1514
- specify "should always be false if the primary key is nil" do
1513
+ it "should always be false if the primary key is nil" do
1515
1514
  z = Class.new(Sequel::Model)
1516
1515
  z.columns :id, :x
1517
1516
  y = Class.new(Sequel::Model)
@@ -1521,38 +1520,38 @@ describe Sequel::Model, "#===" do
1521
1520
  c = z.new(:x => 3)
1522
1521
  d = y.new(:x => 3)
1523
1522
 
1524
- a.should_not === b
1525
- a.should_not === c
1526
- a.should_not === d
1523
+ a.wont_be :===, b
1524
+ a.wont_be :===, c
1525
+ a.wont_be :===, d
1527
1526
  end
1528
1527
  end
1529
1528
 
1530
1529
  describe Sequel::Model, "#hash" do
1531
- specify "should be the same only for objects with the same class and pk if the pk is not nil" do
1530
+ it "should be the same only for objects with the same class and pk if the pk is not nil" do
1532
1531
  z = Class.new(Sequel::Model)
1533
1532
  z.columns :id, :x
1534
1533
  y = Class.new(Sequel::Model)
1535
1534
  y.columns :id, :x
1536
1535
  a = z.load(:id => 1, :x => 3)
1537
1536
 
1538
- a.hash.should == z.load(:id => 1, :x => 4).hash
1539
- a.hash.should_not == z.load(:id => 2, :x => 3).hash
1540
- a.hash.should_not == y.load(:id => 1, :x => 3).hash
1537
+ a.hash.must_equal z.load(:id => 1, :x => 4).hash
1538
+ a.hash.wont_equal z.load(:id => 2, :x => 3).hash
1539
+ a.hash.wont_equal y.load(:id => 1, :x => 3).hash
1541
1540
  end
1542
1541
 
1543
- specify "should be the same only for objects with the same class and values if the pk is nil" do
1542
+ it "should be the same only for objects with the same class and values if the pk is nil" do
1544
1543
  z = Class.new(Sequel::Model)
1545
1544
  z.columns :id, :x
1546
1545
  y = Class.new(Sequel::Model)
1547
1546
  y.columns :id, :x
1548
1547
  a = z.new(:x => 3)
1549
1548
 
1550
- a.hash.should_not == z.new(:x => 4).hash
1551
- a.hash.should == z.new(:x => 3).hash
1552
- a.hash.should_not == y.new(:x => 3).hash
1549
+ a.hash.wont_equal z.new(:x => 4).hash
1550
+ a.hash.must_equal z.new(:x => 3).hash
1551
+ a.hash.wont_equal y.new(:x => 3).hash
1553
1552
  end
1554
1553
 
1555
- specify "should be the same only for objects with the same class and pk if pk is composite and all values are non-NULL" do
1554
+ it "should be the same only for objects with the same class and pk if pk is composite and all values are non-NULL" do
1556
1555
  z = Class.new(Sequel::Model)
1557
1556
  z.columns :id, :id2, :x
1558
1557
  z.set_primary_key([:id, :id2])
@@ -1561,12 +1560,12 @@ describe Sequel::Model, "#hash" do
1561
1560
  y.set_primary_key([:id, :id2])
1562
1561
  a = z.load(:id => 1, :id2=>2, :x => 3)
1563
1562
 
1564
- a.hash.should == z.load(:id => 1, :id2=>2, :x => 4).hash
1565
- a.hash.should_not == z.load(:id => 2, :id2=>1, :x => 3).hash
1566
- a.hash.should_not == y.load(:id => 1, :id2=>1, :x => 3).hash
1563
+ a.hash.must_equal z.load(:id => 1, :id2=>2, :x => 4).hash
1564
+ a.hash.wont_equal z.load(:id => 2, :id2=>1, :x => 3).hash
1565
+ a.hash.wont_equal y.load(:id => 1, :id2=>1, :x => 3).hash
1567
1566
  end
1568
1567
 
1569
- specify "should be the same only for objects with the same class and value if pk is composite and one values is NULL" do
1568
+ it "should be the same only for objects with the same class and value if pk is composite and one values is NULL" do
1570
1569
  z = Class.new(Sequel::Model)
1571
1570
  z.columns :id, :id2, :x
1572
1571
  z.set_primary_key([:id, :id2])
@@ -1575,29 +1574,29 @@ describe Sequel::Model, "#hash" do
1575
1574
  y.set_primary_key([:id, :id2])
1576
1575
 
1577
1576
  a = z.load(:id => 1, :id2 => nil, :x => 3)
1578
- a.hash.should == z.load(:id => 1, :id2=>nil, :x => 3).hash
1579
- a.hash.should_not == z.load(:id => 1, :id2=>nil, :x => 4).hash
1580
- a.hash.should_not == y.load(:id => 1, :id2=>nil, :x => 3).hash
1577
+ a.hash.must_equal z.load(:id => 1, :id2=>nil, :x => 3).hash
1578
+ a.hash.wont_equal z.load(:id => 1, :id2=>nil, :x => 4).hash
1579
+ a.hash.wont_equal y.load(:id => 1, :id2=>nil, :x => 3).hash
1581
1580
 
1582
1581
  a = z.load(:id =>nil, :id2 => nil, :x => 3)
1583
- a.hash.should == z.load(:id => nil, :id2=>nil, :x => 3).hash
1584
- a.hash.should_not == z.load(:id => nil, :id2=>nil, :x => 4).hash
1585
- a.hash.should_not == y.load(:id => nil, :id2=>nil, :x => 3).hash
1582
+ a.hash.must_equal z.load(:id => nil, :id2=>nil, :x => 3).hash
1583
+ a.hash.wont_equal z.load(:id => nil, :id2=>nil, :x => 4).hash
1584
+ a.hash.wont_equal y.load(:id => nil, :id2=>nil, :x => 3).hash
1586
1585
 
1587
1586
  a = z.load(:id => 1, :x => 3)
1588
- a.hash.should == z.load(:id => 1, :x => 3).hash
1589
- a.hash.should_not == z.load(:id => 1, :id2=>nil, :x => 3).hash
1590
- a.hash.should_not == z.load(:id => 1, :x => 4).hash
1591
- a.hash.should_not == y.load(:id => 1, :x => 3).hash
1587
+ a.hash.must_equal z.load(:id => 1, :x => 3).hash
1588
+ a.hash.wont_equal z.load(:id => 1, :id2=>nil, :x => 3).hash
1589
+ a.hash.wont_equal z.load(:id => 1, :x => 4).hash
1590
+ a.hash.wont_equal y.load(:id => 1, :x => 3).hash
1592
1591
 
1593
1592
  a = z.load(:x => 3)
1594
- a.hash.should == z.load(:x => 3).hash
1595
- a.hash.should_not == z.load(:id => nil, :id2=>nil, :x => 3).hash
1596
- a.hash.should_not == z.load(:x => 4).hash
1597
- a.hash.should_not == y.load(:x => 3).hash
1593
+ a.hash.must_equal z.load(:x => 3).hash
1594
+ a.hash.wont_equal z.load(:id => nil, :id2=>nil, :x => 3).hash
1595
+ a.hash.wont_equal z.load(:x => 4).hash
1596
+ a.hash.wont_equal y.load(:x => 3).hash
1598
1597
  end
1599
1598
 
1600
- specify "should be the same only for objects with the same class and values if the no primary key" do
1599
+ it "should be the same only for objects with the same class and values if the no primary key" do
1601
1600
  z = Class.new(Sequel::Model)
1602
1601
  z.columns :id, :x
1603
1602
  z.no_primary_key
@@ -1606,9 +1605,9 @@ describe Sequel::Model, "#hash" do
1606
1605
  y.no_primary_key
1607
1606
  a = z.new(:x => 3)
1608
1607
 
1609
- a.hash.should_not == z.new(:x => 4).hash
1610
- a.hash.should == z.new(:x => 3).hash
1611
- a.hash.should_not == y.new(:x => 3).hash
1608
+ a.hash.wont_equal z.new(:x => 4).hash
1609
+ a.hash.must_equal z.new(:x => 3).hash
1610
+ a.hash.wont_equal y.new(:x => 3).hash
1612
1611
  end
1613
1612
 
1614
1613
  end
@@ -1621,38 +1620,38 @@ describe Sequel::Model, "#initialize" do
1621
1620
  @c.strict_param_setting = false
1622
1621
  end
1623
1622
 
1624
- specify "should accept values" do
1623
+ it "should accept values" do
1625
1624
  m = @c.new(:x => 2)
1626
- m.values.should == {:x => 2}
1625
+ m.values.must_equal(:x => 2)
1627
1626
  end
1628
1627
 
1629
- specify "should not modify the primary key" do
1628
+ it "should not modify the primary key" do
1630
1629
  m = @c.new(:id => 1, :x => 2)
1631
- m.values.should == {:x => 2}
1630
+ m.values.must_equal(:x => 2)
1632
1631
  end
1633
1632
 
1634
- specify "should accept no values" do
1633
+ it "should accept no values" do
1635
1634
  m = @c.new
1636
- m.values.should == {}
1635
+ m.values.must_equal({})
1637
1636
  end
1638
1637
 
1639
- specify "should accept a block to execute" do
1638
+ it "should accept a block to execute" do
1640
1639
  m = @c.new {|o| o[:id] = 1234}
1641
- m.id.should == 1234
1640
+ m.id.must_equal 1234
1642
1641
  end
1643
1642
 
1644
- specify "should accept virtual attributes" do
1643
+ it "should accept virtual attributes" do
1645
1644
  @c.send(:define_method, :blah=){|x| @blah = x}
1646
1645
  @c.send(:define_method, :blah){@blah}
1647
1646
 
1648
1647
  m = @c.new(:x => 2, :blah => 3)
1649
- m.values.should == {:x => 2}
1650
- m.blah.should == 3
1648
+ m.values.must_equal(:x => 2)
1649
+ m.blah.must_equal 3
1651
1650
  end
1652
1651
 
1653
- specify "should convert string keys into symbol keys" do
1652
+ it "should convert string keys into symbol keys" do
1654
1653
  m = @c.new('x' => 2)
1655
- m.values.should == {:x => 2}
1654
+ m.values.must_equal(:x => 2)
1656
1655
  end
1657
1656
  end
1658
1657
 
@@ -1661,21 +1660,21 @@ describe Sequel::Model, "#initialize_set" do
1661
1660
  @c = Class.new(Sequel::Model){columns :id, :x, :y}
1662
1661
  end
1663
1662
 
1664
- specify "should be called by initialize to set the column values" do
1663
+ it "should be called by initialize to set the column values" do
1665
1664
  @c.send(:define_method, :initialize_set){|h| set(:y => 3)}
1666
- @c.new(:x => 2).values.should == {:y => 3}
1665
+ @c.new(:x => 2).values.must_equal(:y => 3)
1667
1666
  end
1668
1667
 
1669
- specify "should be called with the hash given to initialize " do
1668
+ it "should be called with the hash given to initialize " do
1670
1669
  x = nil
1671
1670
  @c.send(:define_method, :initialize_set){|y| x = y}
1672
1671
  @c.new(:x => 2)
1673
- x.should == {:x => 2}
1672
+ x.must_equal(:x => 2)
1674
1673
  end
1675
1674
 
1676
- specify "should not cause columns modified by the method to be considered as changed" do
1675
+ it "should not cause columns modified by the method to be considered as changed" do
1677
1676
  @c.send(:define_method, :initialize_set){|h| set(:y => 3)}
1678
- @c.new(:x => 2).changed_columns.should == []
1677
+ @c.new(:x => 2).changed_columns.must_equal []
1679
1678
  end
1680
1679
  end
1681
1680
 
@@ -1690,31 +1689,31 @@ describe Sequel::Model, ".create" do
1690
1689
 
1691
1690
  it "should be able to create rows in the associated table" do
1692
1691
  o = @c.create(:x => 1)
1693
- o.class.should == @c
1694
- DB.sqls.should == ['INSERT INTO items (x) VALUES (1)', "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1692
+ o.class.must_equal @c
1693
+ DB.sqls.must_equal ['INSERT INTO items (x) VALUES (1)', "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1695
1694
  end
1696
1695
 
1697
1696
  it "should be able to create rows without any values specified" do
1698
1697
  o = @c.create
1699
- o.class.should == @c
1700
- DB.sqls.should == ["INSERT INTO items DEFAULT VALUES", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1698
+ o.class.must_equal @c
1699
+ DB.sqls.must_equal ["INSERT INTO items DEFAULT VALUES", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1701
1700
  end
1702
1701
 
1703
1702
  it "should accept a block and call it" do
1704
1703
  o1, o2, o3 = nil, nil, nil
1705
1704
  o = @c.create {|o4| o1 = o4; o3 = o4; o2 = :blah; o3.x = 333}
1706
- o.class.should == @c
1707
- o1.should === o
1708
- o3.should === o
1709
- o2.should == :blah
1710
- DB.sqls.should == ["INSERT INTO items (x) VALUES (333)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1705
+ o.class.must_equal @c
1706
+ o1.must_be :===, o
1707
+ o3.must_be :===, o
1708
+ o2.must_equal :blah
1709
+ DB.sqls.must_equal ["INSERT INTO items (x) VALUES (333)", "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
1711
1710
  end
1712
1711
 
1713
1712
  it "should create a row for a model with custom primary key" do
1714
1713
  @c.set_primary_key :x
1715
1714
  o = @c.create(:x => 30)
1716
- o.class.should == @c
1717
- DB.sqls.should == ["INSERT INTO items (x) VALUES (30)", "SELECT * FROM items WHERE (x = 30) LIMIT 1"]
1715
+ o.class.must_equal @c
1716
+ DB.sqls.must_equal ["INSERT INTO items (x) VALUES (30)", "SELECT * FROM items WHERE (x = 30) LIMIT 1"]
1718
1717
  end
1719
1718
  end
1720
1719
 
@@ -1727,28 +1726,28 @@ describe Sequel::Model, "#refresh" do
1727
1726
  DB.reset
1728
1727
  end
1729
1728
 
1730
- specify "should reload the instance values from the database" do
1729
+ it "should reload the instance values from the database" do
1731
1730
  @m = @c.new(:id => 555)
1732
1731
  @m[:x] = 'blah'
1733
1732
  @c.instance_dataset._fetch = @c.dataset._fetch = {:x => 'kaboom', :id => 555}
1734
1733
  @m.refresh
1735
- @m[:x].should == 'kaboom'
1736
- DB.sqls.should == ["SELECT * FROM items WHERE (id = 555) LIMIT 1"]
1734
+ @m[:x].must_equal 'kaboom'
1735
+ DB.sqls.must_equal ["SELECT * FROM items WHERE (id = 555) LIMIT 1"]
1737
1736
  end
1738
1737
 
1739
- specify "should raise if the instance is not found" do
1738
+ it "should raise if the instance is not found" do
1740
1739
  @m = @c.new(:id => 555)
1741
1740
  @c.instance_dataset._fetch =@c.dataset._fetch = []
1742
- proc {@m.refresh}.should raise_error(Sequel::Error)
1743
- DB.sqls.should == ["SELECT * FROM items WHERE (id = 555) LIMIT 1"]
1741
+ proc {@m.refresh}.must_raise(Sequel::Error)
1742
+ DB.sqls.must_equal ["SELECT * FROM items WHERE (id = 555) LIMIT 1"]
1744
1743
  end
1745
1744
 
1746
- specify "should be aliased by #reload" do
1745
+ it "should be aliased by #reload" do
1747
1746
  @m = @c.new(:id => 555)
1748
1747
  @c.instance_dataset._fetch =@c.dataset._fetch = {:x => 'kaboom', :id => 555}
1749
1748
  @m.reload
1750
- @m[:x].should == 'kaboom'
1751
- DB.sqls.should == ["SELECT * FROM items WHERE (id = 555) LIMIT 1"]
1749
+ @m[:x].must_equal 'kaboom'
1750
+ DB.sqls.must_equal ["SELECT * FROM items WHERE (id = 555) LIMIT 1"]
1752
1751
  end
1753
1752
  end
1754
1753
 
@@ -1766,349 +1765,349 @@ describe Sequel::Model, "typecasting" do
1766
1765
  Sequel.datetime_class = Time
1767
1766
  end
1768
1767
 
1769
- specify "should not convert if typecasting is turned off" do
1768
+ it "should not convert if typecasting is turned off" do
1770
1769
  @c.typecast_on_assignment = false
1771
1770
  m = @c.new
1772
1771
  m.x = '1'
1773
- m.x.should == '1'
1772
+ m.x.must_equal '1'
1774
1773
  end
1775
1774
 
1776
- specify "should convert to integer for an integer field" do
1775
+ it "should convert to integer for an integer field" do
1777
1776
  @c.db_schema = {:x=>{:type=>:integer}}
1778
1777
  m = @c.new
1779
1778
  m.x = '1'
1780
- m.x.should == 1
1779
+ m.x.must_equal 1
1781
1780
  m.x = 1
1782
- m.x.should == 1
1781
+ m.x.must_equal 1
1783
1782
  m.x = 1.3
1784
- m.x.should == 1
1783
+ m.x.must_equal 1
1785
1784
  end
1786
1785
 
1787
- specify "should typecast '' to nil unless type is string or blob" do
1786
+ it "should typecast '' to nil unless type is string or blob" do
1788
1787
  [:integer, :float, :decimal, :boolean, :date, :time, :datetime].each do |x|
1789
1788
  @c.db_schema = {:x=>{:type=>x}}
1790
1789
  m = @c.new
1791
1790
  m.x = ''
1792
- m.x.should == nil
1791
+ m.x.must_equal nil
1793
1792
  end
1794
1793
  [:string, :blob].each do |x|
1795
1794
  @c.db_schema = {:x=>{:type=>x}}
1796
1795
  m = @c.new
1797
1796
  m.x = ''
1798
- m.x.should == ''
1797
+ m.x.must_equal ''
1799
1798
  end
1800
1799
  end
1801
1800
 
1802
- specify "should not typecast '' to nil if typecast_empty_string_to_nil is false" do
1801
+ it "should not typecast '' to nil if typecast_empty_string_to_nil is false" do
1803
1802
  m = @c.new
1804
1803
  m.typecast_empty_string_to_nil = false
1805
- proc{m.x = ''}.should raise_error
1804
+ proc{m.x = ''}.must_raise Sequel::InvalidValue
1806
1805
  @c.typecast_empty_string_to_nil = false
1807
- proc{@c.new.x = ''}.should raise_error
1806
+ proc{@c.new.x = ''}.must_raise Sequel::InvalidValue
1808
1807
  end
1809
1808
 
1810
- specify "should handle typecasting where == raises an error on the object" do
1809
+ it "should handle typecasting where == raises an error on the object" do
1811
1810
  m = @c.new
1812
1811
  o = Object.new
1813
1812
  def o.==(v) raise ArgumentError end
1814
1813
  def o.to_i() 4 end
1815
1814
  m.x = o
1816
- m.x.should == 4
1815
+ m.x.must_equal 4
1817
1816
  end
1818
1817
 
1819
- specify "should not typecast nil if NULLs are allowed" do
1818
+ it "should not typecast nil if NULLs are allowed" do
1820
1819
  @c.db_schema[:x][:allow_null] = true
1821
1820
  m = @c.new
1822
1821
  m.x = nil
1823
- m.x.should == nil
1822
+ m.x.must_equal nil
1824
1823
  end
1825
1824
 
1826
- specify "should raise an error if attempting to typecast nil and NULLs are not allowed" do
1825
+ it "should raise an error if attempting to typecast nil and NULLs are not allowed" do
1827
1826
  @c.db_schema[:x][:allow_null] = false
1828
- proc{@c.new.x = nil}.should raise_error(Sequel::Error)
1829
- proc{@c.new.x = ''}.should raise_error(Sequel::Error)
1827
+ proc{@c.new.x = nil}.must_raise(Sequel::InvalidValue)
1828
+ proc{@c.new.x = ''}.must_raise(Sequel::InvalidValue)
1830
1829
  end
1831
1830
 
1832
- specify "should not raise an error if NULLs are not allowed and typecasting is turned off" do
1831
+ it "should not raise an error if NULLs are not allowed and typecasting is turned off" do
1833
1832
  @c.typecast_on_assignment = false
1834
1833
  @c.db_schema[:x][:allow_null] = false
1835
1834
  m = @c.new
1836
1835
  m.x = nil
1837
- m.x.should == nil
1836
+ m.x.must_equal nil
1838
1837
  end
1839
1838
 
1840
- specify "should not raise when typecasting nil to NOT NULL column but raise_on_typecast_failure is off" do
1839
+ it "should not raise when typecasting nil to NOT NULL column but raise_on_typecast_failure is off" do
1841
1840
  @c.raise_on_typecast_failure = false
1842
1841
  @c.typecast_on_assignment = true
1843
1842
  m = @c.new
1844
1843
  m.x = ''
1845
- m.x.should == nil
1844
+ m.x.must_equal nil
1846
1845
  m.x = nil
1847
- m.x.should == nil
1846
+ m.x.must_equal nil
1848
1847
  end
1849
1848
 
1850
- specify "should raise an error if invalid data is used in an integer field" do
1851
- proc{@c.new.x = 'a'}.should raise_error(Sequel::InvalidValue)
1849
+ it "should raise an error if invalid data is used in an integer field" do
1850
+ proc{@c.new.x = 'a'}.must_raise(Sequel::InvalidValue)
1852
1851
  end
1853
1852
 
1854
- specify "should assign value if raise_on_typecast_failure is off and assigning invalid integer" do
1853
+ it "should assign value if raise_on_typecast_failure is off and assigning invalid integer" do
1855
1854
  @c.raise_on_typecast_failure = false
1856
1855
  model = @c.new
1857
1856
  model.x = '1d'
1858
- model.x.should == '1d'
1857
+ model.x.must_equal '1d'
1859
1858
  end
1860
1859
 
1861
- specify "should convert to float for a float field" do
1860
+ it "should convert to float for a float field" do
1862
1861
  @c.db_schema = {:x=>{:type=>:float}}
1863
1862
  m = @c.new
1864
1863
  m.x = '1.3'
1865
- m.x.should == 1.3
1864
+ m.x.must_equal 1.3
1866
1865
  m.x = 1
1867
- m.x.should == 1.0
1866
+ m.x.must_equal 1.0
1868
1867
  m.x = 1.3
1869
- m.x.should == 1.3
1868
+ m.x.must_equal 1.3
1870
1869
  end
1871
1870
 
1872
- specify "should raise an error if invalid data is used in an float field" do
1871
+ it "should raise an error if invalid data is used in an float field" do
1873
1872
  @c.db_schema = {:x=>{:type=>:float}}
1874
- proc{@c.new.x = 'a'}.should raise_error(Sequel::InvalidValue)
1873
+ proc{@c.new.x = 'a'}.must_raise(Sequel::InvalidValue)
1875
1874
  end
1876
1875
 
1877
- specify "should assign value if raise_on_typecast_failure is off and assigning invalid float" do
1876
+ it "should assign value if raise_on_typecast_failure is off and assigning invalid float" do
1878
1877
  @c.raise_on_typecast_failure = false
1879
1878
  @c.db_schema = {:x=>{:type=>:float}}
1880
1879
  model = @c.new
1881
1880
  model.x = '1d'
1882
- model.x.should == '1d'
1881
+ model.x.must_equal '1d'
1883
1882
  end
1884
1883
 
1885
- specify "should convert to BigDecimal for a decimal field" do
1884
+ it "should convert to BigDecimal for a decimal field" do
1886
1885
  @c.db_schema = {:x=>{:type=>:decimal}}
1887
1886
  m = @c.new
1888
1887
  bd = BigDecimal.new('1.0')
1889
1888
  m.x = '1.0'
1890
- m.x.should == bd
1889
+ m.x.must_equal bd
1891
1890
  m.x = 1.0
1892
- m.x.should == bd
1891
+ m.x.must_equal bd
1893
1892
  m.x = 1
1894
- m.x.should == bd
1893
+ m.x.must_equal bd
1895
1894
  m.x = bd
1896
- m.x.should == bd
1895
+ m.x.must_equal bd
1897
1896
  m.x = '0'
1898
- m.x.should == 0
1897
+ m.x.must_equal 0
1899
1898
  end
1900
1899
 
1901
- specify "should raise an error if invalid data is used in an decimal field" do
1900
+ it "should raise an error if invalid data is used in an decimal field" do
1902
1901
  @c.db_schema = {:x=>{:type=>:decimal}}
1903
- proc{@c.new.x = Date.today}.should raise_error(Sequel::InvalidValue)
1904
- proc{@c.new.x = 'foo'}.should raise_error(Sequel::InvalidValue)
1902
+ proc{@c.new.x = Date.today}.must_raise(Sequel::InvalidValue)
1903
+ proc{@c.new.x = 'foo'}.must_raise(Sequel::InvalidValue)
1905
1904
  end
1906
1905
 
1907
- specify "should assign value if raise_on_typecast_failure is off and assigning invalid decimal" do
1906
+ it "should assign value if raise_on_typecast_failure is off and assigning invalid decimal" do
1908
1907
  @c.raise_on_typecast_failure = false
1909
1908
  @c.db_schema = {:x=>{:type=>:decimal}}
1910
1909
  model = @c.new
1911
1910
  time = Time.now
1912
1911
  model.x = time
1913
- model.x.should == time
1912
+ model.x.must_equal time
1914
1913
  end
1915
1914
 
1916
- specify "should convert to string for a string field" do
1915
+ it "should convert to string for a string field" do
1917
1916
  @c.db_schema = {:x=>{:type=>:string}}
1918
1917
  m = @c.new
1919
1918
  m.x = '1.3'
1920
- m.x.should == '1.3'
1919
+ m.x.must_equal '1.3'
1921
1920
  m.x = 1
1922
- m.x.should == '1'
1921
+ m.x.must_equal '1'
1923
1922
  m.x = 1.3
1924
- m.x.should == '1.3'
1923
+ m.x.must_equal '1.3'
1925
1924
  end
1926
1925
 
1927
- specify "should convert to boolean for a boolean field" do
1926
+ it "should convert to boolean for a boolean field" do
1928
1927
  @c.db_schema = {:x=>{:type=>:boolean}}
1929
1928
  m = @c.new
1930
1929
  m.x = '1.3'
1931
- m.x.should == true
1930
+ m.x.must_equal true
1932
1931
  m.x = 1
1933
- m.x.should == true
1932
+ m.x.must_equal true
1934
1933
  m.x = 1.3
1935
- m.x.should == true
1934
+ m.x.must_equal true
1936
1935
  m.x = 't'
1937
- m.x.should == true
1936
+ m.x.must_equal true
1938
1937
  m.x = 'T'
1939
- m.x.should == true
1938
+ m.x.must_equal true
1940
1939
  m.x = 'y'
1941
- m.x.should == true
1940
+ m.x.must_equal true
1942
1941
  m.x = 'Y'
1943
- m.x.should == true
1942
+ m.x.must_equal true
1944
1943
  m.x = true
1945
- m.x.should == true
1944
+ m.x.must_equal true
1946
1945
  m.x = nil
1947
- m.x.should == nil
1946
+ m.x.must_equal nil
1948
1947
  m.x = ''
1949
- m.x.should == nil
1948
+ m.x.must_equal nil
1950
1949
  m.x = []
1951
- m.x.should == nil
1950
+ m.x.must_equal nil
1952
1951
  m.x = 'f'
1953
- m.x.should == false
1952
+ m.x.must_equal false
1954
1953
  m.x = 'F'
1955
- m.x.should == false
1954
+ m.x.must_equal false
1956
1955
  m.x = 'false'
1957
- m.x.should == false
1956
+ m.x.must_equal false
1958
1957
  m.x = 'FALSE'
1959
- m.x.should == false
1958
+ m.x.must_equal false
1960
1959
  m.x = 'n'
1961
- m.x.should == false
1960
+ m.x.must_equal false
1962
1961
  m.x = 'N'
1963
- m.x.should == false
1962
+ m.x.must_equal false
1964
1963
  m.x = 'no'
1965
- m.x.should == false
1964
+ m.x.must_equal false
1966
1965
  m.x = 'NO'
1967
- m.x.should == false
1966
+ m.x.must_equal false
1968
1967
  m.x = '0'
1969
- m.x.should == false
1968
+ m.x.must_equal false
1970
1969
  m.x = 0
1971
- m.x.should == false
1970
+ m.x.must_equal false
1972
1971
  m.x = false
1973
- m.x.should == false
1972
+ m.x.must_equal false
1974
1973
  end
1975
1974
 
1976
- specify "should convert to date for a date field" do
1975
+ it "should convert to date for a date field" do
1977
1976
  @c.db_schema = {:x=>{:type=>:date}}
1978
1977
  m = @c.new
1979
1978
  y = Date.new(2007,10,21)
1980
1979
  m.x = '2007-10-21'
1981
- m.x.should == y
1980
+ m.x.must_equal y
1982
1981
  m.x = Date.parse('2007-10-21')
1983
- m.x.should == y
1982
+ m.x.must_equal y
1984
1983
  m.x = Time.parse('2007-10-21')
1985
- m.x.should == y
1984
+ m.x.must_equal y
1986
1985
  m.x = DateTime.parse('2007-10-21')
1987
- m.x.should == y
1986
+ m.x.must_equal y
1988
1987
  end
1989
1988
 
1990
- specify "should accept a hash with symbol or string keys for a date field" do
1989
+ it "should accept a hash with symbol or string keys for a date field" do
1991
1990
  @c.db_schema = {:x=>{:type=>:date}}
1992
1991
  m = @c.new
1993
1992
  y = Date.new(2007,10,21)
1994
1993
  m.x = {:year=>2007, :month=>10, :day=>21}
1995
- m.x.should == y
1994
+ m.x.must_equal y
1996
1995
  m.x = {'year'=>'2007', 'month'=>'10', 'day'=>'21'}
1997
- m.x.should == y
1996
+ m.x.must_equal y
1998
1997
  end
1999
1998
 
2000
- specify "should raise an error if invalid data is used in a date field" do
1999
+ it "should raise an error if invalid data is used in a date field" do
2001
2000
  @c.db_schema = {:x=>{:type=>:date}}
2002
- proc{@c.new.x = 'a'}.should raise_error(Sequel::InvalidValue)
2003
- proc{@c.new.x = 100}.should raise_error(Sequel::InvalidValue)
2001
+ proc{@c.new.x = 'a'}.must_raise(Sequel::InvalidValue)
2002
+ proc{@c.new.x = 100}.must_raise(Sequel::InvalidValue)
2004
2003
  end
2005
2004
 
2006
- specify "should assign value if raise_on_typecast_failure is off and assigning invalid date" do
2005
+ it "should assign value if raise_on_typecast_failure is off and assigning invalid date" do
2007
2006
  @c.raise_on_typecast_failure = false
2008
2007
  @c.db_schema = {:x=>{:type=>:date}}
2009
2008
  model = @c.new
2010
2009
  model.x = 4
2011
- model.x.should == 4
2010
+ model.x.must_equal 4
2012
2011
  end
2013
2012
 
2014
- specify "should convert to Sequel::SQLTime for a time field" do
2013
+ it "should convert to Sequel::SQLTime for a time field" do
2015
2014
  @c.db_schema = {:x=>{:type=>:time}}
2016
2015
  m = @c.new
2017
2016
  x = '10:20:30'
2018
2017
  y = Sequel::SQLTime.parse(x)
2019
2018
  m.x = x
2020
- m.x.should == y
2019
+ m.x.must_equal y
2021
2020
  m.x = y
2022
- m.x.should == y
2023
- m.x.should be_a_kind_of(Sequel::SQLTime)
2021
+ m.x.must_equal y
2022
+ m.x.must_be_kind_of(Sequel::SQLTime)
2024
2023
  end
2025
2024
 
2026
- specify "should accept a hash with symbol or string keys for a time field" do
2025
+ it "should accept a hash with symbol or string keys for a time field" do
2027
2026
  @c.db_schema = {:x=>{:type=>:time}}
2028
2027
  m = @c.new
2029
2028
  y = Time.parse('10:20:30')
2030
2029
  m.x = {:hour=>10, :minute=>20, :second=>30}
2031
- m.x.should == y
2030
+ m.x.must_equal y
2032
2031
  m.x = {'hour'=>'10', 'minute'=>'20', 'second'=>'30'}
2033
- m.x.should == y
2032
+ m.x.must_equal y
2034
2033
  end
2035
2034
 
2036
- specify "should raise an error if invalid data is used in a time field" do
2035
+ it "should raise an error if invalid data is used in a time field" do
2037
2036
  @c.db_schema = {:x=>{:type=>:time}}
2038
- proc{@c.new.x = '0000'}.should raise_error
2039
- proc{@c.new.x = Date.parse('2008-10-21')}.should raise_error(Sequel::InvalidValue)
2040
- proc{@c.new.x = DateTime.parse('2008-10-21')}.should raise_error(Sequel::InvalidValue)
2037
+ proc{@c.new.x = '0000'}.must_raise(Sequel::InvalidValue)
2038
+ proc{@c.new.x = Date.parse('2008-10-21')}.must_raise(Sequel::InvalidValue)
2039
+ proc{@c.new.x = DateTime.parse('2008-10-21')}.must_raise(Sequel::InvalidValue)
2041
2040
  end
2042
2041
 
2043
- specify "should assign value if raise_on_typecast_failure is off and assigning invalid time" do
2042
+ it "should assign value if raise_on_typecast_failure is off and assigning invalid time" do
2044
2043
  @c.raise_on_typecast_failure = false
2045
2044
  @c.db_schema = {:x=>{:type=>:time}}
2046
2045
  model = @c.new
2047
2046
  model.x = '0000'
2048
- model.x.should == '0000'
2047
+ model.x.must_equal '0000'
2049
2048
  end
2050
2049
 
2051
- specify "should convert to the Sequel.datetime_class for a datetime field" do
2050
+ it "should convert to the Sequel.datetime_class for a datetime field" do
2052
2051
  @c.db_schema = {:x=>{:type=>:datetime}}
2053
2052
  m = @c.new
2054
2053
  x = '2007-10-21T10:20:30-07:00'
2055
2054
  y = Time.parse(x)
2056
2055
  m.x = x
2057
- m.x.should == y
2056
+ m.x.must_equal y
2058
2057
  m.x = DateTime.parse(x)
2059
- m.x.should == y
2058
+ m.x.must_equal y
2060
2059
  m.x = Time.parse(x)
2061
- m.x.should == y
2060
+ m.x.must_equal y
2062
2061
  m.x = Date.parse('2007-10-21')
2063
- m.x.should == Time.parse('2007-10-21')
2062
+ m.x.must_equal Time.parse('2007-10-21')
2064
2063
  Sequel.datetime_class = DateTime
2065
2064
  y = DateTime.parse(x)
2066
2065
  m.x = x
2067
- m.x.should == y
2066
+ m.x.must_equal y
2068
2067
  m.x = DateTime.parse(x)
2069
- m.x.should == y
2068
+ m.x.must_equal y
2070
2069
  m.x = Time.parse(x)
2071
- m.x.should == y
2070
+ m.x.must_equal y
2072
2071
  m.x = Date.parse('2007-10-21')
2073
- m.x.should == DateTime.parse('2007-10-21')
2072
+ m.x.must_equal DateTime.parse('2007-10-21')
2074
2073
  end
2075
2074
 
2076
- specify "should accept a hash with symbol or string keys for a datetime field" do
2075
+ it "should accept a hash with symbol or string keys for a datetime field" do
2077
2076
  @c.db_schema = {:x=>{:type=>:datetime}}
2078
2077
  m = @c.new
2079
2078
  y = Time.parse('2007-10-21 10:20:30')
2080
2079
  m.x = {:year=>2007, :month=>10, :day=>21, :hour=>10, :minute=>20, :second=>30}
2081
- m.x.should == y
2080
+ m.x.must_equal y
2082
2081
  m.x = {'year'=>'2007', 'month'=>'10', 'day'=>'21', 'hour'=>'10', 'minute'=>'20', 'second'=>'30'}
2083
- m.x.should == y
2082
+ m.x.must_equal y
2084
2083
  Sequel.datetime_class = DateTime
2085
2084
  y = DateTime.parse('2007-10-21 10:20:30')
2086
2085
  m.x = {:year=>2007, :month=>10, :day=>21, :hour=>10, :minute=>20, :second=>30}
2087
- m.x.should == y
2086
+ m.x.must_equal y
2088
2087
  m.x = {'year'=>'2007', 'month'=>'10', 'day'=>'21', 'hour'=>'10', 'minute'=>'20', 'second'=>'30'}
2089
- m.x.should == y
2088
+ m.x.must_equal y
2090
2089
  end
2091
2090
 
2092
- specify "should raise an error if invalid data is used in a datetime field" do
2091
+ it "should raise an error if invalid data is used in a datetime field" do
2093
2092
  @c.db_schema = {:x=>{:type=>:datetime}}
2094
- proc{@c.new.x = '0000'}.should raise_error(Sequel::InvalidValue)
2093
+ proc{@c.new.x = '0000'}.must_raise(Sequel::InvalidValue)
2095
2094
  Sequel.datetime_class = DateTime
2096
- proc{@c.new.x = '0000'}.should raise_error(Sequel::InvalidValue)
2097
- proc{@c.new.x = 'a'}.should raise_error(Sequel::InvalidValue)
2095
+ proc{@c.new.x = '0000'}.must_raise(Sequel::InvalidValue)
2096
+ proc{@c.new.x = 'a'}.must_raise(Sequel::InvalidValue)
2098
2097
  end
2099
2098
 
2100
- specify "should assign value if raise_on_typecast_failure is off and assigning invalid datetime" do
2099
+ it "should assign value if raise_on_typecast_failure is off and assigning invalid datetime" do
2101
2100
  @c.raise_on_typecast_failure = false
2102
2101
  @c.db_schema = {:x=>{:type=>:datetime}}
2103
2102
  model = @c.new
2104
2103
  model.x = '0000'
2105
- model.x.should == '0000'
2104
+ model.x.must_equal '0000'
2106
2105
  Sequel.datetime_class = DateTime
2107
2106
  model = @c.new
2108
2107
  model.x = '0000'
2109
- model.x.should == '0000'
2108
+ model.x.must_equal '0000'
2110
2109
  model.x = 'a'
2111
- model.x.should == 'a'
2110
+ model.x.must_equal 'a'
2112
2111
  end
2113
2112
  end
2114
2113
 
@@ -2125,24 +2124,24 @@ describe "Model#lock!" do
2125
2124
  o = @c.new
2126
2125
  def o._refresh(x) raise Sequel::Error; super(x) end
2127
2126
  x = o.lock!
2128
- x.should == o
2129
- DB.sqls.should == []
2127
+ x.must_equal o
2128
+ DB.sqls.must_equal []
2130
2129
  end
2131
2130
 
2132
2131
  it "should refresh the record using for_update if it is not a new record" do
2133
2132
  o = @c.load(:id => 1)
2134
2133
  def o._refresh(x) instance_variable_set(:@a, 1); super(x) end
2135
2134
  x = o.lock!
2136
- x.should == o
2137
- o.instance_variable_get(:@a).should == 1
2138
- DB.sqls.should == ["SELECT * FROM items WHERE (id = 1) LIMIT 1 FOR UPDATE"]
2135
+ x.must_equal o
2136
+ o.instance_variable_get(:@a).must_equal 1
2137
+ DB.sqls.must_equal ["SELECT * FROM items WHERE (id = 1) LIMIT 1 FOR UPDATE"]
2139
2138
  end
2140
2139
  end
2141
2140
 
2142
2141
  describe "Model#schema_type_class" do
2143
- specify "should return the class or array of classes for the given type symbol" do
2142
+ it "should return the class or array of classes for the given type symbol" do
2144
2143
  @c = Class.new(Sequel::Model(:items))
2145
2144
  @c.class_eval{@db_schema = {:id=>{:type=>:integer}}}
2146
- @c.new.send(:schema_type_class, :id).should == Integer
2145
+ @c.new.send(:schema_type_class, :id).must_equal Integer
2147
2146
  end
2148
2147
  end