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
@@ -9,35 +9,35 @@ describe "Model attribute setters" do
9
9
  DB.reset
10
10
  end
11
11
 
12
- specify "refresh should return self" do
12
+ it "refresh should return self" do
13
13
  @o = @c[1]
14
- @o.stub(:_refresh).and_return([])
15
- @o.refresh.should == @o
14
+ def @o._refresh(*) [] end
15
+ @o.refresh.must_equal @o
16
16
  end
17
17
 
18
18
  it "should mark the column value as changed" do
19
- @o.changed_columns.should == []
19
+ @o.changed_columns.must_equal []
20
20
 
21
21
  @o.x = 2
22
- @o.changed_columns.should == [:x]
22
+ @o.changed_columns.must_equal [:x]
23
23
 
24
24
  @o.y = 3
25
- @o.changed_columns.should == [:x, :y]
25
+ @o.changed_columns.must_equal [:x, :y]
26
26
 
27
27
  @o.changed_columns.clear
28
28
 
29
29
  @o[:x] = 2
30
- @o.changed_columns.should == [:x]
30
+ @o.changed_columns.must_equal [:x]
31
31
 
32
32
  @o[:y] = 3
33
- @o.changed_columns.should == [:x, :y]
33
+ @o.changed_columns.must_equal [:x, :y]
34
34
  end
35
35
 
36
36
  it "should handle columns that can't be called like normal ruby methods" do
37
37
  @o.send(:"x y=", 3)
38
- @o.changed_columns.should == [:"x y"]
39
- @o.values.should == {:"x y"=>3}
40
- @o.send(:"x y").should == 3
38
+ @o.changed_columns.must_equal [:"x y"]
39
+ @o.values.must_equal(:"x y"=>3)
40
+ @o.send(:"x y").must_equal 3
41
41
  end
42
42
  end
43
43
 
@@ -51,13 +51,13 @@ describe "Model.def_column_alias" do
51
51
  end
52
52
 
53
53
  it "should create an getter alias for the column" do
54
- @o.id2.should == 1
54
+ @o.id2.must_equal 1
55
55
  end
56
56
 
57
57
  it "should create an setter alias for the column" do
58
58
  @o.id2 = 2
59
- @o.id2.should == 2
60
- @o.values.should == {:id => 2}
59
+ @o.id2.must_equal 2
60
+ @o.values.must_equal(:id => 2)
61
61
  end
62
62
  end
63
63
 
@@ -74,32 +74,32 @@ describe Sequel::Model, "dataset" do
74
74
  [:Elephant, :Maggot, :ShoeSize, :BootSize].each{|x| Object.send(:remove_const, x)}
75
75
  end
76
76
 
77
- specify "should default to the plural of the class name" do
78
- Maggot.dataset.sql.should == 'SELECT * FROM maggots'
79
- ShoeSize.dataset.sql.should == 'SELECT * FROM shoe_sizes'
77
+ it "should default to the plural of the class name" do
78
+ Maggot.dataset.sql.must_equal 'SELECT * FROM maggots'
79
+ ShoeSize.dataset.sql.must_equal 'SELECT * FROM shoe_sizes'
80
80
  end
81
81
 
82
- specify "should return the dataset for the superclass if available" do
83
- BootSize.dataset.sql.should == 'SELECT * FROM shoe_sizes'
82
+ it "should return the dataset for the superclass if available" do
83
+ BootSize.dataset.sql.must_equal 'SELECT * FROM shoe_sizes'
84
84
  end
85
85
 
86
- specify "should return the correct dataset if set explicitly" do
87
- Elephant.dataset.sql.should == 'SELECT * FROM ele1'
88
- @a.dataset.sql.should == 'SELECT * FROM items'
86
+ it "should return the correct dataset if set explicitly" do
87
+ Elephant.dataset.sql.must_equal 'SELECT * FROM ele1'
88
+ @a.dataset.sql.must_equal 'SELECT * FROM items'
89
89
  end
90
90
 
91
- specify "should raise if no dataset is explicitly set and the class is anonymous" do
92
- proc {@b.dataset}.should raise_error(Sequel::Error)
91
+ it "should raise if no dataset is explicitly set and the class is anonymous" do
92
+ proc {@b.dataset}.must_raise(Sequel::Error)
93
93
  end
94
94
 
95
- specify "should disregard namespaces for the table name" do
95
+ it "should disregard namespaces for the table name" do
96
96
  begin
97
97
  module ::BlahBlah
98
98
  class MwaHaHa < Sequel::Model
99
99
  end
100
100
  end
101
101
 
102
- BlahBlah::MwaHaHa.dataset.sql.should == 'SELECT * FROM mwa_ha_has'
102
+ BlahBlah::MwaHaHa.dataset.sql.must_equal 'SELECT * FROM mwa_ha_has'
103
103
  ensure
104
104
  Object.send(:remove_const, :BlahBlah)
105
105
  end
@@ -113,14 +113,14 @@ describe Sequel::Model, ".def_dataset_method" do
113
113
 
114
114
  it "should add a method to the dataset and model if called with a block argument" do
115
115
  @c.def_dataset_method(:return_3){3}
116
- @c.return_3.should == 3
117
- @c.dataset.return_3.should == 3
116
+ @c.return_3.must_equal 3
117
+ @c.dataset.return_3.must_equal 3
118
118
  end
119
119
 
120
120
  it "should handle weird method names" do
121
121
  @c.def_dataset_method(:"return 3"){3}
