sequel 4.22.0 → 4.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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
@@ -12,17 +12,17 @@ describe Sequel::Model, "hook_class_methods plugin" do
12
12
  DB.reset
13
13
  end
14
14
 
15
- specify "should be definable using a block" do
15
+ it "should be definable using a block" do
16
16
  adds = []
17
17
  c = model_class.call Sequel::Model do
18
18
  before_save{adds << 'hi'}
19
19
  end
20
20
 
21
21
  c.new.before_save
22
- adds.should == ['hi']
22
+ adds.must_equal ['hi']
23
23
  end
24
24
 
25
- specify "should be definable using a method name" do
25
+ it "should be definable using a method name" do
26
26
  adds = []
27
27
  c = model_class.call Sequel::Model do
28
28
  define_method(:bye){adds << 'bye'}
@@ -30,10 +30,10 @@ describe Sequel::Model, "hook_class_methods plugin" do
30
30
  end
31
31
 
32
32
  c.new.before_save
33
- adds.should == ['bye']
33
+ adds.must_equal ['bye']
34
34
  end
35
35
 
36
- specify "should be additive" do
36
+ it "should be additive" do
37
37
  adds = []
38
38
  c = model_class.call Sequel::Model do
39
39
  after_save{adds << 'hyiyie'}
@@ -41,10 +41,10 @@ describe Sequel::Model, "hook_class_methods plugin" do
41
41
  end
42
42
 
43
43
  c.new.after_save
44
- adds.should == ['hyiyie', 'byiyie']
44
+ adds.must_equal ['hyiyie', 'byiyie']
45
45
  end
46
46
 
47
- specify "before hooks should run in reverse order" do
47
+ it "before hooks should run in reverse order" do
48
48
  adds = []
49
49
  c = model_class.call Sequel::Model do
50
50
  before_save{adds << 'hyiyie'}
@@ -52,10 +52,10 @@ describe Sequel::Model, "hook_class_methods plugin" do
52
52
  end
53
53
 
54
54
  c.new.before_save
55
- adds.should == ['byiyie', 'hyiyie']
55
+ adds.must_equal ['byiyie', 'hyiyie']
56
56
  end
57
57
 
58
- specify "should not be additive if the method or tag already exists" do
58
+ it "should not be additive if the method or tag already exists" do
59
59
  adds = []
60
60
  c = model_class.call Sequel::Model do
61
61
  define_method(:bye){adds << 'bye'}
@@ -64,7 +64,7 @@ describe Sequel::Model, "hook_class_methods plugin" do
64
64
  end
65
65
 
66
66
  c.new.before_save
67
- adds.should == ['bye']
67
+ adds.must_equal ['bye']
68
68
 
69
69
  adds = []
70
70
  d = model_class.call Sequel::Model do
@@ -73,7 +73,7 @@ describe Sequel::Model, "hook_class_methods plugin" do
73
73
  end
74
74
 
75
75
  d.new.before_save
76
- adds.should == ['byiyie']
76
+ adds.must_equal ['byiyie']
77
77
 
78
78
  adds = []
79
79
  e = model_class.call Sequel::Model do
@@ -83,7 +83,7 @@ describe Sequel::Model, "hook_class_methods plugin" do
83
83
  end
84
84
 
85
85
  e.new.before_save
86
- adds.should == ['byiyie']
86
+ adds.must_equal ['byiyie']
87
87
 
88
88
  adds = []
89
89
  e = model_class.call Sequel::Model do
@@ -93,10 +93,10 @@ describe Sequel::Model, "hook_class_methods plugin" do
93
93
  end
94
94
 
95
95
  e.new.before_save
96
- adds.should == ['bye']
96
+ adds.must_equal ['bye']
97
97
  end
98
98
 
99
- specify "should be inheritable" do
99
+ it "should be inheritable" do
100
100
  adds = []
101
101
  a = model_class.call Sequel::Model do
102
102
  after_save{adds << '123'}
@@ -109,10 +109,10 @@ describe Sequel::Model, "hook_class_methods plugin" do
109
109
  end
110
110
 
111
111
  b.new.after_save
112
- adds.should == ['123', '456', '789']
112
+ adds.must_equal ['123', '456', '789']
113
113
  end
114
114
 
