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
@@ -12,50 +12,50 @@ describe "serialization_modification_detection plugin" do
12
12
  end
13
13
 
14
14
  it "should only detect columns that have been changed" do
15
- @o.changed_columns.should == []
15
+ @o.changed_columns.must_equal []
16
16
  @o.a << 'b'
17
- @o.changed_columns.should == [:a]
17
+ @o.changed_columns.must_equal [:a]
18
18
  @o.a.replace('a')
19
- @o.changed_columns.should == []
19
+ @o.changed_columns.must_equal []
20
20
 
21
21
  @o.values[:b] = 2
22
- @o.changed_columns.should == [:b]
22
+ @o.changed_columns.must_equal [:b]
23
23
  @o.values[:b] = 1
24
- @o.changed_columns.should == []
24
+ @o.changed_columns.must_equal []
25
25
 
26
26
  @o.c[0] << 'b'
27
27
  @o.d['b'] << 'b'
28
- @o.changed_columns.sort_by{|c| c.to_s}.should == [:c, :d]
28
+ @o.changed_columns.sort_by{|c| c.to_s}.must_equal [:c, :d]
29
29
  @o.c[0] = 'a'
30
- @o.changed_columns.should == [:d]
30
+ @o.changed_columns.must_equal [:d]
31
31
  @o.d['b'] = 'c'
32
- @o.changed_columns.should == []
32
+ @o.changed_columns.must_equal []
33
33
  end
34
34
 
35
35
  it "should not list a column twice" do
36
36
  @o.a = 'b'
37
37
  @o.a << 'a'
38
- @o.changed_columns.should == [:a]
38
+ @o.changed_columns.must_equal [:a]
39
39
  end
40
40
 
41
41
  it "should report correct changed_columns after updating" do
42
42
  @o.a << 'a'
43
43
  @o.save_changes
44
- @o.changed_columns.should == []
44
+ @o.changed_columns.must_equal []
45
45
 
46
46
  @o.values[:b] = 2
47
47
  @o.save_changes
48
- @o.changed_columns.should == []
48
+ @o.changed_columns.must_equal []
49
49
 
50
50
  @o.c[0] << 'b'
51
51
  @o.save_changes
52
- @o.changed_columns.should == []
52
+ @o.changed_columns.must_equal []
53
53
 
54
54
  @o.d['b'] << 'a'
55
55
  @o.save_changes
56
- @o.changed_columns.should == []
56
+ @o.changed_columns.must_equal []
57
57
 