122
- @c.send(:"return 3").should == 3
123
- @c.dataset.send(:"return 3").should == 3
122
+ @c.send(:"return 3").must_equal 3
123
+ @c.dataset.send(:"return 3").must_equal 3
124
124
  end
125
125
 
126
126
  it "should not add a model method if the model already responds to the method" do
@@ -138,37 +138,37 @@ describe Sequel::Model, ".def_dataset_method" do
138
138
  def_dataset_method(:foo){3}
139
139
  def_dataset_method(:bar){4}
140
140
  end
141
- @c.foo.should == 1
142
- @c.dataset.foo.should == 3
143
- @c.send(:bar).should == 2
144
- @c.dataset.bar.should == 4
141
+ @c.foo.must_equal 1
142
+ @c.dataset.foo.must_equal 3
143
+ @c.send(:bar).must_equal 2
144
+ @c.dataset.bar.must_equal 4
145
145
  end
146
146
 
147
147
  it "should add all passed methods to the model if called without a block argument" do
148
148
  @c.def_dataset_method(:return_3, :return_4)
149
- proc{@c.return_3}.should raise_error(NoMethodError)
150
- proc{@c.return_4}.should raise_error(NoMethodError)
149
+ proc{@c.return_3}.must_raise(NoMethodError)
150
+ proc{@c.return_4}.must_raise(NoMethodError)
151
151
  @c.dataset.instance_eval do
152
152
  def return_3; 3; end
153
153
  def return_4; 4; end
154
154
  end
155
- @c.return_3.should == 3
156
- @c.return_4.should == 4
155
+ @c.return_3.must_equal 3
156
+ @c.return_4.must_equal 4
157
157
  end
158
158
 
159
159
  it "should cache calls and readd methods if set_dataset is used" do
160
160
  @c.def_dataset_method(:return_3){3}
161
161
  @c.set_dataset :items
162
- @c.return_3.should == 3
163
- @c.dataset.return_3.should == 3
162
+ @c.return_3.must_equal 3
163
+ @c.dataset.return_3.must_equal 3
164
164
  end
165
165
 
166
166
  it "should readd methods to subclasses, if set_dataset is used in a subclass" do
167
167
  @c.def_dataset_method(:return_3){3}
168
168
  c = Class.new(@c)
169
169
  c.set_dataset :items
170
- c.return_3.should == 3
171
- c.dataset.return_3.should == 3
170
+ c.return_3.must_equal 3
171
+ c.dataset.return_3.must_equal 3
172
172
  end
173
173
  end
174
174
 
@@ -179,69 +179,69 @@ describe Sequel::Model, ".dataset_module" do
179
179
 
180
180
  it "should extend the dataset with the module if the model has a dataset" do
181
181
  @c.dataset_module{def return_3() 3 end}
182
- @c.dataset.return_3.should == 3
182
+ @c.dataset.return_3.must_equal 3
183
183
  end
184
184
 
185
185
  it "should also extend the instance_dataset with the module if the model has a dataset" do
186
186
  @c.dataset_module{def return_3() 3 end}
187
- @c.instance_dataset.return_3.should == 3
187
+ @c.instance_dataset.return_3.must_equal 3
188
188
  end
189
189
 
190
190
  it "should add methods defined in the module to the class" do
191
191
  @c.dataset_module{def return_3() 3 end}
192
- @c.return_3.should == 3
192
+ @c.return_3.must_equal 3
193
193
  end
194
194
 
195
195
  it "should add methods defined in the module outside the block to the class" do
196
196
  @c.dataset_module.module_eval{def return_3() 3 end}
197
- @c.return_3.should == 3
197
+ @c.return_3.must_equal 3
198
198
  end
199
199
 
200
200
  it "should cache calls and readd methods if set_dataset is used" do
201
201
  @c.dataset_module{def return_3() 3 end}
202
202
  @c.set_dataset :items
203
- @c.return_3.should == 3
204
- @c.dataset.return_3.should == 3
203
+ @c.return_3.must_equal 3
204
+ @c.dataset.return_3.must_equal 3
205
205
  end
206
206
 
207
207
  it "should readd methods to subclasses, if set_dataset is used in a subclass" do
208
208
  @c.dataset_module{def return_3() 3 end}
209
209
  c = Class.new(@c)
210
210
  c.set_dataset :items
211
- c.return_3.should == 3
212
- c.dataset.return_3.should == 3
211
+ c.return_3.must_equal 3
212
+ c.dataset.return_3.must_equal 3
213
213
  end
214
214
 
215
215
  it "should only have a single dataset_module per class" do
216
216
  @c.dataset_module{def return_3() 3 end}
217
217
  @c.dataset_module{def return_3() 3 + (begin; super; rescue NoMethodError; 1; end) end}
218
- @c.return_3.should == 4
218
+ @c.return_3.must_equal 4
219
219
  end
220
220
 
221
221
  it "should not have subclasses share the dataset_module" do
222
222
  @c.dataset_module{def return_3() 3 end}
223
223
  c = Class.new(@c)
224
224
  c.dataset_module{def return_3() 3 + (begin; super; rescue NoMethodError; 1; end) end}
225
- c.return_3.should == 6
225
+ c.return_3.must_equal 6
226
226
  end
227
227
 
228
228
  it "should accept a module object and extend the dataset with it" do
229
229
  @c.dataset_module Module.new{def return_3() 3 end}