115
- specify "should be overridable in descendant classes" do
115
+ it "should be overridable in descendant classes" do
116
116
  adds = []
117
117
  a = model_class.call Sequel::Model do
118
118
  before_save{adds << '123'}
@@ -124,13 +124,13 @@ describe Sequel::Model, "hook_class_methods plugin" do
124
124
  end
125
125
 
126
126
  a.new.before_save
127
- adds.should == ['123']
127
+ adds.must_equal ['123']
128
128
  adds = []
129
129
  b.new.before_save
130
- adds.should == ['456']
130
+ adds.must_equal ['456']
131
131
  end
132
132
 
133
- specify "should stop processing if a before hook returns false" do
133
+ it "should stop processing if a before hook returns false" do
134
134
  flag = true
135
135
  adds = []
136
136
 
@@ -140,18 +140,18 @@ describe Sequel::Model, "hook_class_methods plugin" do
140
140
  end
141
141
 
142
142
  a.new.before_save
143
- adds.should == ['blah', 'cruel']
143
+ adds.must_equal ['blah', 'cruel']
144
144
 
145
145
  # chain should not break on nil
146
146
  adds = []
147
147
  flag = nil
148
148
  a.new.before_save
149
- adds.should == ['blah', 'cruel']
149
+ adds.must_equal ['blah', 'cruel']
150
150
 
151
151
  adds = []
152
152
  flag = false
153
153
  a.new.before_save
154
- adds.should == ['blah']
154
+ adds.must_equal ['blah']
155
155
 
156
156
  b = Class.new(a)
157
157
  b.class_eval do
@@ -160,7 +160,7 @@ describe Sequel::Model, "hook_class_methods plugin" do
160
160
 
161
161
  adds = []
162
162
  b.new.before_save
163
- adds.should == ['mau', 'blah']
163
+ adds.must_equal ['mau', 'blah']
164
164
  end
165
165
  end
166
166
 
@@ -176,36 +176,36 @@ describe "Model#before_create && Model#after_create" do
176
176
  end
177
177
  end
178
178
 
179
- specify "should be called around new record creation" do
179
+ it "should be called around new record creation" do
180
180
  @c.before_create {DB << "BLAH before"}
181
181
  @c.create(:x => 2)
182
- DB.sqls.should == ['BLAH before', 'INSERT INTO items (x) VALUES (2)', 'BLAH after']
182
+ DB.sqls.must_equal ['BLAH before', 'INSERT INTO items (x) VALUES (2)', 'BLAH after']
183
183
  end
184
184
 
185
- specify ".create should cancel the save and raise an error if before_create returns false and raise_on_save_failure is true" do
185
+ it ".create should cancel the save and raise an error if before_create returns false and raise_on_save_failure is true" do
186
186
  @c.before_create{false}
187
- proc{@c.create(:x => 2)}.should raise_error(Sequel::HookFailed)
188
- DB.sqls.should == []
187
+ proc{@c.create(:x => 2)}.must_raise(Sequel::HookFailed)
188
+ DB.sqls.must_equal []
189
189
  end
190
190
 
191
- specify ".create should cancel the save and raise an error if before_create calls cancel_action and raise_on_save_failure is true" do
191
+ it ".create should cancel the save and raise an error if before_create calls cancel_action and raise_on_save_failure is true" do
192
192
  @c.before_create{cancel_action}
193
- proc{@c.create(:x => 2)}.should raise_error(Sequel::HookFailed)
194
- DB.sqls.should == []
193
+ proc{@c.create(:x => 2)}.must_raise(Sequel::HookFailed)
194
+ DB.sqls.must_equal []
195
195
  end
196
196
 
197
- specify ".create should cancel the save and return nil if before_create returns false and raise_on_save_failure is false" do
197
+ it ".create should cancel the save and return nil if before_create returns false and raise_on_save_failure is false" do
198
198
  @c.before_create{false}
199
199
  @c.raise_on_save_failure = false
200
- @c.create(:x => 2).should == nil
201
- DB.sqls.should == []
200
+ @c.create(:x => 2).must_equal nil
201
+ DB.sqls.must_equal []
202
202
  end
203
203
 
204
- specify ".create should cancel the save and return nil if before_create calls cancel_action and raise_on_save_failure is false" do
204
+ it ".create should cancel the save and return nil if before_create calls cancel_action and raise_on_save_failure is false" do
205
205
  @c.before_create{cancel_action}