58
- @ds.db.sqls.should == ["UPDATE items SET a = 'aa' WHERE (id = 1)",
58
+ @ds.db.sqls.must_equal ["UPDATE items SET a = 'aa' WHERE (id = 1)",
59
59
  "UPDATE items SET b = 2 WHERE (id = 1)",
60
60
  "UPDATE items SET c = ('ab') WHERE (id = 1)",
61
61
  "UPDATE items SET d = ('b' = 'ca') WHERE (id = 1)"]
@@ -63,18 +63,18 @@ describe "serialization_modification_detection plugin" do
63
63
 
64
64
  it "should report correct changed_columns after creating new object" do
65
65
  o = @c.create
66
- o.changed_columns.should == []
66
+ o.changed_columns.must_equal []
67
67
  o.a << 'a'
68
- o.changed_columns.should == [:a]
69
- @ds.db.sqls.should == ["INSERT INTO items DEFAULT VALUES", "SELECT * FROM items WHERE (id = 1) LIMIT 1"]
68
+ o.changed_columns.must_equal [:a]
69
+ @ds.db.sqls.must_equal ["INSERT INTO items DEFAULT VALUES", "SELECT * FROM items WHERE (id = 1) LIMIT 1"]
70
70
  end
71
71
 
72
72
  it "should report correct changed_columns after refreshing existing object" do
73
73
  @o.a << 'a'
74
- @o.changed_columns.should == [:a]
74
+ @o.changed_columns.must_equal [:a]
75
75
  @o.refresh
76
- @o.changed_columns.should == []
76
+ @o.changed_columns.must_equal []
77
77
  @o.a << 'a'
78
- @o.changed_columns.should == [:a]
78
+ @o.changed_columns.must_equal [:a]
79
79
  end
80
80
  end
@@ -13,42 +13,42 @@ describe "MSSSQL optimistic locking plugin" do
13
13
  it "should not include the lock column when updating" do
14
14
  @db.fetch = [[{:timestamp=>'2345'}]]
15
15
  @o.save
16
- @db.sqls.should == ["UPDATE TOP (1) items SET name = 'a' OUTPUT inserted.timestamp WHERE ((id = 1) AND (timestamp = 0x31323334))"]
16
+ @db.sqls.must_equal ["UPDATE TOP (1) items SET name = 'a' OUTPUT inserted.timestamp WHERE ((id = 1) AND (timestamp = 0x31323334))"]
17
17
  end
18
18
 
19
19
  it "should automatically update lock column using new value from database" do
20
20
  @db.fetch = [[{:timestamp=>'2345'}]]
21
21
  @o.save
22
- @o.timestamp.should == '2345'
22
+ @o.timestamp.must_equal '2345'
23
23
  end
24
24
 
25
25
  it "should raise error when updating stale object" do
26
26
  @db.fetch = []
27
27
  @o.timestamp = '2345'
28
- proc{@o.save}.should raise_error(Sequel::NoExistingObject)
29
- @o.timestamp.should == '2345'
30
- @db.sqls.should == ["UPDATE TOP (1) items SET name = 'a' OUTPUT inserted.timestamp WHERE ((id = 1) AND (timestamp = 0x32333435))"]
28
+ proc{@o.save}.must_raise(Sequel::NoExistingObject)
29
+ @o.timestamp.must_equal '2345'
30
+ @db.sqls.must_equal ["UPDATE TOP (1) items SET name = 'a' OUTPUT inserted.timestamp WHERE ((id = 1) AND (timestamp = 0x32333435))"]
31
31
  end
32
32
 
33
33
  it "should raise error when destroying stale object" do
34
34
  @db.numrows = 0
35
35
  @o.timestamp = '2345'
36
- proc{@o.destroy}.should raise_error(Sequel::NoExistingObject)
37
- @db.sqls.should == ["DELETE FROM items WHERE ((id = 1) AND (timestamp = 0x32333435))"]
36
+ proc{@o.destroy}.must_raise(Sequel::NoExistingObject)
37
+ @db.sqls.must_equal ["DELETE FROM items WHERE ((id = 1) AND (timestamp = 0x32333435))"]
38
38
  end
39
39
 
40
40
  it "should allow refresh after failed save" do
41
41
  @db.fetch = []
42
42
  @o.timestamp = '2345'
43
- proc{@o.save}.should raise_error(Sequel::NoExistingObject)
43
+ proc{@o.save}.must_raise(Sequel::NoExistingObject)
44
44
  @db.fetch = {:id=>1, :name=>'a', :timestamp=>'2345'}
45
45
  @o.refresh
46
46
  @db.sqls
47
47
  @o.save
48
- @db.sqls.should == ["UPDATE TOP (1) items SET name = 'a' OUTPUT inserted.timestamp WHERE ((id = 1) AND (timestamp = 0x32333435))"]
48
+ @db.sqls.must_equal ["UPDATE TOP (1) items SET name = 'a' OUTPUT inserted.timestamp WHERE ((id = 1) AND (timestamp = 0x32333435))"]
49
49
  end
50
50
 
51
- specify "should allow changing the lock column via model.lock_column=" do
51
+ it "should allow changing the lock column via model.lock_column=" do
52
52
  @c = Class.new(Sequel::Model(@db[:items]))
53
53
  @c.columns :id, :name, :lv
54
54
  @c.plugin :mssql_optimistic_locking
@@ -56,36 +56,36 @@ describe "MSSSQL optimistic locking plugin" do
56
56
  @o = @c.load(:id=>1, :name=>'a', :lv=>'1234')
57
57
  @db.sqls
58
58
  @db.fetch = []
59
- proc{@o.save}.should raise_error(Sequel::NoExistingObject)
60
- @o.lv.should == '1234'
61
- @db.sqls.should == ["UPDATE TOP (1) items SET name = 'a' OUTPUT inserted.lv WHERE ((id = 1) AND (lv = 0x31323334))"]
59
+ proc{@o.save}.must_raise(Sequel::NoExistingObject)
60
+ @o.lv.must_equal '1234'
61
+ @db.sqls.must_equal ["UPDATE TOP (1) items SET name = 'a' OUTPUT inserted.lv WHERE ((id = 1) AND (lv = 0x31323334))"]
62
62
  @o = @c.load(:id=>1, :name=>'a', :lv=>'1234')
63
63
  @db.fetch = {:lv=>'2345'}
64
64
  @o.save
65
- @o.lv.should == '2345'
65
+ @o.lv.must_equal '2345'
66
66
  end
67
67
 
68
- specify "should allow changing the lock column via plugin option" do
68
+ it "should allow changing the lock column via plugin option" do
69
69
  @c = Class.new(Sequel::Model(@db[:items]))
70
70
  @c.columns :id, :name, :lv
71
71
  @c.plugin :mssql_optimistic_locking, :lock_column=>:lv
72
72
  @o = @c.load(:id=>1, :name=>'a', :lv=>'1234')
73
73
  @db.sqls
74
74
  @db.fetch = []
75
- proc{@o.save}.should raise_error(Sequel::NoExistingObject)
76
- @o.lv.should == '1234'
77
- @db.sqls.should == ["UPDATE TOP (1) items SET name = 'a' OUTPUT inserted.lv WHERE ((id = 1) AND (lv = 0x31323334))"]
75
+ proc{@o.save}.must_raise(Sequel::NoExistingObject)
76
+ @o.lv.must_equal '1234'
77
+ @db.sqls.must_equal ["UPDATE TOP (1) items SET name = 'a' OUTPUT inserted.lv WHERE ((id = 1) AND (lv = 0x31323334))"]
78
78
  @o = @c.load(:id=>1, :name=>'a', :lv=>'1234')
79
79
  @db.fetch = {:lv=>'2345'}
80
80
  @o.save
81
- @o.lv.should == '2345'
81
+ @o.lv.must_equal '2345'
82
82
  end
83
83
 
84
- specify "should work when subclassing" do
84
+ it "should work when subclassing" do
85
85
  c = Class.new(@c)
86
86
  o = c.load(:id=>1, :name=>'a', :timestamp=>'1234')
87
87
  @db.fetch = [[{:timestamp=>'2345'}]]
88
88
  o.save
89
- @db.sqls.should == ["UPDATE TOP (1) items SET name = 'a' OUTPUT inserted.timestamp WHERE ((id = 1) AND (timestamp = 0x31323334))"]
89
+ @db.sqls.must_equal ["UPDATE TOP (1) items SET name = 'a' OUTPUT inserted.timestamp WHERE ((id = 1) AND (timestamp = 0x31323334))"]
90
90
  end
91
91
  end
@@ -26,21 +26,21 @@ describe "Sequel named_timezones extension" do
26
26
  end
27
27
 
28
28
  it "should convert string arguments to *_timezone= to TZInfo::Timezone instances" do
29
- Sequel.application_timezone.should == @tz_in
30
- Sequel.database_timezone.should == @tz_out
29
+ Sequel.application_timezone.must_equal @tz_in
30
+ Sequel.database_timezone.must_equal @tz_out
31
31
  end
32
32
 
33
33
  it "should convert string arguments for Database#timezone= to TZInfo::Timezone instances for database-specific timezones" do
34
34
  @db.extension :named_timezones
35
35
  @db.timezone = 'America/Los_Angeles'
36
- @db.timezone.should == @tz_in
36
+ @db.timezone.must_equal @tz_in
37
37
  end
38
38
 
39
39
  it "should accept TZInfo::Timezone instances in *_timezone=" do
40
40
  Sequel.application_timezone = @tz_in
41
41
  Sequel.database_timezone = @tz_out
42
- Sequel.application_timezone.should == @tz_in
43
- Sequel.database_timezone.should == @tz_out
42
+ Sequel.application_timezone.must_equal @tz_in
43
+ Sequel.database_timezone.must_equal @tz_out
44
44
  end
45
45
 
46
46
  it "should convert datetimes going into the database to named database_timezone" do
@@ -48,36 +48,36 @@ describe "Sequel named_timezones extension" do
48
48
  def ds.supports_timestamp_timezones?; true; end
49
49
  def ds.supports_timestamp_usecs?; false; end
50
50
  ds.insert([@dt, DateTime.civil(2009,6,1,3,20,30,-7/24.0), DateTime.civil(2009,6,1,6,20,30,-1/6.0)])
51
- @db.sqls.should == ["INSERT INTO a VALUES ('2009-06-01 06:20:30-0400', '2009-06-01 06:20:30-0400', '2009-06-01 06:20:30-0400')"]
51
+ @db.sqls.must_equal ["INSERT INTO a VALUES ('2009-06-01 06:20:30-0400', '2009-06-01 06:20:30-0400', '2009-06-01 06:20:30-0400')"]
52
52
  end
53
53
 
54
54
  it "should convert datetimes coming out of the database from database_timezone to application_timezone" do
55
55
  dt = Sequel.database_to_application_timestamp('2009-06-01 06:20:30-0400')
56
- dt.should == @dt
57
- dt.offset.should == -7/24.0
56
+ dt.must_equal @dt
57
+ dt.offset.must_equal(-7/24.0)
58
58
 
59
59
  dt = Sequel.database_to_application_timestamp('2009-06-01 10:20:30+0000')
60
- dt.should == @dt
61
- dt.offset.should == -7/24.0
60
+ dt.must_equal @dt
61
+ dt.offset.must_equal(-7/24.0)
62
62
  end
63
63
 
64
64
  it "should raise an error for ambiguous timezones by default" do
65
- proc{Sequel.database_to_application_timestamp('2004-10-31T01:30:00')}.should raise_error(Sequel::InvalidValue)
65
+ proc{Sequel.database_to_application_timestamp('2004-10-31T01:30:00')}.must_raise(Sequel::InvalidValue)
66
66
  end
67
67
 
68
68
  it "should support tzinfo_disambiguator= to handle ambiguous timezones automatically" do
69
69
  Sequel.tzinfo_disambiguator = proc{|datetime, periods| periods.first}
70
- Sequel.database_to_application_timestamp('2004-10-31T01:30:00').should == DateTime.parse('2004-10-30T22:30:00-07:00')
70
+ Sequel.database_to_application_timestamp('2004-10-31T01:30:00').must_equal DateTime.parse('2004-10-30T22:30:00-07:00')
71
71
  end
72
72
 
73
73
  it "should assume datetimes coming out of the database that don't have an offset as coming from database_timezone" do
74
74
  dt = Sequel.database_to_application_timestamp('2009-06-01 06:20:30')
75
- dt.should == @dt
76
- dt.offset.should == -7/24.0
75
+ dt.must_equal @dt
76
+ dt.offset.must_equal(-7/24.0)
77
77
 
78
78
  dt = Sequel.database_to_application_timestamp('2009-06-01 10:20:30')
79
- dt.should == @dt + 1/6.0
80
- dt.offset.should == -7/24.0
79
+ dt.must_equal @dt + 1/6.0
80
+ dt.offset.must_equal(-7/24.0)
81
81
  end
82
82
 
83
83
  it "should work with the thread_local_timezones extension" do
@@ -101,8 +101,8 @@ describe "Sequel named_timezones extension" do
101
101
  q1.push nil
102
102
  t1.join
103
103
  t2.join
104
- tz1.should == @tz_out
105
- tz2.should == @tz_in
104
+ tz1.must_equal @tz_out
105
+ tz2.must_equal @tz_in
106
106
  end
107
107
  end
108
108
  end
@@ -3,15 +3,15 @@ require File.join(File.dirname(File.expand_path(__FILE__)), "spec_helper")
3
3
  describe "NestedAttributes plugin" do
4
4
  def check_sqls(should, is)
5
5
  if should.is_a?(Array)
6
- should.should include(is)
6
+ should.must_include(is)
7
7
  else
8
- is.should == should
8
+ is.must_equal should
9
9
  end
10
10
  end
11
11
 
12
12
  def check_sql_array(*shoulds)
13
13
  sqls = @db.sqls
14
- sqls.length.should == shoulds.length
14
+ sqls.length.must_equal shoulds.length
15
15
  shoulds.zip(sqls){|s, i| check_sqls(s, i)}
16
16
  end
17
17
 
@@ -51,7 +51,7 @@ describe "NestedAttributes plugin" do
51
51
 
52
52
  it "should support creating new many_to_one objects" do
53
53
  a = @Album.new({:name=>'Al', :artist_attributes=>{:name=>'Ar'}})
54
- @db.sqls.should == []
54
+ @db.sqls.must_equal []
55
55
  a.save
56
56
  check_sql_array("INSERT INTO artists (name) VALUES ('Ar')",
57
57
  ["INSERT INTO albums (name, artist_id) VALUES ('Al', 1)", "INSERT INTO albums (artist_id, name) VALUES (1, 'Al')"])
@@ -61,7 +61,7 @@ describe "NestedAttributes plugin" do
61
61
  a = @Artist.new(:name=>'Ar')
62
62
  a.id = 1
63
63
  a.first_album_attributes = {:name=>'Al'}
64
- @db.sqls.should == []
64
+ @db.sqls.must_equal []
65
65
  a.save
66
66
  check_sql_array(["INSERT INTO artists (name, id) VALUES ('Ar', 1)", "INSERT INTO artists (id, name) VALUES (1, 'Ar')"],
67
67
  "UPDATE albums SET artist_id = NULL WHERE (artist_id = 1)",
@@ -70,7 +70,7 @@ describe "NestedAttributes plugin" do
70
70
 
71
71
  it "should support creating new one_to_many objects" do
72
72
  a = @Artist.new({:name=>'Ar', :albums_attributes=>[{:name=>'Al'}]})
73
- @db.sqls.should == []
73
+ @db.sqls.must_equal []
74
74
  a.save
75
75
  check_sql_array("INSERT INTO artists (name) VALUES ('Ar')",
76
76
  ["INSERT INTO albums (artist_id, name) VALUES (1, 'Al')", "INSERT INTO albums (name, artist_id) VALUES ('Al', 1)"])
@@ -85,7 +85,7 @@ describe "NestedAttributes plugin" do
85
85
  end
86
86
  end
87
87
  a = @Artist.new({:name=>'Ar', :albums_attributes=>[{:name=>'Al'}]})
88
- @db.sqls.should == []
88
+ @db.sqls.must_equal []
89
89
  a.save
90
90
  check_sql_array("INSERT INTO artists (name) VALUES ('Ar')",
91
91
  ["INSERT INTO albums (artist_id, name) VALUES (1, 'Al')", "INSERT INTO albums (name, artist_id) VALUES ('Al', 1)"])
@@ -93,7 +93,7 @@ describe "NestedAttributes plugin" do
93
93
  a = @Artist.new(:name=>'Ar')
94
94
  a.id = 1
95
95
  a.first_album_attributes = {:name=>'Al'}
96
- @db.sqls.should == []
96
+ @db.sqls.must_equal []
97
97
  a.save
98
98
  check_sql_array(["INSERT INTO artists (name, id) VALUES ('Ar', 1)", "INSERT INTO artists (id, name) VALUES (1, 'Ar')"],
99
99
  "UPDATE albums SET artist_id = NULL WHERE (artist_id = 1)",
@@ -125,10 +125,10 @@ describe "NestedAttributes plugin" do
125
125
  end
126
126
 
127
127
  c = @Concert.new(:playlist=>'Pl')
128
- @db.sqls.should == []
128
+ @db.sqls.must_equal []
129
129
  c.albums_attributes = [{:name=>'Al'}]
130
130
  c.save
131
- insert.should == {:tour=>'To', :date=>'2004-04-05', :playlist=>'Pl'}
131
+ insert.must_equal(:tour=>'To', :date=>'2004-04-05', :playlist=>'Pl')
132
132
  check_sql_array(["INSERT INTO albums (name, artist_id) VALUES ('Al', 3)", "INSERT INTO albums (artist_id, name) VALUES (3, 'Al')"])
133
133
 
134
134
  @Concert.class_eval do
@@ -142,11 +142,11 @@ describe "NestedAttributes plugin" do
142
142
  a = @Artist.new(:name=>'Ar')
143
143
  a.id = 1
144
144
  a.first_concert_attributes = {:playlist=>'Pl'}
145
- @db.sqls.should == []
145
+ @db.sqls.must_equal []
146
146
  a.save
147
147
  check_sql_array(["INSERT INTO artists (name, id) VALUES ('Ar', 1)", "INSERT INTO artists (id, name) VALUES (1, 'Ar')"],
148
148
  "UPDATE concerts SET artist_id = NULL WHERE (artist_id = 1)")
149
- insert.should == {:tour=>'To', :date=>'2004-04-05', :artist_id=>1, :playlist=>'Pl'}
149
+ insert.must_equal(:tour=>'To', :date=>'2004-04-05', :artist_id=>1, :playlist=>'Pl')
150
150
  end
151
151
 
152
152
  it "should should not remove existing values from object when validating" do
@@ -155,15 +155,15 @@ describe "NestedAttributes plugin" do
155
155
  @db.fetch = {:id=>1}
156
156
  a = @Artist.load(:id=>1)
157
157
  a.set(:first_album_attributes=>{:id=>1, :name=>'Ar'})
158
- a.first_album.values.should == {:id=>1, :name=>'Ar'}
159
- @db.sqls.should == ["SELECT * FROM albums WHERE (albums.id = 1) LIMIT 1"]
158
+ a.first_album.values.must_equal(:id=>1, :name=>'Ar')
159
+ @db.sqls.must_equal ["SELECT * FROM albums WHERE (albums.id = 1) LIMIT 1"]
160
160
  a.save_changes
161
161
  check_sql_array("UPDATE albums SET name = 'Ar' WHERE (id = 1)")
162
162
  end
163
163
 
164
164
  it "should support creating new many_to_many objects" do
165
165
  a = @Album.new({:name=>'Al', :tags_attributes=>[{:name=>'T'}]})
166
- @db.sqls.should == []
166
+ @db.sqls.must_equal []
167
167
  a.save
168
168
  check_sql_array("INSERT INTO albums (name) VALUES ('Al')",
169
169
  "INSERT INTO tags (name) VALUES ('T')",
@@ -172,11 +172,11 @@ describe "NestedAttributes plugin" do
172
172
 
173
173
  it "should add new objects to the cached association array as soon as the *_attributes= method is called" do
174
174
  a = @Artist.new({:name=>'Ar', :first_album_attributes=>{:name=>'B'}, :albums_attributes=>[{:name=>'Al', :tags_attributes=>[{:name=>'T'}]}]})
175
- a.albums.should == [@Album.new(:name=>'Al')]
176
- a.albums.first.artist.should == a
177
- a.albums.first.tags.should == [@Tag.new(:name=>'T')]
178
- a.first_album.should == @Album.new(:name=>'B')
179
- a.first_album.artist.should == a
175
+ a.albums.must_equal [@Album.new(:name=>'Al')]
176
+ a.albums.first.artist.must_equal a
177
+ a.albums.first.tags.must_equal [@Tag.new(:name=>'T')]
178
+ a.first_album.must_equal @Album.new(:name=>'B')
179
+ a.first_album.artist.must_equal a
180
180
  end
181
181
 
182
182
  it "should support creating new objects with composite primary keys" do
@@ -192,10 +192,10 @@ describe "NestedAttributes plugin" do
192
192
  end
193
193
  end
194
194
  a = @Artist.new({:name=>'Ar', :concerts_attributes=>[{:playlist=>'Pl'}]})
195
- @db.sqls.should == []
195
+ @db.sqls.must_equal []
196
196
  a.save
197
- @db.sqls.should == ["INSERT INTO artists (name) VALUES ('Ar')"]
198
- insert.should == {:tour=>'To', :date=>'2004-04-05', :artist_id=>1, :playlist=>'Pl'}
197
+ @db.sqls.must_equal ["INSERT INTO artists (name) VALUES ('Ar')"]
198
+ insert.must_equal(:tour=>'To', :date=>'2004-04-05', :artist_id=>1, :playlist=>'Pl')
199
199
  end
200
200
 
201
201
  it "should support creating new objects with specific primary keys if :unmatched_pk => :create is set" do
@@ -208,10 +208,10 @@ describe "NestedAttributes plugin" do
208
208
  end
209
209
  end
210
210
  a = @Artist.new({:name=>'Ar', :albums_attributes=>[{:id=>7, :name=>'Al'}]})
211
- @db.sqls.should == []
211
+ @db.sqls.must_equal []
212
212
  a.save
213
- @db.sqls.should == ["INSERT INTO artists (name) VALUES ('Ar')"]
214
- insert.should == {:artist_id=>1, :name=>'Al', :id=>7}
213
+ @db.sqls.must_equal ["INSERT INTO artists (name) VALUES ('Ar')"]
214
+ insert.must_equal(:artist_id=>1, :name=>'Al', :id=>7)
215
215
  end
216
216
 
217
217
  it "should support creating new objects with specific composite primary keys if :unmatched_pk => :create is set" do
@@ -223,10 +223,10 @@ describe "NestedAttributes plugin" do
223
223
  end
224
224
  end
225
225
  a = @Artist.new({:name=>'Ar', :concerts_attributes=>[{:tour=>'To', :date=>'2004-04-05', :playlist=>'Pl'}]})
226
- @db.sqls.should == []
226
+ @db.sqls.must_equal []
227
227
  a.save
228
- @db.sqls.should == ["INSERT INTO artists (name) VALUES ('Ar')"]
229
- insert.should == {:tour=>'To', :date=>'2004-04-05', :artist_id=>1, :playlist=>'Pl'}
228
+ @db.sqls.must_equal ["INSERT INTO artists (name) VALUES ('Ar')"]
229
+ insert.must_equal(:tour=>'To', :date=>'2004-04-05', :artist_id=>1, :playlist=>'Pl')
230
230
  end
231
231
 
232
232
  it "should support updating many_to_one objects" do
@@ -234,9 +234,9 @@ describe "NestedAttributes plugin" do
234
234
  ar = @Artist.load(:id=>20, :name=>'Ar')
235
235
  al.associations[:artist] = ar
236
236
  al.set(:artist_attributes=>{:id=>'20', :name=>'Ar2'})
237
- @db.sqls.should == []
237
+ @db.sqls.must_equal []
238
238
  al.save
239
- @db.sqls.should == ["UPDATE albums SET name = 'Al' WHERE (id = 10)", "UPDATE artists SET name = 'Ar2' WHERE (id = 20)"]
239
+ @db.sqls.must_equal ["UPDATE albums SET name = 'Al' WHERE (id = 10)", "UPDATE artists SET name = 'Ar2' WHERE (id = 20)"]
240
240
  end
241
241
 
242
242
  it "should support updating one_to_one objects" do
@@ -244,9 +244,9 @@ describe "NestedAttributes plugin" do
244
244
  ar = @Artist.load(:id=>20, :name=>'Ar')
245
245
  ar.associations[:first_album] = al
246
246
  ar.set(:first_album_attributes=>{:id=>10, :name=>'Al2'})
247
- @db.sqls.should == []
247
+ @db.sqls.must_equal []
248
248
  ar.save
249
- @db.sqls.should == ["UPDATE artists SET name = 'Ar' WHERE (id = 20)", "UPDATE albums SET name = 'Al2' WHERE (id = 10)"]
249
+ @db.sqls.must_equal ["UPDATE artists SET name = 'Ar' WHERE (id = 20)", "UPDATE albums SET name = 'Al2' WHERE (id = 10)"]
250
250
  end
251
251
 
252
252
  it "should support updating one_to_many objects" do
@@ -254,9 +254,9 @@ describe "NestedAttributes plugin" do
254
254
  ar = @Artist.load(:id=>20, :name=>'Ar')
255
255
  ar.associations[:albums] = [al]
256
256
  ar.set(:albums_attributes=>[{:id=>10, :name=>'Al2'}])
257
- @db.sqls.should == []
257
+ @db.sqls.must_equal []
258
258
  ar.save
259
- @db.sqls.should == ["UPDATE artists SET name = 'Ar' WHERE (id = 20)", "UPDATE albums SET name = 'Al2' WHERE (id = 10)"]
259
+ @db.sqls.must_equal ["UPDATE artists SET name = 'Ar' WHERE (id = 20)", "UPDATE albums SET name = 'Al2' WHERE (id = 10)"]
260
260
  end
261
261
 
262
262
  it "should support updating one_to_many objects with _delete/_remove flags set to false" do
@@ -264,9 +264,9 @@ describe "NestedAttributes plugin" do
264
264
  ar = @Artist.load(:id=>20, :name=>'Ar')
265
265
  ar.associations[:albums] = [al]
266
266
  ar.set(:albums_attributes=>[{:id=>10, :name=>'Al2', :_delete => 'f', :_remove => '0'}])
267
- @db.sqls.should == []
267
+ @db.sqls.must_equal []
268
268
  ar.save
269
- @db.sqls.should == ["UPDATE artists SET name = 'Ar' WHERE (id = 20)", "UPDATE albums SET name = 'Al2' WHERE (id = 10)"]
269
+ @db.sqls.must_equal ["UPDATE artists SET name = 'Ar' WHERE (id = 20)", "UPDATE albums SET name = 'Al2' WHERE (id = 10)"]
270
270
  end
271
271
 
272
272
  it "should support updating many_to_many objects" do
@@ -274,9 +274,9 @@ describe "NestedAttributes plugin" do
274
274
  t = @Tag.load(:id=>20, :name=>'T')
275
275
  a.associations[:tags] = [t]
276
276
  a.set(:tags_attributes=>[{:id=>20, :name=>'T2'}])
277
- @db.sqls.should == []
277
+ @db.sqls.must_equal []
278
278
  a.save
279
- @db.sqls.should == ["UPDATE albums SET name = 'Al' WHERE (id = 10)", "UPDATE tags SET name = 'T2' WHERE (id = 20)"]
279
+ @db.sqls.must_equal ["UPDATE albums SET name = 'Al' WHERE (id = 10)", "UPDATE tags SET name = 'T2' WHERE (id = 20)"]
280
280
  end
281
281
 
282
282
  it "should support updating many_to_many objects with _delete/_remove flags set to false" do
@@ -284,9 +284,9 @@ describe "NestedAttributes plugin" do
284
284
  t = @Tag.load(:id=>20, :name=>'T')
285
285
  a.associations[:tags] = [t]
286
286
  a.set(:tags_attributes=>[{:id=>20, :name=>'T2', '_delete' => false, '_remove' => 'F'}])
287
- @db.sqls.should == []
287
+ @db.sqls.must_equal []
288
288
  a.save
289
- @db.sqls.should == ["UPDATE albums SET name = 'Al' WHERE (id = 10)", "UPDATE tags SET name = 'T2' WHERE (id = 20)"]
289
+ @db.sqls.must_equal ["UPDATE albums SET name = 'Al' WHERE (id = 10)", "UPDATE tags SET name = 'T2' WHERE (id = 20)"]
290
290
  end
291
291
 
292
292
  it "should support updating objects with composite primary keys" do
@@ -294,7 +294,7 @@ describe "NestedAttributes plugin" do
294
294
  co = @Concert.load(:tour=>'To', :date=>'2004-04-05', :playlist=>'Pl')
295
295
  ar.associations[:concerts] = [co]
296
296
  ar.set(:concerts_attributes=>[{:tour=>'To', :date=>'2004-04-05', :playlist=>'Pl2'}])
297
- @db.sqls.should == []
297
+ @db.sqls.must_equal []
298
298
  ar.save
299
299
  check_sql_array("UPDATE artists SET name = 'Ar' WHERE (id = 10)", ["UPDATE concerts SET playlist = 'Pl2' WHERE ((tour = 'To') AND (date = '2004-04-05'))", "UPDATE concerts SET playlist = 'Pl2' WHERE ((date = '2004-04-05') AND (tour = 'To'))"])
300
300
  end
@@ -304,7 +304,7 @@ describe "NestedAttributes plugin" do
304
304
  ar = @Artist.load(:id=>20, :name=>'Ar')
305
305
  al.associations[:artist] = ar
306
306
  al.set(:artist_attributes=>{:id=>'20', :_remove=>'1'})
307
- @db.sqls.should == []
307
+ @db.sqls.must_equal []
308
308
  al.save
309
309
  check_sql_array(["UPDATE albums SET artist_id = NULL, name = 'Al' WHERE (id = 10)", "UPDATE albums SET name = 'Al', artist_id = NULL WHERE (id = 10)"])
310
310
  end
@@ -314,9 +314,9 @@ describe "NestedAttributes plugin" do
314
314
  ar = @Artist.load(:id=>20, :name=>'Ar')
315
315
  ar.associations[:first_album] = al
316
316
  ar.set(:first_album_attributes=>{:id=>10, :_remove=>'t'})
317
- @db.sqls.should == []
317
+ @db.sqls.must_equal []
318
318
  ar.save
319
- @db.sqls.should == ["UPDATE albums SET artist_id = NULL WHERE (artist_id = 20)", "UPDATE artists SET name = 'Ar' WHERE (id = 20)"]
319
+ @db.sqls.must_equal ["UPDATE albums SET artist_id = NULL WHERE (artist_id = 20)", "UPDATE artists SET name = 'Ar' WHERE (id = 20)"]
320
320
  end
321
321
 
322
322
  it "should support removing one_to_many objects" do
@@ -324,8 +324,8 @@ describe "NestedAttributes plugin" do
324
324
  ar = @Artist.load(:id=>20, :name=>'Ar')
325
325
  ar.associations[:albums] = [al]
326
326
  ar.set(:albums_attributes=>[{:id=>10, :_remove=>'t'}])
327
- ar.associations[:albums].should == []
328
- @db.sqls.should == []
327
+ ar.associations[:albums].must_equal []
328
+ @db.sqls.must_equal []
329
329
  @Album.dataset._fetch = {:id=>1}
330
330
  ar.save
331
331
  check_sql_array("SELECT 1 AS one FROM albums WHERE ((albums.artist_id = 20) AND (id = 10)) LIMIT 1",
@@ -338,10 +338,10 @@ describe "NestedAttributes plugin" do
338
338
  t = @Tag.load(:id=>20, :name=>'T')
339
339
  a.associations[:tags] = [t]
340
340
  a.set(:tags_attributes=>[{:id=>20, :_remove=>true}])
341
- a.associations[:tags].should == []
342
- @db.sqls.should == []
341
+ a.associations[:tags].must_equal []
342
+ @db.sqls.must_equal []
343
343
  a.save
344
- @db.sqls.should == ["DELETE FROM at WHERE ((album_id = 10) AND (tag_id = 20))", "UPDATE albums SET name = 'Al' WHERE (id = 10)"]
344
+ @db.sqls.must_equal ["DELETE FROM at WHERE ((album_id = 10) AND (tag_id = 20))", "UPDATE albums SET name = 'Al' WHERE (id = 10)"]
345
345
  end
346
346
 
347
347
  it "should support removing objects with composite primary keys" do
@@ -349,7 +349,7 @@ describe "NestedAttributes plugin" do
349
349
  co = @Concert.load(:tour=>'To', :date=>'2004-04-05', :playlist=>'Pl')
350
350
  ar.associations[:concerts] = [co]
351
351
  ar.set(:concerts_attributes=>[{:tour=>'To', :date=>'2004-04-05', :_remove=>'t'}])
352
- @db.sqls.should == []
352
+ @db.sqls.must_equal []
353
353
  @Concert.dataset._fetch = {:id=>1}
354
354
  ar.save
355
355
  check_sql_array(["SELECT 1 AS one FROM concerts WHERE ((concerts.artist_id = 10) AND (tour = 'To') AND (date = '2004-04-05')) LIMIT 1", "SELECT 1 AS one FROM concerts WHERE ((concerts.artist_id = 10) AND (date = '2004-04-05') AND (tour = 'To')) LIMIT 1"],
@@ -362,7 +362,7 @@ describe "NestedAttributes plugin" do
362
362
  ar = @Artist.load(:id=>20, :name=>'Ar')
363
363
  al.associations[:artist] = ar
364
364
  al.set(:artist_attributes=>{:id=>'20', :_delete=>'1'})
365
- @db.sqls.should == []
365
+ @db.sqls.must_equal []
366
366
  al.save
367
367
  check_sql_array(["UPDATE albums SET artist_id = NULL, name = 'Al' WHERE (id = 10)", "UPDATE albums SET name = 'Al', artist_id = NULL WHERE (id = 10)"],
368
368
  "DELETE FROM artists WHERE (id = 20)")
@@ -373,9 +373,9 @@ describe "NestedAttributes plugin" do
373
373
  ar = @Artist.load(:id=>20, :name=>'Ar')
374
374
  ar.associations[:first_album] = al
375
375
  ar.set(:first_album_attributes=>{:id=>10, :_delete=>'t'})
376
- @db.sqls.should == []
376
+ @db.sqls.must_equal []
377
377
  ar.save
378
- @db.sqls.should == ["UPDATE artists SET name = 'Ar' WHERE (id = 20)", "DELETE FROM albums WHERE (id = 10)"]
378
+ @db.sqls.must_equal ["UPDATE artists SET name = 'Ar' WHERE (id = 20)", "DELETE FROM albums WHERE (id = 10)"]
379
379
  end
380
380
 
381
381
  it "should support destroying one_to_many objects" do
@@ -383,9 +383,9 @@ describe "NestedAttributes plugin" do
383
383
  ar = @Artist.load(:id=>20, :name=>'Ar')
384
384
  ar.associations[:albums] = [al]
385
385
  ar.set(:albums_attributes=>[{:id=>10, :_delete=>'t'}])
386
- @db.sqls.should == []
386
+ @db.sqls.must_equal []
387
387
  ar.save
388
- @db.sqls.should == ["UPDATE artists SET name = 'Ar' WHERE (id = 20)", "DELETE FROM albums WHERE (id = 10)"]
388
+ @db.sqls.must_equal ["UPDATE artists SET name = 'Ar' WHERE (id = 20)", "DELETE FROM albums WHERE (id = 10)"]
389
389
  end
390
390
 
391
391
  it "should support destroying many_to_many objects" do
@@ -393,9 +393,9 @@ describe "NestedAttributes plugin" do
393
393
  t = @Tag.load(:id=>20, :name=>'T')
394
394
  a.associations[:tags] = [t]
395
395
  a.set(:tags_attributes=>[{:id=>20, :_delete=>true}])
396
- @db.sqls.should == []
396
+ @db.sqls.must_equal []
397
397
  a.save
398
- @db.sqls.should == ["DELETE FROM at WHERE ((album_id = 10) AND (tag_id = 20))", "UPDATE albums SET name = 'Al' WHERE (id = 10)", "DELETE FROM tags WHERE (id = 20)"]
398
+ @db.sqls.must_equal ["DELETE FROM at WHERE ((album_id = 10) AND (tag_id = 20))", "UPDATE albums SET name = 'Al' WHERE (id = 10)", "DELETE FROM tags WHERE (id = 20)"]
399
399
  end
400
400
 
401
401
  it "should support destroying objects with composite primary keys" do
@@ -403,7 +403,7 @@ describe "NestedAttributes plugin" do
403
403
  co = @Concert.load(:tour=>'To', :date=>'2004-04-05', :playlist=>'Pl')
404
404
  ar.associations[:concerts] = [co]
405
405
  ar.set(:concerts_attributes=>[{:tour=>'To', :date=>'2004-04-05', :_delete=>'t'}])
406
- @db.sqls.should == []
406
+ @db.sqls.must_equal []
407
407
  ar.save
408
408
  check_sql_array("UPDATE artists SET name = 'Ar' WHERE (id = 10)", ["DELETE FROM concerts WHERE ((tour = 'To') AND (date = '2004-04-05'))", "DELETE FROM concerts WHERE ((date = '2004-04-05') AND (tour = 'To'))"])
409
409
  end
@@ -413,9 +413,9 @@ describe "NestedAttributes plugin" do
413
413
  t = @Tag.load(:id=>20, :name=>'T')
414
414
  a.associations[:tags] = [t]
415
415
  a.set('tags_attributes'=>[{'id'=>20, '_delete'=>true}])
416
- @db.sqls.should == []
416
+ @db.sqls.must_equal []
417
417
  a.save
418
- @db.sqls.should == ["DELETE FROM at WHERE ((album_id = 10) AND (tag_id = 20))", "UPDATE albums SET name = 'Al' WHERE (id = 10)", "DELETE FROM tags WHERE (id = 20)"]
418
+ @db.sqls.must_equal ["DELETE FROM at WHERE ((album_id = 10) AND (tag_id = 20))", "UPDATE albums SET name = 'Al' WHERE (id = 10)", "DELETE FROM tags WHERE (id = 20)"]
419
419
  end
420
420
 
421
421
  it "should support using a hash instead of an array for to_many nested attributes" do
@@ -423,9 +423,9 @@ describe "NestedAttributes plugin" do
423
423
  t = @Tag.load(:id=>20, :name=>'T')
424
424
  a.associations[:tags] = [t]
425
425
  a.set('tags_attributes'=>{'1'=>{'id'=>20, '_delete'=>true}})
426
- @db.sqls.should == []
426
+ @db.sqls.must_equal []
427
427
  a.save
428
- @db.sqls.should == ["DELETE FROM at WHERE ((album_id = 10) AND (tag_id = 20))", "UPDATE albums SET name = 'Al' WHERE (id = 10)", "DELETE FROM tags WHERE (id = 20)"]
428
+ @db.sqls.must_equal ["DELETE FROM at WHERE ((album_id = 10) AND (tag_id = 20))", "UPDATE albums SET name = 'Al' WHERE (id = 10)", "DELETE FROM tags WHERE (id = 20)"]
429
429
  end
430
430
 
431
431
  it "should only allow destroying associated objects if :destroy option is used in the nested_attributes call" do
@@ -433,9 +433,9 @@ describe "NestedAttributes plugin" do
433
433
  ar = @Artist.load(:id=>20, :name=>'Ar')
434
434
  a.associations[:artist] = ar
435
435
  @Album.nested_attributes :artist
436
- proc{a.set(:artist_attributes=>{:id=>'20', :_delete=>'1'})}.should raise_error(Sequel::MassAssignmentRestriction)
436
+ proc{a.set(:artist_attributes=>{:id=>'20', :_delete=>'1'})}.must_raise(Sequel::MassAssignmentRestriction)
437
437
  @Album.nested_attributes :artist, :destroy=>true
438
- proc{a.set(:artist_attributes=>{:id=>'20', :_delete=>'1'})}.should_not raise_error
438
+ a.set(:artist_attributes=>{:id=>'20', :_delete=>'1'})
439
439
  end
440
440
 
441
441
  it "should only allow removing associated objects if :remove option is used in the nested_attributes call" do
@@ -443,17 +443,17 @@ describe "NestedAttributes plugin" do
443
443
  ar = @Artist.load(:id=>20, :name=>'Ar')
444
444
  a.associations[:artist] = ar
445
445
  @Album.nested_attributes :artist
446
- proc{a.set(:artist_attributes=>{:id=>'20', :_remove=>'1'})}.should raise_error(Sequel::MassAssignmentRestriction)
446
+ proc{a.set(:artist_attributes=>{:id=>'20', :_remove=>'1'})}.must_raise(Sequel::MassAssignmentRestriction)
447
447
  @Album.nested_attributes :artist, :remove=>true
448
- proc{a.set(:artist_attributes=>{:id=>'20', :_remove=>'1'})}.should_not raise_error
448
+ a.set(:artist_attributes=>{:id=>'20', :_remove=>'1'})
449
449
  end
450
450
 
451
451
  it "should raise an Error if a primary key is given in a nested attribute hash, but no matching associated object exists" do
452
452
  al = @Album.load(:id=>10, :name=>'Al')
453
453
  ar = @Artist.load(:id=>20, :name=>'Ar')
454
454
  ar.associations[:albums] = [al]
455
- proc{ar.set(:albums_attributes=>[{:id=>30, :_delete=>'t'}])}.should raise_error(Sequel::Error)
456
- proc{ar.set(:albums_attributes=>[{:id=>10, :_delete=>'t'}])}.should_not raise_error
455
+ proc{ar.set(:albums_attributes=>[{:id=>30, :_delete=>'t'}])}.must_raise(Sequel::Error)
456
+ ar.set(:albums_attributes=>[{:id=>10, :_delete=>'t'}])
457
457
  end
458
458
 
459
459
  it "should not raise an Error if an unmatched primary key is given, if the :strict=>false option is used" do
@@ -462,9 +462,9 @@ describe "NestedAttributes plugin" do
462
462
  ar = @Artist.load(:id=>20, :name=>'Ar')
463
463
  ar.associations[:albums] = [al]
464
464
  ar.set(:albums_attributes=>[{:id=>30, :_delete=>'t'}])
465
- @db.sqls.should == []
465
+ @db.sqls.must_equal []
466
466
  ar.save
467
- @db.sqls.should == ["UPDATE artists SET name = 'Ar' WHERE (id = 20)"]
467
+ @db.sqls.must_equal ["UPDATE artists SET name = 'Ar' WHERE (id = 20)"]
468
468
  end
469
469
 
470
470
  it "should not raise an Error if an unmatched primary key is given, if the :unmatched_pk=>:ignore option is used" do
@@ -473,17 +473,17 @@ describe "NestedAttributes plugin" do
473
473
  ar = @Artist.load(:id=>20, :name=>'Ar')
474
474
  ar.associations[:albums] = [al]
475
475
  ar.set(:albums_attributes=>[{:id=>30, :_delete=>'t'}])
476
- @db.sqls.should == []
476
+ @db.sqls.must_equal []
477
477
  ar.save
478
- @db.sqls.should == ["UPDATE artists SET name = 'Ar' WHERE (id = 20)"]
478
+ @db.sqls.must_equal ["UPDATE artists SET name = 'Ar' WHERE (id = 20)"]
479
479
  end
480
480
 
481
481
  it "should raise an Error if a composite primary key is given in a nested attribute hash, but no matching associated object exists" do
482
482
  ar = @Artist.load(:id=>10, :name=>'Ar')
483
483
  co = @Concert.load(:tour=>'To', :date=>'2004-04-05', :playlist=>'Pl')
484
484
  ar.associations[:concerts] = [co]
485
- proc{ar.set(:concerts_attributes=>[{:tour=>'To', :date=>'2004-04-04', :_delete=>'t'}])}.should raise_error(Sequel::Error)
486
- proc{ar.set(:concerts_attributes=>[{:tour=>'To', :date=>'2004-04-05', :_delete=>'t'}])}.should_not raise_error
485
+ proc{ar.set(:concerts_attributes=>[{:tour=>'To', :date=>'2004-04-04', :_delete=>'t'}])}.must_raise(Sequel::Error)
486
+ ar.set(:concerts_attributes=>[{:tour=>'To', :date=>'2004-04-05', :_delete=>'t'}])
487
487
  end
488
488
 
489
489
  it "should not raise an Error if an unmatched composite primary key is given, if the :strict=>false option is used" do
@@ -492,9 +492,9 @@ describe "NestedAttributes plugin" do
492
492
  co = @Concert.load(:tour=>'To', :date=>'2004-04-05', :playlist=>'Pl')
493
493
  ar.associations[:concerts] = [co]
494
494
  ar.set(:concerts_attributes=>[{:tour=>'To', :date=>'2004-04-06', :_delete=>'t'}])
495
- @db.sqls.should == []
495
+ @db.sqls.must_equal []
496
496
  ar.save
497
- @db.sqls.should == ["UPDATE artists SET name = 'Ar' WHERE (id = 10)"]
497
+ @db.sqls.must_equal ["UPDATE artists SET name = 'Ar' WHERE (id = 10)"]
498
498
  end
499
499
 
500
500
  it "should not save if nested attribute is not valid and should include nested attribute validation errors in the main object's validation errors" do
@@ -505,12 +505,12 @@ describe "NestedAttributes plugin" do
505
505
  end
506
506
  end
507
507
  a = @Album.new(:name=>'Al', :artist_attributes=>{:name=>'Ar'})
508
- @db.sqls.should == []
509
- proc{a.save}.should raise_error(Sequel::ValidationFailed)
510
- a.errors.full_messages.should == ['artist name cannot be Ar']
511
- @db.sqls.should == []
508
+ @db.sqls.must_equal []
509
+ proc{a.save}.must_raise(Sequel::ValidationFailed)
510
+ a.errors.full_messages.must_equal ['artist name cannot be Ar']
511
+ @db.sqls.must_equal []
512
512
  # Should preserve attributes
513
- a.artist.name.should == 'Ar'
513
+ a.artist.name.must_equal 'Ar'
514
514
  end
515
515
 
516
516
  it "should not attempt to validate nested attributes if the :validate=>false association option is used" do
@@ -523,7 +523,7 @@ describe "NestedAttributes plugin" do
523
523
  end
524
524
  end
525
525
  a = @Album.new(:name=>'Al', :artist_attributes=>{:name=>'Ar'})
526
- @db.sqls.should == []
526
+ @db.sqls.must_equal []
527
527
  a.save
528
528
  check_sql_array("INSERT INTO artists (name) VALUES ('Ar')",
529
529
  ["INSERT INTO albums (artist_id, name) VALUES (1, 'Al')", "INSERT INTO albums (name, artist_id) VALUES ('Al', 1)"])
@@ -537,7 +537,7 @@ describe "NestedAttributes plugin" do
537
537
  end
538
538
  end
539
539
  a = @Album.new(:name=>'Al', :artist_attributes=>{:name=>'Ar'})
540
- @db.sqls.should == []
540
+ @db.sqls.must_equal []
541
541
  a.save(:validate=>false)
542
542
  check_sql_array("INSERT INTO artists (name) VALUES ('Ar')",
543
543
  ["INSERT INTO albums (artist_id, name) VALUES (1, 'Al')", "INSERT INTO albums (name, artist_id) VALUES ('Al', 1)"])
@@ -545,25 +545,25 @@ describe "NestedAttributes plugin" do
545
545
 
546
546
  it "should not accept nested attributes unless explicitly specified" do
547
547
  @Artist.many_to_many :tags, :class=>@Tag, :left_key=>:album_id, :right_key=>:tag_id, :join_table=>:at
548
- proc{@Artist.create({:name=>'Ar', :tags_attributes=>[{:name=>'T'}]})}.should raise_error(Sequel::MassAssignmentRestriction)
549
- @db.sqls.should == []
548
+ proc{@Artist.create({:name=>'Ar', :tags_attributes=>[{:name=>'T'}]})}.must_raise(Sequel::MassAssignmentRestriction)
549
+ @db.sqls.must_equal []
550
550
  end
551
551
 
552
552
  it "should save when save_changes or update is called if nested attribute associated objects changed but there are no changes to the main object" do
553
553
  al = @Album.load(:id=>10, :name=>'Al')
554
554
  ar = @Artist.load(:id=>20, :name=>'Ar')
555
555
  al.associations[:artist] = ar
556
- @db.sqls.should == []
556
+ @db.sqls.must_equal []
557
557
  al.update(:artist_attributes=>{:id=>'20', :name=>'Ar2'})
558
- @db.sqls.should == ["UPDATE artists SET name = 'Ar2' WHERE (id = 20)"]
558
+ @db.sqls.must_equal ["UPDATE artists SET name = 'Ar2' WHERE (id = 20)"]
559
559
  end
560
560
 
561
561
  it "should have a :limit option limiting the amount of entries" do
562
562
  @Album.nested_attributes :tags, :limit=>2
563
563
  arr = [{:name=>'T'}]
564
- proc{@Album.new({:name=>'Al', :tags_attributes=>arr*3})}.should raise_error(Sequel::Error)
564
+ proc{@Album.new({:name=>'Al', :tags_attributes=>arr*3})}.must_raise(Sequel::Error)
565
565
  a = @Album.new({:name=>'Al', :tags_attributes=>arr*2})
566
- @db.sqls.should == []
566
+ @db.sqls.must_equal []
567
567
  a.save
568
568
  check_sql_array("INSERT INTO albums (name) VALUES ('Al')",
569
569
  "INSERT INTO tags (name) VALUES ('T')",
@@ -575,7 +575,7 @@ describe "NestedAttributes plugin" do
575
575
  it "should accept a block that each hash gets passed to determine if it should be processed" do
576
576
  @Album.nested_attributes(:tags){|h| h[:name].empty?}
577
577
  a = @Album.new({:name=>'Al', :tags_attributes=>[{:name=>'T'}, {:name=>''}, {:name=>'T2'}]})
578
- @db.sqls.should == []
578
+ @db.sqls.must_equal []
579
579
  a.save
580
580
  check_sql_array("INSERT INTO albums (name) VALUES ('Al')",
581
581
  "INSERT INTO tags (name) VALUES ('T')",
@@ -588,7 +588,7 @@ describe "NestedAttributes plugin" do
588
588
  @Album.nested_attributes :tags, :transform=>proc{|parent, hash| hash[:name] << parent.name; hash }
589
589
  a = @Album.new(:name => 'Al')
590
590
  a.set(:tags_attributes=>[{:name=>'T'}, {:name=>'T2'}])
591
- @db.sqls.should == []
591
+ @db.sqls.must_equal []
592
592
  a.save
593
593
  check_sql_array("INSERT INTO albums (name) VALUES ('Al')",
594
594
  "INSERT INTO tags (name) VALUES ('TAl')",
@@ -608,7 +608,7 @@ describe "NestedAttributes plugin" do
608
608
  a = @Album.new(:name=>'Al')
609
609
  a.associations[:tags] = [@Tag.load(:id=>6, :name=>'A'), @Tag.load(:id=>7, :name=>'A2')]
610
610
  a.tags_attributes = [{:id=>6, :name=>'T'}, {:id=>7, :name=>'T2', :_remove=>true}, {:name=>'T3'}, {:id=>8, :name=>'T4'}, {:id=>9, :name=>'T5', :_remove=>true}]
611
- objs.should == [[@Tag.load(:id=>6, :name=>'T'), :update], [@Tag.load(:id=>7, :name=>'A2'), :remove], [@Tag.new(:name=>'T3'), :create]]
611
+ objs.must_equal [[@Tag.load(:id=>6, :name=>'T'), :update], [@Tag.load(:id=>7, :name=>'A2'), :remove], [@Tag.new(:name=>'T3'), :create]]
612
612
  end
613
613
 
614
614
  it "should raise an error if updating modifies the associated objects keys" do
@@ -627,9 +627,9 @@ describe "NestedAttributes plugin" do
627
627
  al.associations[:artist] = ar
628
628
  al.associations[:tags] = [t]
629
629
  ar.associations[:albums] = [al]
630
- proc{ar.set(:albums_attributes=>[{:id=>10, :name=>'Al2', :artist_id=>'3'}])}.should raise_error(Sequel::Error)
631
- proc{al.set(:artist_attributes=>{:id=>20, :name=>'Ar2', :artist_id=>'3'})}.should raise_error(Sequel::Error)
632
- proc{al.set(:tags_attributes=>[{:id=>30, :name=>'T2', :tag_id=>'3'}])}.should raise_error(Sequel::Error)
630
+ proc{ar.set(:albums_attributes=>[{:id=>10, :name=>'Al2', :artist_id=>'3'}])}.must_raise(Sequel::Error)
631
+ proc{al.set(:artist_attributes=>{:id=>20, :name=>'Ar2', :artist_id=>'3'})}.must_raise(Sequel::Error)
632
+ proc{al.set(:tags_attributes=>[{:id=>30, :name=>'T2', :tag_id=>'3'}])}.must_raise(Sequel::Error)
633
633
  end
634
634
 
635
635
  it "should accept a :fields option and only allow modification of those fields" do
@@ -640,14 +640,14 @@ describe "NestedAttributes plugin" do
640
640
  t = @Tag.load(:id=>30, :name=>'T', :number=>10)
641
641
  al.associations[:tags] = [t]
642
642
  al.set(:tags_attributes=>[{:id=>30, :name=>'T2'}, {:name=>'T3'}])
643
- @db.sqls.should == []
643
+ @db.sqls.must_equal []
644
644
  al.save
645
645
  check_sql_array("UPDATE albums SET name = 'Al' WHERE (id = 10)",
646
646
  "UPDATE tags SET name = 'T2' WHERE (id = 30)",
647
647
  "INSERT INTO tags (name) VALUES ('T3')",
648
648
  ["INSERT INTO at (album_id, tag_id) VALUES (10, 1)", "INSERT INTO at (tag_id, album_id) VALUES (1, 10)"])
649
- proc{al.set(:tags_attributes=>[{:id=>30, :name=>'T2', :number=>3}])}.should raise_error(Sequel::MassAssignmentRestriction)
650
- proc{al.set(:tags_attributes=>[{:name=>'T2', :number=>3}])}.should raise_error(Sequel::MassAssignmentRestriction)
649
+ proc{al.set(:tags_attributes=>[{:id=>30, :name=>'T2', :number=>3}])}.must_raise(Sequel::MassAssignmentRestriction)
650
+ proc{al.set(:tags_attributes=>[{:name=>'T2', :number=>3}])}.must_raise(Sequel::MassAssignmentRestriction)
651
651
  end
652
652
 
653
653
  it "should accept a proc for the :fields option that accepts the associated object and returns an array of fields" do
@@ -658,14 +658,14 @@ describe "NestedAttributes plugin" do
658
658
  t = @Tag.load(:id=>30, :name=>'T', :number=>10)
659
659
  al.associations[:tags] = [t]
660
660
  al.set(:tags_attributes=>[{:id=>30, :name=>'T2'}, {:name=>'T3'}])
661
- @db.sqls.should == []
661
+ @db.sqls.must_equal []
662
662
  al.save
663
663
  check_sql_array("UPDATE albums SET name = 'Al' WHERE (id = 10)",
664
664
  "UPDATE tags SET name = 'T2' WHERE (id = 30)",
665
665
  "INSERT INTO tags (name) VALUES ('T3')",
666
666
  ["INSERT INTO at (album_id, tag_id) VALUES (10, 1)", "INSERT INTO at (tag_id, album_id) VALUES (1, 10)"])
667
- proc{al.set(:tags_attributes=>[{:id=>30, :name=>'T2', :number=>3}])}.should raise_error(Sequel::MassAssignmentRestriction)
668
- proc{al.set(:tags_attributes=>[{:name=>'T2', :number=>3}])}.should raise_error(Sequel::MassAssignmentRestriction)
667
+ proc{al.set(:tags_attributes=>[{:id=>30, :name=>'T2', :number=>3}])}.must_raise(Sequel::MassAssignmentRestriction)
668
+ proc{al.set(:tags_attributes=>[{:name=>'T2', :number=>3}])}.must_raise(Sequel::MassAssignmentRestriction)
669
669
  end
670
670
 
671
671
  it "should allow per-call options via the set_nested_attributes method" do
@@ -676,22 +676,22 @@ describe "NestedAttributes plugin" do
676
676
  t = @Tag.load(:id=>30, :name=>'T', :number=>10)
677
677
  al.associations[:tags] = [t]
678
678
  al.set_nested_attributes(:tags, [{:id=>30, :name=>'T2'}, {:name=>'T3'}], :fields=>[:name])
679
- @db.sqls.should == []
679
+ @db.sqls.must_equal []
680
680
  al.save
681
681
  check_sql_array("UPDATE albums SET name = 'Al' WHERE (id = 10)",
682
682
  "UPDATE tags SET name = 'T2' WHERE (id = 30)",
683
683
  "INSERT INTO tags (name) VALUES ('T3')",
684
684
  ["INSERT INTO at (album_id, tag_id) VALUES (10, 1)", "INSERT INTO at (tag_id, album_id) VALUES (1, 10)"])
685
- proc{al.set_nested_attributes(:tags, [{:id=>30, :name=>'T2', :number=>3}], :fields=>[:name])}.should raise_error(Sequel::MassAssignmentRestriction)
686
- proc{al.set_nested_attributes(:tags, [{:name=>'T2', :number=>3}], :fields=>[:name])}.should raise_error(Sequel::MassAssignmentRestriction)
685
+ proc{al.set_nested_attributes(:tags, [{:id=>30, :name=>'T2', :number=>3}], :fields=>[:name])}.must_raise(Sequel::MassAssignmentRestriction)
686
+ proc{al.set_nested_attributes(:tags, [{:name=>'T2', :number=>3}], :fields=>[:name])}.must_raise(Sequel::MassAssignmentRestriction)
687
687
  end
688
688
 
689
689
  it "should have set_nested_attributes method raise error if called with a bad association" do
690
- proc{@Album.load(:id=>10, :name=>'Al').set_nested_attributes(:tags2, [{:id=>30, :name=>'T2', :number=>3}], :fields=>[:name])}.should raise_error(Sequel::Error)
690
+ proc{@Album.load(:id=>10, :name=>'Al').set_nested_attributes(:tags2, [{:id=>30, :name=>'T2', :number=>3}], :fields=>[:name])}.must_raise(Sequel::Error)
691
691
  end
692
692
 
693
693
  it "should have set_nested_attributes method raise error if called with an association that doesn't support nested attributes" do
694
694
  @Tag.columns :id, :name, :number
695
- proc{@Album.load(:id=>10, :name=>'Al').set_nested_attributes(:tags, [{:id=>30, :name=>'T2', :number=>3}], :fields=>[:name])}.should raise_error(Sequel::Error)
695
+ proc{@Album.load(:id=>10, :name=>'Al').set_nested_attributes(:tags, [{:id=>30, :name=>'T2', :number=>3}], :fields=>[:name])}.must_raise(Sequel::Error)
696
696
  end
697
697
  end