230
- @c.dataset.return_3.should == 3
230
+ @c.dataset.return_3.must_equal 3
231
231
  end
232
232
 
233
233
  it "should be able to call dataset_module with a module multiple times" do
234
234
  @c.dataset_module Module.new{def return_3() 3 end}
235
235
  @c.dataset_module Module.new{def return_4() 4 end}
236
- @c.dataset.return_3.should == 3
237
- @c.dataset.return_4.should == 4
236
+ @c.dataset.return_3.must_equal 3
237
+ @c.dataset.return_4.must_equal 4
238
238
  end
239
239
 
240
240
  it "should be able mix dataset_module calls with and without arguments" do
241
241
  @c.dataset_module{def return_3() 3 end}
242
242
  @c.dataset_module Module.new{def return_4() 4 end}
243
- @c.dataset.return_3.should == 3
244
- @c.dataset.return_4.should == 4
243
+ @c.dataset.return_3.must_equal 3
244
+ @c.dataset.return_4.must_equal 4
245
245
  end
246
246
 
247
247
  it "should have modules provided to dataset_module extend subclass datasets" do
@@ -249,26 +249,26 @@ describe Sequel::Model, ".dataset_module" do
249
249
  @c.dataset_module Module.new{def return_4() 4 end}
250
250
  c = Class.new(@c)
251
251
  c.set_dataset :a
252
- c.dataset.return_3.should == 3
253
- c.dataset.return_4.should == 4
252
+ c.dataset.return_3.must_equal 3
253
+ c.dataset.return_4.must_equal 4
254
254
  end
255
255
 
256
256
  it "should return the dataset module if given a block" do
257
- Object.new.extend(@c.dataset_module{def return_3() 3 end}).return_3.should == 3
257
+ Object.new.extend(@c.dataset_module{def return_3() 3 end}).return_3.must_equal 3
258
258
  end
259
259
 
260
260
  it "should return the argument if given one" do
261
- Object.new.extend(@c.dataset_module Module.new{def return_3() 3 end}).return_3.should == 3
261
+ Object.new.extend(@c.dataset_module Module.new{def return_3() 3 end}).return_3.must_equal 3
262
262
  end
263
263
 
264
264
  it "should have dataset_module support a subset method" do
265
265
  @c.dataset_module{subset :released, :released}
266
- @c.released.sql.should == 'SELECT * FROM items WHERE released'
267
- @c.where(:foo).released.sql.should == 'SELECT * FROM items WHERE (foo AND released)'
266
+ @c.released.sql.must_equal 'SELECT * FROM items WHERE released'
267
+ @c.where(:foo).released.sql.must_equal 'SELECT * FROM items WHERE (foo AND released)'
268
268
  end
269
269
 
270
270
  it "should raise error if called with both an argument and ablock" do
271
- proc{@c.dataset_module(Module.new{def return_3() 3 end}){}}.should raise_error(Sequel::Error)
271
+ proc{@c.dataset_module(Module.new{def return_3() 3 end}){}}.must_raise(Sequel::Error)
272
272
  end
273
273
  end
274
274
 
@@ -281,8 +281,8 @@ describe "A model class with implicit table name" do
281
281
  Object.send(:remove_const, :Donkey)
282
282
  end
283
283
 
284
- specify "should have a dataset associated with the model class" do
285
- Donkey.dataset.model.should == Donkey
284
+ it "should have a dataset associated with the model class" do
285
+ Donkey.dataset.model.must_equal Donkey
286
286
  end
287
287
  end
288
288
 
@@ -296,9 +296,9 @@ describe "A model inheriting from a model" do
296
296
  Object.send(:remove_const, :Feline)
297
297
  end
298
298
 
299
- specify "should have a dataset associated with itself" do
300
- Feline.dataset.model.should == Feline
301
- Leopard.dataset.model.should == Leopard
299
+ it "should have a dataset associated with itself" do
300
+ Feline.dataset.model.must_equal Feline
301
+ Leopard.dataset.model.must_equal Leopard
302
302
  end
303
303
  end
304
304
 
@@ -307,21 +307,21 @@ describe "Model.primary_key" do
307
307
  @c = Class.new(Sequel::Model)
308
308
  end
309
309
 
310
- specify "should default to id" do
311
- @c.primary_key.should == :id
310
+ it "should default to id" do
311
+ @c.primary_key.must_equal :id
312
312
  end
313
313
 
314
- specify "should be overridden by set_primary_key" do
314
+ it "should be overridden by set_primary_key" do
315
315
  @c.set_primary_key :cid
316
- @c.primary_key.should == :cid
316
+ @c.primary_key.must_equal :cid
317
317
 
318
318
  @c.set_primary_key([:id1, :id2])
319
- @c.primary_key.should == [:id1, :id2]
319
+ @c.primary_key.must_equal [:id1, :id2]
320
320
  end
321
321
 
322
- specify "should use nil for no primary key" do
322
+ it "should use nil for no primary key" do
323
323
  @c.no_primary_key
324
- @c.primary_key.should == nil
324
+ @c.primary_key.must_equal nil
325
325
  end
326
326
  end
327
327
 
@@ -330,18 +330,18 @@ describe "Model.primary_key_hash" do
330
330
  @c = Class.new(Sequel::Model)
331
331
  end
332
332
 
333
- specify "should handle a single primary key" do
334
- @c.primary_key_hash(1).should == {:id=>1}
333
+ it "should handle a single primary key" do
334
+ @c.primary_key_hash(1).must_equal(:id=>1)
335
335
  end