206
206
  @c.raise_on_save_failure = false
207
- @c.create(:x => 2).should == nil
208
- DB.sqls.should == []
207
+ @c.create(:x => 2).must_equal nil
208
+ DB.sqls.must_equal []
209
209
  end
210
210
  end
211
211
 
@@ -218,24 +218,24 @@ describe "Model#before_update && Model#after_update" do
218
218
  end
219
219
  end
220
220
 
221
- specify "should be called around record update" do
221
+ it "should be called around record update" do
222
222
  @c.before_update {DB << "BLAH before"}
223
223
  m = @c.load(:id => 2233, :x=>123)
224
224
  m.save
225
- DB.sqls.should == ['BLAH before', 'UPDATE items SET x = 123 WHERE (id = 2233)', 'BLAH after']
225
+ DB.sqls.must_equal ['BLAH before', 'UPDATE items SET x = 123 WHERE (id = 2233)', 'BLAH after']
226
226
  end
227
227
 
228
- specify "#save should cancel the save and raise an error if before_update returns false and raise_on_save_failure is true" do
228
+ it "#save should cancel the save and raise an error if before_update returns false and raise_on_save_failure is true" do
229
229
  @c.before_update{false}
230
- proc{@c.load(:id => 2233).save}.should raise_error(Sequel::HookFailed)
231
- DB.sqls.should == []
230
+ proc{@c.load(:id => 2233).save}.must_raise(Sequel::HookFailed)
231
+ DB.sqls.must_equal []
232
232
  end
233
233
 
234
- specify "#save should cancel the save and return nil if before_update returns false and raise_on_save_failure is false" do
234
+ it "#save should cancel the save and return nil if before_update returns false and raise_on_save_failure is false" do
235
235
  @c.before_update{false}
236
236
  @c.raise_on_save_failure = false
237
- @c.load(:id => 2233).save.should == nil
238
- DB.sqls.should == []
237
+ @c.load(:id => 2233).save.must_equal nil
238
+ DB.sqls.must_equal []
239
239
  end
240
240
  end
241
241
 
@@ -249,31 +249,31 @@ describe "Model#before_save && Model#after_save" do
249
249
  end
250
250
  end
251
251
 
252
- specify "should be called around record update" do
252
+ it "should be called around record update" do
253
253
  @c.before_save {DB << "BLAH before"}
254
254
  m = @c.load(:id => 2233, :x=>123)
255
255
  m.save
256
- DB.sqls.should == ['BLAH before', 'UPDATE items SET x = 123 WHERE (id = 2233)', 'BLAH after']
256
+ DB.sqls.must_equal ['BLAH before', 'UPDATE items SET x = 123 WHERE (id = 2233)', 'BLAH after']
257
257
  end
258
258
 
259
- specify "should be called around record creation" do
259
+ it "should be called around record creation" do
260
260
  @c.before_save {DB << "BLAH before"}
261
261
  @c.no_primary_key
262
262
  @c.create(:x => 2)
263
- DB.sqls.should == ['BLAH before', 'INSERT INTO items (x) VALUES (2)', 'BLAH after']
263
+ DB.sqls.must_equal ['BLAH before', 'INSERT INTO items (x) VALUES (2)', 'BLAH after']
264
264
  end
265
265
 
266
- specify "#save should cancel the save and raise an error if before_save returns false and raise_on_save_failure is true" do
266
+ it "#save should cancel the save and raise an error if before_save returns false and raise_on_save_failure is true" do
267
267
  @c.before_save{false}
268
- proc{@c.load(:id => 2233).save}.should raise_error(Sequel::HookFailed)
269
- DB.sqls.should == []
268
+ proc{@c.load(:id => 2233).save}.must_raise(Sequel::HookFailed)
269
+ DB.sqls.must_equal []
270
270
  end
271
271
 
272
- specify "#save should cancel the save and return nil if before_save returns false and raise_on_save_failure is false" do
272
+ it "#save should cancel the save and return nil if before_save returns false and raise_on_save_failure is false" do
273
273
  @c.before_save{false}
274
274
  @c.raise_on_save_failure = false