336
336
 
337
- specify "should handle a composite primary key" do
337
+ it "should handle a composite primary key" do
338
338
  @c.set_primary_key([:id1, :id2])
339
- @c.primary_key_hash([1, 2]).should == {:id1=>1, :id2=>2}
339
+ @c.primary_key_hash([1, 2]).must_equal(:id1=>1, :id2=>2)
340
340
  end
341
341
 
342
- specify "should raise an error for no primary key" do
342
+ it "should raise an error for no primary key" do
343
343
  @c.no_primary_key
344
- proc{@c.primary_key_hash(1)}.should raise_error(Sequel::Error)
344
+ proc{@c.primary_key_hash(1)}.must_raise(Sequel::Error)
345
345
  end
346
346
  end
347
347
 
@@ -350,24 +350,24 @@ describe "Model.qualified_primary_key_hash" do
350
350
  @c = Class.new(Sequel::Model(:items))
351
351
  end
352
352
 
353
- specify "should handle a single primary key" do
354
- @c.qualified_primary_key_hash(1).should == {Sequel.qualify(:items, :id)=>1}
353
+ it "should handle a single primary key" do
354
+ @c.qualified_primary_key_hash(1).must_equal(Sequel.qualify(:items, :id)=>1)
355
355
  end
356
356
 
357
- specify "should handle a composite primary key" do
357
+ it "should handle a composite primary key" do
358
358
  @c.set_primary_key([:id1, :id2])
359
- @c.qualified_primary_key_hash([1, 2]).should == {Sequel.qualify(:items, :id1)=>1, Sequel.qualify(:items, :id2)=>2}
359
+ @c.qualified_primary_key_hash([1, 2]).must_equal(Sequel.qualify(:items, :id1)=>1, Sequel.qualify(:items, :id2)=>2)
360
360
  end
361
361
 
362
- specify "should raise an error for no primary key" do
362
+ it "should raise an error for no primary key" do
363
363
  @c.no_primary_key
364
- proc{@c.qualified_primary_key_hash(1)}.should raise_error(Sequel::Error)
364
+ proc{@c.qualified_primary_key_hash(1)}.must_raise(Sequel::Error)
365
365
  end
366
366
 
367
- specify "should allow specifying a different qualifier" do
368
- @c.qualified_primary_key_hash(1, :apple).should == {Sequel.qualify(:apple, :id)=>1}
367
+ it "should allow specifying a different qualifier" do
368
+ @c.qualified_primary_key_hash(1, :apple).must_equal(Sequel.qualify(:apple, :id)=>1)
369
369
  @c.set_primary_key([:id1, :id2])
370
- @c.qualified_primary_key_hash([1, 2], :bear).should == {Sequel.qualify(:bear, :id1)=>1, Sequel.qualify(:bear, :id2)=>2}
370
+ @c.qualified_primary_key_hash([1, 2], :bear).must_equal(Sequel.qualify(:bear, :id1)=>1, Sequel.qualify(:bear, :id2)=>2)
371
371
  end
372
372
  end
373
373
 
@@ -380,40 +380,40 @@ describe "Model.db" do
380
380
  Sequel::DATABASES.clear
381
381
  end
382
382
  after do
383
- Sequel::Model.instance_variable_get(:@db).should == nil
383
+ Sequel::Model.instance_variable_get(:@db).must_equal nil
384
384
  Sequel::DATABASES.replace(@databases)
385
385
  Sequel::Model.db = @model_db
386
386
  end
387
387
 
388
- specify "should be required when creating named model classes" do
388
+ it "should be required when creating named model classes" do
389
389
  begin
390
- proc{class ModelTest < Sequel::Model; end}.should raise_error(Sequel::Error)
390
+ proc{class ModelTest < Sequel::Model; end}.must_raise(Sequel::Error)
391
391
  ensure
392
392
  Object.send(:remove_const, :ModelTest)
393
393
  end
394
394
  end
395
395
 
396
- specify "should be required when creating anonymous model classes without a database" do
397
- proc{Sequel::Model(:foo)}.should raise_error(Sequel::Error)
396
+ it "should be required when creating anonymous model classes without a database" do
397
+ proc{Sequel::Model(:foo)}.must_raise(Sequel::Error)
398
398
  end
399
399
 
400
- specify "should not be required when creating anonymous model classes with a database" do
401
- Sequel::Model(@db).db.should == @db
402
- Sequel::Model(@db[:foo]).db.should == @db
400
+ it "should not be required when creating anonymous model classes with a database" do
401
+ Sequel::Model(@db).db.must_equal @db
402
+ Sequel::Model(@db[:foo]).db.must_equal @db
403
403
  end
404
404
 
405
- specify "should work correctly when subclassing anonymous model classes with a database" do
405
+ it "should work correctly when subclassing anonymous model classes with a database" do
406
406
  begin
407
- Class.new(Sequel::Model(@db)).db.should == @db
408
- Class.new(Sequel::Model(@db[:foo])).db.should == @db
407
+ Class.new(Sequel::Model(@db)).db.must_equal @db
408
+ Class.new(Sequel::Model(@db[:foo])).db.must_equal @db
409
409
  class ModelTest < Sequel::Model(@db)
410
- db.should == @db
410
+ db.must_equal @db
411
411
  end
412
412
  class ModelTest2 < Sequel::Model(@db[:foo])
413
- db.should == @db
413
+ db.must_equal @db
414
414
  end
415
415
  ModelTest.instance_variable_set(:@db, nil)
416
- ModelTest.db.should == @db
416
+ ModelTest.db.must_equal @db
417
417
  ensure
418
418
  Object.send(:remove_const, :ModelTest)
419
419
  Object.send(:remove_const, :ModelTest2)
@@ -429,21 +429,21 @@ describe "Model.db=" do
429
429
  @m = Class.new(Sequel::Model(@db1[:blue].filter(:x=>1)))
430
430
  end
431
431
 
432
- specify "should affect the underlying dataset" do
432
+ it "should affect the underlying dataset" do
433
433
  @m.db = @db2
434
434
 
435
- @m.dataset.db.should === @db2
436
- @m.dataset.db.should_not === @db1
435
+ @m.dataset.db.must_equal @db2
436
+ @m.dataset.db.wont_equal @db1
437
437
  end
438
438
 
439
- specify "should keep the same dataset options" do
439
+ it "should keep the same dataset options" do
440
440
  @m.db = @db2
441
- @m.dataset.sql.should == 'SELECT * FROM blue WHERE (x = 1)'
441
+ @m.dataset.sql.must_equal 'SELECT * FROM blue WHERE (x = 1)'
442
442
  end
443
443
 
444
- specify "should use the database for subclasses" do
444
+ it "should use the database for subclasses" do
445
445
  @m.db = @db2
446
- Class.new(@m).db.should === @db2
446
+ Class.new(@m).db.must_equal @db2
447
447
  end
448
448
  end
449
449
 
@@ -454,28 +454,29 @@ describe Sequel::Model, ".(allowed|restricted)_columns " do
454
454
  end
455
455
  @c.strict_param_setting = false
456
456
  @c.instance_variable_set(:@columns, [:x, :y, :z])
457
+ DB.reset
457
458
  end
458
459
 
459
460
  it "should set the allowed columns correctly" do
460
- @c.allowed_columns.should == nil
461
+ @c.allowed_columns.must_equal nil
461
462
  @c.set_allowed_columns :x
462
- @c.allowed_columns.should == [:x]
463
+ @c.allowed_columns.must_equal [:x]
463
464
  @c.set_allowed_columns :x, :y
464
- @c.allowed_columns.should == [:x, :y]
465
+ @c.allowed_columns.must_equal [:x, :y]
465
466
  end
466
467
 
467
468
  it "should only set allowed columns by default" do
468
469
  @c.set_allowed_columns :x, :y
469
470
  i = @c.new(:x => 1, :y => 2, :z => 3)
470
- i.values.should == {:x => 1, :y => 2}
471
+ i.values.must_equal(:x => 1, :y => 2)
471
472
  i.set(:x => 4, :y => 5, :z => 6)
472
- i.values.should == {:x => 4, :y => 5}
473
+ i.values.must_equal(:x => 4, :y => 5)
473
474
 
474
475
  @c.instance_dataset._fetch = @c.dataset._fetch = {:x => 7}
475
476
  i = @c.new
476
477
  i.update(:x => 7, :z => 9)
477
- i.values.should == {:x => 7}
478
- DB.sqls.should == ["INSERT INTO blahblah (x) VALUES (7)", "SELECT * FROM blahblah WHERE (id = 10) LIMIT 1"]
478
+ i.values.must_equal(:x => 7)
479
+ DB.sqls.must_equal ["INSERT INTO blahblah (x) VALUES (7)", "SELECT * FROM blahblah WHERE (id = 10) LIMIT 1"]
479
480
  end
480
481
  end
481
482
 
@@ -490,30 +491,30 @@ describe Sequel::Model, ".(un)?restrict_primary_key\\??" do
490
491
 
491
492
  it "should restrict updates to primary key by default" do
492
493
  i = @c.new(:x => 1, :y => 2, :id => 3)
493
- i.values.should == {:x => 1, :y => 2}
494
+ i.values.must_equal(:x => 1, :y => 2)
494
495
  i.set(:x => 4, :y => 5, :id => 6)
495
- i.values.should == {:x => 4, :y => 5}
496
+ i.values.must_equal(:x => 4, :y => 5)
496
497
  end
497
498
 
498
499
  it "should allow updates to primary key if unrestrict_primary_key is used" do
499
500
  @c.unrestrict_primary_key
500
501
  i = @c.new(:x => 1, :y => 2, :id => 3)
501
- i.values.should == {:x => 1, :y => 2, :id=>3}
502
+ i.values.must_equal(:x => 1, :y => 2, :id=>3)
502
503
  i.set(:x => 4, :y => 5, :id => 6)
503
- i.values.should == {:x => 4, :y => 5, :id=>6}
504
+ i.values.must_equal(:x => 4, :y => 5, :id=>6)
504
505
  end
505
506
 
506
507
  it "should have restrict_primary_key? return true or false depending" do
507
- @c.restrict_primary_key?.should == true
508
+ @c.restrict_primary_key?.must_equal true
508
509
  @c.unrestrict_primary_key
509
- @c.restrict_primary_key?.should == false
510
+ @c.restrict_primary_key?.must_equal false
510
511
  c1 = Class.new(@c)
511
- c1.restrict_primary_key?.should == false
512
+ c1.restrict_primary_key?.must_equal false
512
513
  @c.restrict_primary_key