275
- @c.load(:id => 2233).save.should == nil
276
- DB.sqls.should == []
275
+ @c.load(:id => 2233).save.must_equal nil
276
+ DB.sqls.must_equal []
277
277
  end
278
278
  end
279
279
 
@@ -286,24 +286,24 @@ describe "Model#before_destroy && Model#after_destroy" do
286
286
  end
287
287
  end
288
288
 
289
- specify "should be called around record destruction" do
289
+ it "should be called around record destruction" do
290
290
  @c.before_destroy {DB << "BLAH before"}
291
291
  m = @c.load(:id => 2233)
292
292
  m.destroy
293
- DB.sqls.should == ['BLAH before', "DELETE FROM items WHERE id = 2233", 'BLAH after']
293
+ DB.sqls.must_equal ['BLAH before', "DELETE FROM items WHERE id = 2233", 'BLAH after']
294
294
  end
295
295
 
296
- specify "#destroy should cancel the destroy and raise an error if before_destroy returns false and raise_on_save_failure is true" do
296
+ it "#destroy should cancel the destroy and raise an error if before_destroy returns false and raise_on_save_failure is true" do
297
297
  @c.before_destroy{false}
298
- proc{@c.load(:id => 2233).destroy}.should raise_error(Sequel::HookFailed)
299
- DB.sqls.should == []
298
+ proc{@c.load(:id => 2233).destroy}.must_raise(Sequel::HookFailed)
299
+ DB.sqls.must_equal []
300
300
  end
301
301
 
302
- specify "#destroy should cancel the destroy and return nil if before_destroy returns false and raise_on_save_failure is false" do
302
+ it "#destroy should cancel the destroy and return nil if before_destroy returns false and raise_on_save_failure is false" do
303
303
  @c.before_destroy{false}
304
304
  @c.raise_on_save_failure = false
305
- @c.load(:id => 2233).destroy.should == nil
306
- DB.sqls.should == []
305
+ @c.load(:id => 2233).destroy.must_equal nil
306
+ DB.sqls.must_equal []
307
307
  end
308
308
  end
309
309
 
@@ -322,42 +322,42 @@ describe "Model#before_validation && Model#after_validation" do
322
322
  end
323
323
  end
324
324
 
325
- specify "should be called around validation" do
325
+ it "should be called around validation" do
326
326
  @c.before_validation{DB << "BLAH before"}
327
327
  m = @c.load(:id => 2233)
328
- m.should be_valid
329
- DB.sqls.should == ['BLAH before', 'BLAH after']
328
+ m.must_be :valid?
329
+ DB.sqls.must_equal ['BLAH before', 'BLAH after']
330
330
 
331
331
  DB.sqls.clear
332
332
  m = @c.load(:id => 22)
333
- m.should_not be_valid
334
- DB.sqls.should == ['BLAH before', 'BLAH after']
333
+ m.wont_be :valid?
334
+ DB.sqls.must_equal ['BLAH before', 'BLAH after']
335
335
  end
336
336
 
337
- specify "should be called when calling save" do
337
+ it "should be called when calling save" do
338
338
  @c.before_validation{DB << "BLAH before"}
339
339
  m = @c.load(:id => 2233, :x=>123)
340
- m.save.should == m
341
- DB.sqls.should == ['BLAH before', 'BLAH after', 'UPDATE items SET x = 123 WHERE (id = 2233)']
340
+ m.save.must_equal m
341
+ DB.sqls.must_equal ['BLAH before', 'BLAH after', 'UPDATE items SET x = 123 WHERE (id = 2233)']
342
342
 
343
343
  DB.sqls.clear
344
344
  m = @c.load(:id => 22)
345
345
  m.raise_on_save_failure = false
346
- m.save.should == nil
347
- DB.sqls.should == ['BLAH before', 'BLAH after']
346
+ m.save.must_equal nil
347
+ DB.sqls.must_equal ['BLAH before', 'BLAH after']
348
348
  end
349
349
 
350
- specify "#save should cancel the save and raise an error if before_validation returns false and raise_on_save_failure is true" do
350
+ it "#save should cancel the save and raise an error if before_validation returns false and raise_on_save_failure is true" do
351
351
  @c.before_validation{false}
352
- proc{@c.load(:id => 2233).save}.should raise_error(Sequel::HookFailed)
353
- DB.sqls.should == []
352
+ proc{@c.load(:id => 2233).save}.must_raise(Sequel::HookFailed)
353
+ DB.sqls.must_equal []
354
354
  end