513
- @c.restrict_primary_key?.should == true
514
- c1.restrict_primary_key?.should == false
514
+ @c.restrict_primary_key?.must_equal true
515
+ c1.restrict_primary_key?.must_equal false
515
516
  c2 = Class.new(@c)
516
- c2.restrict_primary_key?.should == true
517
+ c2.restrict_primary_key?.must_equal true
517
518
  end
518
519
  end
519
520
 
@@ -526,25 +527,25 @@ describe Sequel::Model, ".strict_param_setting" do
526
527
  end
527
528
 
528
529
  it "should be enabled by default" do
529
- @c.strict_param_setting.should == true
530
+ @c.strict_param_setting.must_equal true
530
531
  end
531
532
 
532
533
  it "should raise an error if a missing/restricted column/method is accessed" do
533
- proc{@c.new(:z=>1)}.should raise_error(Sequel::MassAssignmentRestriction)
534
- proc{@c.create(:z=>1)}.should raise_error(Sequel::MassAssignmentRestriction)
534
+ proc{@c.new(:z=>1)}.must_raise(Sequel::MassAssignmentRestriction)
535
+ proc{@c.create(:z=>1)}.must_raise(Sequel::MassAssignmentRestriction)
535
536
  c = @c.new
536
- proc{c.set(:z=>1)}.should raise_error(Sequel::MassAssignmentRestriction)
537
- proc{c.set_all(:use_after_commit_rollback => false)}.should raise_error(Sequel::MassAssignmentRestriction)
538
- proc{c.set_only({:x=>1}, :y)}.should raise_error(Sequel::MassAssignmentRestriction)
539
- proc{c.update(:z=>1)}.should raise_error(Sequel::MassAssignmentRestriction)
540
- proc{c.update_all(:use_after_commit_rollback=>false)}.should raise_error(Sequel::MassAssignmentRestriction)
541
- proc{c.update_only({:x=>1}, :y)}.should raise_error(Sequel::MassAssignmentRestriction)
537
+ proc{c.set(:z=>1)}.must_raise(Sequel::MassAssignmentRestriction)
538
+ proc{c.set_all(:use_after_commit_rollback => false)}.must_raise(Sequel::MassAssignmentRestriction)
539
+ proc{c.set_only({:x=>1}, :y)}.must_raise(Sequel::MassAssignmentRestriction)
540
+ proc{c.update(:z=>1)}.must_raise(Sequel::MassAssignmentRestriction)
541
+ proc{c.update_all(:use_after_commit_rollback=>false)}.must_raise(Sequel::MassAssignmentRestriction)
542
+ proc{c.update_only({:x=>1}, :y)}.must_raise(Sequel::MassAssignmentRestriction)
542
543
  end
543
544
 
544
545
  it "should be disabled by strict_param_setting = false" do
545
546
  @c.strict_param_setting = false
546
- @c.strict_param_setting.should == false
547
- proc{@c.new(:z=>1)}.should_not raise_error
547
+ @c.strict_param_setting.must_equal false
548
+ @c.new(:z=>1)
548
549
  end
549
550
  end
550
551
 
@@ -560,18 +561,18 @@ describe Sequel::Model, ".require_modification" do
560
561
  end
561
562
 
562
563
  it "should depend on whether the dataset provides an accurate number of rows matched by default" do
563
- Class.new(Sequel::Model).set_dataset(@ds1).require_modification.should == false
564
- Class.new(Sequel::Model).set_dataset(@ds2).require_modification.should == true
564
+ Class.new(Sequel::Model).set_dataset(@ds1).require_modification.must_equal false
565
+ Class.new(Sequel::Model).set_dataset(@ds2).require_modification.must_equal true
565
566
  end
566
567
 
567
568
  it "should obey global setting regardless of dataset support if set" do
568
569
  Sequel::Model.require_modification = true
569
- Class.new(Sequel::Model).set_dataset(@ds1).require_modification.should == true
570
- Class.new(Sequel::Model).set_dataset(@ds2).require_modification.should == true
570
+ Class.new(Sequel::Model).set_dataset(@ds1).require_modification.must_equal true
571
+ Class.new(Sequel::Model).set_dataset(@ds2).require_modification.must_equal true
571
572
 
572
573
  Sequel::Model.require_modification = false
573
- Class.new(Sequel::Model).set_dataset(@ds1).require_modification.should == false
574
- Class.new(Sequel::Model).set_dataset(@ds1).require_modification.should == false
574
+ Class.new(Sequel::Model).set_dataset(@ds1).require_modification.must_equal false
575
+ Class.new(Sequel::Model).set_dataset(@ds1).require_modification.must_equal false
575
576
  end
576
577
  end
577
578
 
@@ -586,73 +587,73 @@ describe Sequel::Model, ".[] optimization" do
586
587
 
587
588
  it "should set simple_pk to the literalized primary key column name if a single primary key" do
588
589
  @c.set_primary_key :id
589
- @c.simple_pk.should == '"id"'
590
+ @c.simple_pk.must_equal '"id"'
590
591
  @c.set_primary_key :b
591
- @c.simple_pk.should == '"b"'
592
+ @c.simple_pk.must_equal '"b"'
592
593
  @c.set_primary_key Sequel.identifier(:b__a)
593
- @c.simple_pk.should == '"b__a"'
594
+ @c.simple_pk.must_equal '"b__a"'
594
595
  end
595
596
 
596
597
  it "should have simple_pk be blank if compound or no primary key" do
597
598
  @c.no_primary_key
598
- @c.simple_pk.should == nil
599
+ @c.simple_pk.must_equal nil
599
600
  @c.set_primary_key [:b, :a]
600
- @c.simple_pk.should == nil
601
+ @c.simple_pk.must_equal nil
601
602
  end
602
603
 
603
604
  it "should have simple table set if passed a Symbol to set_dataset" do
604
605
  @c.set_dataset :a
605
- @c.simple_table.should == '"a"'
606
+ @c.simple_table.must_equal '"a"'
606
607
  @c.set_dataset :b
607
- @c.simple_table.should == '"b"'
608
+ @c.simple_table.must_equal '"b"'
608
609
  @c.set_dataset :b__a
609
- @c.simple_table.should == '"b"."a"'
610
+ @c.simple_table.must_equal '"b"."a"'
610
611
  end
611
612
 
612
613
  it "should have simple_table set if passed a simple select all dataset to set_dataset" do
613
614
  @c.set_dataset @db[:a]
614
- @c.simple_table.should == '"a"'
615
+ @c.simple_table.must_equal '"a"'
615
616
  @c.set_dataset @db[:b]
616
- @c.simple_table.should == '"b"'
617
+ @c.simple_table.must_equal '"b"'
617
618
  @c.set_dataset @db[:b__a]
618
- @c.simple_table.should == '"b"."a"'
619
+ @c.simple_table.must_equal '"b"."a"'
619
620
  end
620
621
 
621
622
  it "should have simple_pk and simple_table respect dataset's identifier input methods" do
622
623
  ds = @db[:ab]
623
624
  ds.identifier_input_method = :reverse
624
625
  @c.set_dataset ds
625
- @c.simple_table.should == '"ba"'
626
+ @c.simple_table.must_equal '"ba"'
626
627
  @c.set_primary_key :cd
627
- @c.simple_pk.should == '"dc"'
628
+ @c.simple_pk.must_equal '"dc"'
628
629
 
629
630
  @c.set_dataset ds.from(:ef__gh)
630
- @c.simple_table.should == '"fe"."hg"'
631
+ @c.simple_table.must_equal '"fe"."hg"'
631
632
  end
632
633
 
633
634
  it "should have simple_table = nil if passed a non-simple select all dataset to set_dataset" do
634
635
  @c.set_dataset @c.db[:a].filter(:active)
635
- @c.simple_table.should == nil
636
+ @c.simple_table.must_equal nil
636
637
  end
637
638
 
638
639
  it "should have simple_table inherit superclass's setting" do
639
- Class.new(@c).simple_table.should == nil
640
+ Class.new(@c).simple_table.must_equal nil
640
641
  @c.set_dataset :a
641
- Class.new(@c).simple_table.should == '"a"'
642
+ Class.new(@c).simple_table.must_equal '"a"'
642
643
  end
643
644
 
644
645
  it "should use Dataset#with_sql if simple_table and simple_pk are true" do
645
646
  @c.set_dataset :a
646
647
  @c.instance_dataset._fetch = @c.dataset._fetch = {:id => 1}
647
- @c[1].should == @c.load(:id=>1)
648
- @db.sqls.should == ['SELECT * FROM "a" WHERE "id" = 1']
648
+ @c[1].must_equal @c.load(:id=>1)
649
+ @db.sqls.must_equal ['SELECT * FROM "a" WHERE "id" = 1']
649
650
  end
650
651
 
651
652
  it "should not use Dataset#with_sql if either simple_table or simple_pk is nil" do
652
653
  @c.set_dataset @db[:a].filter(:active)
653
654
  @c.dataset._fetch = {:id => 1}
654
- @c[1].should == @c.load(:id=>1)
655
- @db.sqls.should == ['SELECT * FROM "a" WHERE ("active" AND ("id" = 1)) LIMIT 1']
655
+ @c[1].must_equal @c.load(:id=>1)
656
+ @db.sqls.must_equal ['SELECT * FROM "a" WHERE ("active" AND ("id" = 1)) LIMIT 1']
656
657
  end
657
658
  end
658
659
 
@@ -665,31 +666,31 @@ describe "Model datasets #with_pk with #with_pk!" do
665
666
  end
666
667
 
667
668
  it "should be callable on the model class with optimized SQL" do
668
- @c.with_pk(1).should == @c.load(:id=>1)
669
- DB.sqls.should == ["SELECT * FROM a WHERE id = 1"]
670
- @c.with_pk!(1).should == @c.load(:id=>1)
671
- DB.sqls.should == ["SELECT * FROM a WHERE id = 1"]
669
+ @c.with_pk(1).must_equal @c.load(:id=>1)
670
+ DB.sqls.must_equal ["SELECT * FROM a WHERE id = 1"]
671
+ @c.with_pk!(1).must_equal @c.load(:id=>1)
672
+ DB.sqls.must_equal ["SELECT * FROM a WHERE id = 1"]
672
673
  end
673
674
 
674
675
  it "should return the first record where the primary key matches" do
675
- @ds.with_pk(1).should == @c.load(:id=>1)
676
- DB.sqls.should == ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
677
- @ds.with_pk!(1).should == @c.load(:id=>1)
678
- DB.sqls.should == ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
676
+ @ds.with_pk(1).must_equal @c.load(:id=>1)
677
+ DB.sqls.must_equal ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
678
+ @ds.with_pk!(1).must_equal @c.load(:id=>1)
679
+ DB.sqls.must_equal ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
679
680
  end
680
681
 
681
682
  it "should handle existing filters" do