355
355
 
356
- specify "#save should cancel the save and return nil if before_validation returns false and raise_on_save_failure is false" do
356
+ it "#save should cancel the save and return nil if before_validation returns false and raise_on_save_failure is false" do
357
357
  @c.before_validation{false}
358
358
  @c.raise_on_save_failure = false
359
- @c.load(:id => 2233).save.should == nil
360
- DB.sqls.should == []
359
+ @c.load(:id => 2233).save.must_equal nil
360
+ DB.sqls.must_equal []
361
361
  end
362
362
  end
363
363
 
@@ -366,18 +366,18 @@ describe "Model.has_hooks?" do
366
366
  @c = model_class.call(Sequel::Model(:items))
367
367
  end
368
368
 
369
- specify "should return false if no hooks are defined" do
370
- @c.has_hooks?(:before_save).should == false
369
+ it "should return false if no hooks are defined" do
370
+ @c.has_hooks?(:before_save).must_equal false
371
371
  end
372
372
 
373
- specify "should return true if hooks are defined" do
373
+ it "should return true if hooks are defined" do
374
374
  @c.before_save {'blah'}
375
- @c.has_hooks?(:before_save).should == true
375
+ @c.has_hooks?(:before_save).must_equal true
376
376
  end
377
377
 
378
- specify "should return true if hooks are inherited" do
378
+ it "should return true if hooks are inherited" do
379
379
  @d = Class.new(@c)
380
- @d.has_hooks?(:before_save).should == false
380
+ @d.has_hooks?(:before_save).must_equal false
381
381
  end
382
382
  end
383
383
 
@@ -399,31 +399,31 @@ describe "Model#add_hook_type" do
399
399
  Object.send(:remove_const, :Foo)
400
400
  end
401
401
 
402
- specify "should have before_bar and after_bar class methods" do
403
- @f.should respond_to(:before_bar)
404
- @f.should respond_to(:before_bar)
402
+ it "should have before_bar and after_bar class methods" do
403
+ @f.must_respond_to(:before_bar)
404
+ @f.must_respond_to(:before_bar)
405
405
  end
406
406
 
407
- specify "should have before_bar and after_bar instance methods" do
408
- @f.new.should respond_to(:before_bar)
409
- @f.new.should respond_to(:before_bar)
407
+ it "should have before_bar and after_bar instance methods" do
408
+ @f.new.must_respond_to(:before_bar)
409
+ @f.new.must_respond_to(:before_bar)
410
410
  end
411
411
 
412
- specify "it should return true for bar when before_bar and after_bar hooks are returing true" do
412
+ it "it should return true for bar when before_bar and after_bar hooks are returing true" do
413
413
  a = 1
414
414
  @f.before_bar { a += 1}
415
- @f.new.bar.should == true
416
- a.should == 2
415
+ @f.new.bar.must_equal true
416
+ a.must_equal 2
417
417
  @f.after_bar { a *= 2}
418
- @f.new.bar.should == true
419
- a.should == 6
418
+ @f.new.bar.must_equal true
419
+ a.must_equal 6
420
420
  end
421
421
 
422
- specify "it should return nil for bar when before_bar and after_bar hooks are returing false" do
423
- @f.new.bar.should == true
422
+ it "it should return nil for bar when before_bar and after_bar hooks are returing false" do
423
+ @f.new.bar.must_equal true
424
424
  @f.after_bar { false }
425
- @f.new.bar.should == :a
425
+ @f.new.bar.must_equal :a
426
426
  @f.before_bar { false }
427
- @f.new.bar.should == :b
427
+ @f.new.bar.must_equal :b
428
428
  end
429
429
  end
@@ -4,79 +4,79 @@ Sequel.extension :inflector
4
4
 
5
5
  describe String do
6
6
  it "#camelize and #camelcase should transform the word to CamelCase" do
7
- "egg_and_hams".camelize.should == "EggAndHams"
8
- "egg_and_hams".camelize(false).should == "eggAndHams"
9
- "post".camelize.should == "Post"
10
- "post".camelcase.should == "Post"
7
+ "egg_and_hams".camelize.must_equal "EggAndHams"
8
+ "egg_and_hams".camelize(false).must_equal "eggAndHams"
9
+ "post".camelize.must_equal "Post"
10
+ "post".camelcase.must_equal "Post"
11
11
  end
12
12
 
13
13
  it "#constantize should eval the string to get a constant" do
14
- "String".constantize.should == String
15
- "String::Inflections".constantize.should == String::Inflections
16
- proc{"BKSDDF".constantize}.should raise_error
17
- proc{"++A++".constantize}.should raise_error
14
+ "String".constantize.must_equal String
15
+ "String::Inflections".constantize.must_equal String::Inflections
16
+ proc{"BKSDDF".constantize}.must_raise NameError
17
+ proc{"++A++".constantize}.must_raise NameError
18
18
  end
19
19
 
20
20
  it "#dasherize should transform underscores to dashes" do
21
- "egg_and_hams".dasherize.should == "egg-and-hams"
22
- "post".dasherize.should == "post"
21
+ "egg_and_hams".dasherize.must_equal "egg-and-hams"
22
+ "post".dasherize.must_equal "post"
23
23
  end
24
24
 
25
25
  it "#demodulize should remove any preceding modules" do
26
- "String::Inflections::Blah".demodulize.should == "Blah"
27
- "String::Inflections".demodulize.should == "Inflections"
28
- "String".demodulize.should == "String"
26
+ "String::Inflections::Blah".demodulize.must_equal "Blah"
27
+ "String::Inflections".demodulize.must_equal "Inflections"
28
+ "String".demodulize.must_equal "String"
29
29
  end
30
30
 
31
31
  it "#humanize should remove _i, transform underscore to spaces, and capitalize" do
32
- "egg_and_hams".humanize.should == "Egg and hams"
33
- "post".humanize.should == "Post"
34
- "post_id".humanize.should == "Post"
32
+ "egg_and_hams".humanize.must_equal "Egg and hams"
33
+ "post".humanize.must_equal "Post"
34
+ "post_id".humanize.must_equal "Post"
35
35
  end
36
36
 
37
37
  it "#titleize and #titlecase should underscore, humanize, and capitalize all words" do
38
- "egg-and: hams".titleize.should == "Egg And: Hams"
39
- "post".titleize.should == "Post"
40
- "post".titlecase.should == "Post"
38
+ "egg-and: hams".titleize.must_equal "Egg And: Hams"
39
+ "post".titleize.must_equal "Post"
40
+ "post".titlecase.must_equal "Post"
41
41
  end
42
42
 
43
43
  it "#underscore should add underscores between CamelCased words, change :: to / and - to _, and downcase" do
44
- "EggAndHams".underscore.should == "egg_and_hams"
45
- "EGGAndHams".underscore.should == "egg_and_hams"
46
- "Egg::And::Hams".underscore.should == "egg/and/hams"
47
- "post".underscore.should == "post"
48
- "post-id".underscore.should == "post_id"
44
+ "EggAndHams".underscore.must_equal "egg_and_hams"
45
+ "EGGAndHams".underscore.must_equal "egg_and_hams"
46
+ "Egg::And::Hams".underscore.must_equal "egg/and/hams"
47
+ "post".underscore.must_equal "post"
48
+ "post-id".underscore.must_equal "post_id"
49
49
  end
50
50
 
51
51
  it "#pluralize should transform words from singular to plural" do
52
- "post".pluralize.should == "posts"
53
- "octopus".pluralize.should =="octopuses"
54
- "the blue mailman".pluralize.should == "the blue mailmen"
55
- "CamelOctopus".pluralize.should == "CamelOctopuses"
52
+ "post".pluralize.must_equal "posts"
53
+ "octopus".pluralize.must_equal"octopuses"
54
+ "the blue mailman".pluralize.must_equal "the blue mailmen"
55
+ "CamelOctopus".pluralize.must_equal "CamelOctopuses"
56
56
  end
57
57
 
58
58
  it "#singularize should transform words from plural to singular" do
59
- "posts".singularize.should == "post"
60
- "octopuses".singularize.should == "octopus"
61
- "the blue mailmen".singularize.should == "the blue mailman"
62
- "CamelOctopuses".singularize.should == "CamelOctopus"
59
+ "posts".singularize.must_equal "post"
60
+ "octopuses".singularize.must_equal "octopus"
61
+ "the blue mailmen".singularize.must_equal "the blue mailman"
62
+ "CamelOctopuses".singularize.must_equal "CamelOctopus"
63
63
  end