682
683
  @ds.filter(:a=>2).with_pk(1)
683
- DB.sqls.should == ["SELECT * FROM a WHERE ((a = 2) AND (a.id = 1)) LIMIT 1"]
684
+ DB.sqls.must_equal ["SELECT * FROM a WHERE ((a = 2) AND (a.id = 1)) LIMIT 1"]
684
685
  @ds.filter(:a=>2).with_pk!(1)
685
- DB.sqls.should == ["SELECT * FROM a WHERE ((a = 2) AND (a.id = 1)) LIMIT 1"]
686
+ DB.sqls.must_equal ["SELECT * FROM a WHERE ((a = 2) AND (a.id = 1)) LIMIT 1"]
686
687
  end
687
688
 
688
689
  it "should work with string values" do
689
690
  @ds.with_pk("foo")
690
- DB.sqls.should == ["SELECT * FROM a WHERE (a.id = 'foo') LIMIT 1"]
691
+ DB.sqls.must_equal ["SELECT * FROM a WHERE (a.id = 'foo') LIMIT 1"]
691
692
  @ds.with_pk!("foo")
692
- DB.sqls.should == ["SELECT * FROM a WHERE (a.id = 'foo') LIMIT 1"]
693
+ DB.sqls.must_equal ["SELECT * FROM a WHERE (a.id = 'foo') LIMIT 1"]
693
694
  end
694
695
 
695
696
  it "should handle an array for composite primary keys" do
@@ -697,40 +698,40 @@ describe "Model datasets #with_pk with #with_pk!" do
697
698
  @ds.with_pk([1, 2])
698
699
  sqls = DB.sqls
699
700
  ["SELECT * FROM a WHERE ((a.id1 = 1) AND (a.id2 = 2)) LIMIT 1",
700
- "SELECT * FROM a WHERE ((a.id2 = 2) AND (a.id1 = 1)) LIMIT 1"].should include(sqls.pop)
701
- sqls.should == []
701
+ "SELECT * FROM a WHERE ((a.id2 = 2) AND (a.id1 = 1)) LIMIT 1"].must_include(sqls.pop)
702
+ sqls.must_equal []
702
703
 
703
704
  @ds.with_pk!([1, 2])
704
705
  sqls = DB.sqls
705
706
  ["SELECT * FROM a WHERE ((a.id1 = 1) AND (a.id2 = 2)) LIMIT 1",
706
- "SELECT * FROM a WHERE ((a.id2 = 2) AND (a.id1 = 1)) LIMIT 1"].should include(sqls.pop)
707
- sqls.should == []
707
+ "SELECT * FROM a WHERE ((a.id2 = 2) AND (a.id1 = 1)) LIMIT 1"].must_include(sqls.pop)
708
+ sqls.must_equal []
708
709
  end
709
710
 
710
711
  it "should have with_pk return nil and with_pk! raise if no rows match" do
711
712
  @ds._fetch = []
712
- @ds.with_pk(1).should == nil
713
- DB.sqls.should == ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
714
- proc{@ds.with_pk!(1)}.should raise_error(Sequel::NoMatchingRow)
715
- DB.sqls.should == ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
713
+ @ds.with_pk(1).must_equal nil
714
+ DB.sqls.must_equal ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
715
+ proc{@ds.with_pk!(1)}.must_raise(Sequel::NoMatchingRow)
716
+ DB.sqls.must_equal ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
716
717
  end
717
718
 
718
719
  it "should have with_pk return nil and with_pk! raise if no rows match when calling the class method" do
719
720
  @ds._fetch = []
720
- @c.with_pk(1).should == nil
721
- DB.sqls.should == ["SELECT * FROM a WHERE id = 1"]
722
- proc{@c.with_pk!(1)}.should raise_error(Sequel::NoMatchingRow)
723
- DB.sqls.should == ["SELECT * FROM a WHERE id = 1"]
721
+ @c.with_pk(1).must_equal nil
722
+ DB.sqls.must_equal ["SELECT * FROM a WHERE id = 1"]
723
+ proc{@c.with_pk!(1)}.must_raise(Sequel::NoMatchingRow)
724
+ DB.sqls.must_equal ["SELECT * FROM a WHERE id = 1"]
724
725
  end
725
726
 
726
727
  it "should have #[] consider an integer as a primary key lookup" do
727
- @ds[1].should == @c.load(:id=>1)
728
- DB.sqls.should == ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
728
+ @ds[1].must_equal @c.load(:id=>1)
729
+ DB.sqls.must_equal ["SELECT * FROM a WHERE (a.id = 1) LIMIT 1"]
729
730
  end
730
731
 
731
732
  it "should not have #[] consider a string as a primary key lookup" do
732
- @ds['foo'].should == @c.load(:id=>1)
733
- DB.sqls.should == ["SELECT * FROM a WHERE (foo) LIMIT 1"]
733
+ @ds['foo'].must_equal @c.load(:id=>1)
734
+ DB.sqls.must_equal ["SELECT * FROM a WHERE (foo) LIMIT 1"]
734
735
  end
735
736
  end
736
737
 
@@ -741,6 +742,6 @@ describe "Model::include" do
741
742
  including_class = Class.new(Sequel::Model(:items)) do
742
743
  include(mod1, mod2)
743
744
  end
744
- including_class.included_modules.should include(mod1, mod2)
745
+ including_class.included_modules.must_include(mod1, mod2)
745
746
  end
746
747
  end