64
64
 
65
65
  it "#tableize should transform class names to table names" do
66
- "RawScaledScorer".tableize.should == "raw_scaled_scorers"
67
- "egg_and_ham".tableize.should == "egg_and_hams"
68
- "fancyCategory".tableize.should == "fancy_categories"
66
+ "RawScaledScorer".tableize.must_equal "raw_scaled_scorers"
67
+ "egg_and_ham".tableize.must_equal "egg_and_hams"
68
+ "fancyCategory".tableize.must_equal "fancy_categories"
69
69
  end
70
70
 
71
71
  it "#classify should tranform table names to class names" do
72
- "egg_and_hams".classify.should == "EggAndHam"
73
- "post".classify.should == "Post"
72
+ "egg_and_hams".classify.must_equal "EggAndHam"
73
+ "post".classify.must_equal "Post"
74
74
  end
75
75
 
76
76
  it "#foreign_key should create a foreign key name from a class name" do
77
- "Message".foreign_key.should == "message_id"
78
- "Message".foreign_key(false).should == "messageid"
79
- "Admin::Post".foreign_key.should == "post_id"
77
+ "Message".foreign_key.must_equal "message_id"
78
+ "Message".foreign_key(false).must_equal "messageid"
79
+ "Admin::Post".foreign_key.must_equal "post_id"
80
80
  end
81
81
  end
82
82
 
@@ -92,12 +92,12 @@ describe String::Inflections do
92
92
 
93
93
  it "should be possible to clear the list of singulars, plurals, and uncountables" do
94
94
  String.inflections.clear(:plurals)
95
- String.inflections.plurals.should == []
95
+ String.inflections.plurals.must_equal []
96
96
  String.inflections.plural('blah', 'blahs')
97
97
  String.inflections.clear
98
- String.inflections.plurals.should == []
99
- String.inflections.singulars.should == []
100
- String.inflections.uncountables.should == []
98
+ String.inflections.plurals.must_equal []
99
+ String.inflections.singulars.must_equal []
100
+ String.inflections.uncountables.must_equal []
101
101
  end
102
102
 
103
103
  it "should be able to specify new inflection rules" do
@@ -107,16 +107,16 @@ describe String::Inflections do
107
107
  i.irregular('yy', 'yyy')
108
108
  i.uncountable(%w'zz')
109
109
  end
110
- 'roxx'.pluralize.should == 'roxxx'
111
- 'rottt'.singularize.should == 'rott'
112
- 'yy'.pluralize.should == 'yyy'
113
- 'yyy'.singularize.should == 'yy'
114
- 'zz'.pluralize.should == 'zz'
115
- 'zz'.singularize.should == 'zz'
110
+ 'roxx'.pluralize.must_equal 'roxxx'
111
+ 'rottt'.singularize.must_equal 'rott'
112
+ 'yy'.pluralize.must_equal 'yyy'
113
+ 'yyy'.singularize.must_equal 'yy'
114
+ 'zz'.pluralize.must_equal 'zz'
115
+ 'zz'.singularize.must_equal 'zz'
116
116
  end
117
117
 
118
118
  it "should be yielded and returned by String.inflections" do
119
- String.inflections{|i| i.should == String::Inflections}.should == String::Inflections
119
+ String.inflections{|i| i.must_equal String::Inflections}.must_equal String::Inflections
120
120
  end
121
121
  end
122
122
 
@@ -173,11 +173,11 @@ describe 'Default inflections' do
173
173
  :sex=>:sexes,
174
174
  :move=>:moves
175
175
  }.each do |k, v|
176
- k.to_s.pluralize.should == v.to_s
177
- v.to_s.singularize.should == k.to_s
176
+ k.to_s.pluralize.must_equal v.to_s
177
+ v.to_s.singularize.must_equal k.to_s
178
178
  end
179
179
  [:equipment, :information, :rice, :money, :species, :series, :fish, :sheep, :news].each do |a|
180
- a.to_s.pluralize.should == a.to_s.singularize
180
+ a.to_s.pluralize.must_equal a.to_s.singularize
181
181
  end
182
182
  end
183
183
  end