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
@@ -10,45 +10,45 @@ describe "Sequel::Plugins::InputTransformer" do
10
10
 
11
11
  it "should apply transformation to input" do
12
12
  @o.name = ' name '
13
- @o.name.should == ' eman '
13
+ @o.name.must_equal ' eman '
14
14
  @o.name = [1, 2, 3]
15
- @o.name.should == [1, 2, 3]
15
+ @o.name.must_equal [1, 2, 3]
16
16
  end
17
17
 
18
18
  it "should not apply any transformers by default" do
19
19
  c = Class.new(Sequel::Model)
20
20
  c.columns :name, :b
21
21
  c.plugin :input_transformer
22
- c.new(:name => ' name ').name.should == ' name '
22
+ c.new(:name => ' name ').name.must_equal ' name '
23
23
  end
24
24
 
25
25
  it "should allow skipping of columns using .skip_input_transformer" do
26
26
  @c.skip_input_transformer :reverser, :name
27
27
  v = ' name '
28
28
  @o.name = v
29
- @o.name.should equal(v)
29
+ @o.name.must_be_same_as(v)
30
30
  end
31
31
 
32
32
  it "should work correctly in subclasses" do
33
33
  o = Class.new(@c).new
34
34
  o.name = ' name '
35
- o.name.should == ' eman '
35
+ o.name.must_equal ' eman '
36
36
  end
37
37
 
38
38
  it "should raise an error if adding input filter without name" do
39
- proc{@c.add_input_transformer(nil){}}.should raise_error(Sequel::Error)
40
- proc{@c.plugin(:input_transformer){}}.should raise_error(Sequel::Error)
39
+ proc{@c.add_input_transformer(nil){}}.must_raise(Sequel::Error)
40
+ proc{@c.plugin(:input_transformer){}}.must_raise(Sequel::Error)
41
41
  end
42
42
 
43
43
  it "should raise an error if adding input filter without block" do
44
- proc{@c.add_input_transformer(:foo)}.should raise_error(Sequel::Error)
45
- proc{@c.plugin(:input_transformer, :foo)}.should raise_error(Sequel::Error)
44
+ proc{@c.add_input_transformer(:foo)}.must_raise(Sequel::Error)
45
+ proc{@c.plugin(:input_transformer, :foo)}.must_raise(Sequel::Error)
46
46
  end
47
47
 
48
48
  it "should apply multiple input transformers in reverse order of their call" do
49
49
  @c.add_input_transformer(:add_bar){|v| v << 'bar'}
50
50
  @c.add_input_transformer(:add_foo){|v| v << 'foo'}
51
51
  @o.name = ' name '
52
- @o.name.should == 'raboof eman '
52
+ @o.name.must_equal 'raboof eman '
53
53
  end
54
54
  end
@@ -14,23 +14,23 @@ describe "Sequel::Plugins::InsertReturningSelect" do
14
14
 
15
15
  it "should add a returning clause when inserting using selected columns" do
16
16
  @Album.plugin :insert_returning_select
17
- @Album.create(:x=>2).should == @Album.load(:id=>1, :x=>2)
18
- @db.sqls.should == ['INSERT INTO albums (x) VALUES (2) RETURNING id, x']
17
+ @Album.create(:x=>2).must_equal @Album.load(:id=>1, :x=>2)
18
+ @db.sqls.must_equal ['INSERT INTO albums (x) VALUES (2) RETURNING id, x']
19
19
  end
20
20
 
21
21
  it "should not add a returning clause if selection does not consist of just columns" do
22
22
  @Album.dataset = @Album.dataset.select_append(Sequel.as(1, :b))
23
23
  @Album.plugin :insert_returning_select
24
24
  @db.sqls.clear
25
- @Album.create(:x=>2).should == @Album.load(:id=>1, :x=>2)
26
- @db.sqls.should == ['INSERT INTO albums (x) VALUES (2)', 'SELECT id, x, 1 AS b FROM albums WHERE (id = 1) LIMIT 1']
25
+ @Album.create(:x=>2).must_equal @Album.load(:id=>1, :x=>2)
26
+ @db.sqls.must_equal ['INSERT INTO albums (x) VALUES (2)', 'SELECT id, x, 1 AS b FROM albums WHERE (id = 1) LIMIT 1']
27
27
  end
28
28
 
29
29
  it "should not add a returning clause if database doesn't support it" do
30
30
  @db.extend_datasets{def supports_returning?(_) false end}
31
31
  @Album.plugin :insert_returning_select
32
- @Album.create(:x=>2).should == @Album.load(:id=>1, :x=>2)
33
- @db.sqls.should == ['INSERT INTO albums (x) VALUES (2)', 'SELECT id, x FROM albums WHERE (id = 1) LIMIT 1']
32
+ @Album.create(:x=>2).must_equal @Album.load(:id=>1, :x=>2)
33
+ @db.sqls.must_equal ['INSERT INTO albums (x) VALUES (2)', 'SELECT id, x FROM albums WHERE (id = 1) LIMIT 1']
34
34
  end
35
35
 
36
36
  it "should work correctly with subclasses" do
@@ -40,7 +40,7 @@ describe "Sequel::Plugins::InsertReturningSelect" do
40
40
  b.columns :id, :x
41
41
  b.dataset = @db[:albums].select(:id, :x)
42
42
  @db.sqls.clear
43
- b.create(:x=>2).should == b.load(:id=>1, :x=>2)
44
- @db.sqls.should == ['INSERT INTO albums (x) VALUES (2) RETURNING id, x']
43
+ b.create(:x=>2).must_equal b.load(:id=>1, :x=>2)
44
+ @db.sqls.must_equal ['INSERT INTO albums (x) VALUES (2) RETURNING id, x']
45
45
  end
46
46
  end
@@ -10,70 +10,70 @@ describe "instance_filters plugin" do
10
10
  DB.sqls
11
11
  end
12
12
 
13
- specify "should raise an error when updating a stale record" do
13
+ it "should raise an error when updating a stale record" do
14
14
  @p.update(:name=>'Bob')
15
- DB.sqls.should == ["UPDATE people SET name = 'Bob' WHERE (id = 1)"]
15
+ DB.sqls.must_equal ["UPDATE people SET name = 'Bob' WHERE (id = 1)"]
16
16
  @p.instance_filter(:name=>'Jim')
17
17
  @p.this.numrows = 0
18
- proc{@p.update(:name=>'Joe')}.should raise_error(Sequel::Plugins::InstanceFilters::Error)
19
- DB.sqls.should == ["UPDATE people SET name = 'Joe' WHERE ((id = 1) AND (name = 'Jim'))"]
18
+ proc{@p.update(:name=>'Joe')}.must_raise(Sequel::Plugins::InstanceFilters::Error)
19
+ DB.sqls.must_equal ["UPDATE people SET name = 'Joe' WHERE ((id = 1) AND (name = 'Jim'))"]
20
20
  end
21
21
 
22
- specify "should raise an error when destroying a stale record" do
22
+ it "should raise an error when destroying a stale record" do
23
23
  @p.destroy
24
- DB.sqls.should == ["DELETE FROM people WHERE id = 1"]
24
+ DB.sqls.must_equal ["DELETE FROM people WHERE id = 1"]
25
25
  @p.instance_filter(:name=>'Jim')
26
26
  @p.this.numrows = 0
27
- proc{@p.destroy}.should raise_error(Sequel::Plugins::InstanceFilters::Error)
28
- DB.sqls.should == ["DELETE FROM people WHERE ((id = 1) AND (name = 'Jim'))"]
27
+ proc{@p.destroy}.must_raise(Sequel::Plugins::InstanceFilters::Error)
28
+ DB.sqls.must_equal ["DELETE FROM people WHERE ((id = 1) AND (name = 'Jim'))"]
29
29
  end
30
30
 
31
- specify "should work when using the prepared_statements plugin" do
31
+ it "should work when using the prepared_statements plugin" do
32
32
  @c.plugin :prepared_statements
33
33
 
34
34
  @p.update(:name=>'Bob')
35
- DB.sqls.should == ["UPDATE people SET name = 'Bob' WHERE (id = 1)"]
35
+ DB.sqls.must_equal ["UPDATE people SET name = 'Bob' WHERE (id = 1)"]
36
36
  @p.instance_filter(:name=>'Jim')
37
37
  @p.this.numrows = 0
38
- proc{@p.update(:name=>'Joe')}.should raise_error(Sequel::Plugins::InstanceFilters::Error)
39
- DB.sqls.should == ["UPDATE people SET name = 'Joe' WHERE ((id = 1) AND (name = 'Jim'))"]
38
+ proc{@p.update(:name=>'Joe')}.must_raise(Sequel::Plugins::InstanceFilters::Error)
39
+ DB.sqls.must_equal ["UPDATE people SET name = 'Joe' WHERE ((id = 1) AND (name = 'Jim'))"]
40
40
 
41
41
  @p = @c.load(:id=>1, :name=>'John', :num=>1)
42
42
  @p.this.numrows = 1
43
43
  @p.destroy
44
- DB.sqls.should == ["DELETE FROM people WHERE (id = 1)"]
44
+ DB.sqls.must_equal ["DELETE FROM people WHERE (id = 1)"]
45
45
  @p.instance_filter(:name=>'Jim')
46
46
  @p.this.numrows = 0
47
- proc{@p.destroy}.should raise_error(Sequel::Plugins::InstanceFilters::Error)
48
- DB.sqls.should == ["DELETE FROM people WHERE ((id = 1) AND (name = 'Jim'))"]
47
+ proc{@p.destroy}.must_raise(Sequel::Plugins::InstanceFilters::Error)
48
+ DB.sqls.must_equal ["DELETE FROM people WHERE ((id = 1) AND (name = 'Jim'))"]
49
49
 
50
- @c.create.should be_a_kind_of(@c)
50
+ @c.create.must_be_kind_of(@c)
51
51
  end
52
52
 
53
- specify "should apply all instance filters" do
53
+ it "should apply all instance filters" do
54
54
  @p.instance_filter(:name=>'Jim')
55
55
  @p.instance_filter{num > 2}
56
56
  @p.update(:name=>'Bob')
57
- DB.sqls.should == ["UPDATE people SET name = 'Bob' WHERE ((id = 1) AND (name = 'Jim') AND (num > 2))"]
57
+ DB.sqls.must_equal ["UPDATE people SET name = 'Bob' WHERE ((id = 1) AND (name = 'Jim') AND (num > 2))"]
58
58
  end
59
59
 
60
- specify "should drop instance filters after updating" do
60
+ it "should drop instance filters after updating" do
61
61
  @p.instance_filter(:name=>'Joe')
62
62
  @p.update(:name=>'Joe')
63
- DB.sqls.should == ["UPDATE people SET name = 'Joe' WHERE ((id = 1) AND (name = 'Joe'))"]
63
+ DB.sqls.must_equal ["UPDATE people SET name = 'Joe' WHERE ((id = 1) AND (name = 'Joe'))"]
64
64
  @p.update(:name=>'Bob')
65
- DB.sqls.should == ["UPDATE people SET name = 'Bob' WHERE (id = 1)"]
65
+ DB.sqls.must_equal ["UPDATE people SET name = 'Bob' WHERE (id = 1)"]
66
66
  end
67
67
 
68
- specify "shouldn't allow instance filters on frozen objects" do
68
+ it "shouldn't allow instance filters on frozen objects" do
69
69
  @p.instance_filter(:name=>'Joe')
70
70
  @p.freeze
71
- proc{@p.instance_filter(:name=>'Jim')}.should raise_error
71
+ proc{@p.instance_filter(:name=>'Jim')}.must_raise
72
72
  end
73
73
 
74
- specify "should have dup duplicate internal structures" do
74
+ it "should have dup duplicate internal structures" do
75
75
  @p.instance_filter(:name=>'Joe')
76
- @p.dup.send(:instance_filters).should == @p.send(:instance_filters)
77
- @p.dup.send(:instance_filters).should_not equal(@p.send(:instance_filters))
76
+ @p.dup.send(:instance_filters).must_equal @p.send(:instance_filters)
77
+ @p.dup.send(:instance_filters).wont_be_same_as(@p.send(:instance_filters))
78
78
  end
79
79
  end
@@ -20,19 +20,19 @@ describe "InstanceHooks plugin" do
20
20
  @o.before_create_hook{r 2}
21
21
  @o.after_create_hook{r 3}
22
22
  @o.before_create_hook{r 4}
23
- @o.save.should_not == nil
24
- @r.should == [4, 2, 1, 3]
23
+ @o.save.wont_equal nil
24
+ @r.must_equal [4, 2, 1, 3]
25
25
  end
26
26
 
27
27
  it "should cancel the save if before_create_hook block returns false" do
28
28
  @o.after_create_hook{r 1}
29
29
  @o.before_create_hook{r false}
30
30
  @o.before_create_hook{r 4}
31
- @o.save.should == nil
32
- @r.should == [4, false]
31
+ @o.save.must_equal nil
32
+ @r.must_equal [4, false]
33
33
  @r.clear
34
- @o.save.should == nil
35
- @r.should == [4, false]
34
+ @o.save.must_equal nil
35
+ @r.must_equal [4, false]
36
36
  end
37
37
 
38
38
  it "should support before_update_hook and after_update_hook" do
@@ -40,21 +40,21 @@ describe "InstanceHooks plugin" do
40
40
  @x.before_update_hook{r 2}
41
41
  @x.after_update_hook{r 3}
42
42
  @x.before_update_hook{r 4}
43
- @x.save.should_not == nil
44
- @r.should == [4, 2, 1, 3]
45
- @x.save.should_not == nil
46
- @r.should == [4, 2, 1, 3]
43
+ @x.save.wont_equal nil
44
+ @r.must_equal [4, 2, 1, 3]
45
+ @x.save.wont_equal nil
46
+ @r.must_equal [4, 2, 1, 3]
47
47
  end
48
48
 
49
49
  it "should cancel the save if before_update_hook block returns false" do
50
50
  @x.after_update_hook{r 1}
51
51
  @x.before_update_hook{r false}
52
52
  @x.before_update_hook{r 4}
53
- @x.save.should == nil
54
- @r.should == [4, false]
53
+ @x.save.must_equal nil
54
+ @r.must_equal [4, false]
55
55
  @r.clear
56
- @x.save.should == nil
57
- @r.should == [4, false]
56
+ @x.save.must_equal nil
57
+ @r.must_equal [4, false]
58
58
  end
59
59
 
60
60
  it "should support before_save_hook and after_save_hook" do
@@ -62,36 +62,36 @@ describe "InstanceHooks plugin" do
62
62
  @o.before_save_hook{r 2}
63
63
  @o.after_save_hook{r 3}
64
64
  @o.before_save_hook{r 4}
65
- @o.save.should_not == nil
66
- @r.should == [4, 2, 1, 3]
65
+ @o.save.wont_equal nil
66
+ @r.must_equal [4, 2, 1, 3]
67
67
  @r.clear
68
68
 
69
69
  @x.after_save_hook{r 1}
70
70
  @x.before_save_hook{r 2}
71
71
  @x.after_save_hook{r 3}
72
72
  @x.before_save_hook{r 4}
73
- @x.save.should_not == nil
74
- @r.should == [4, 2, 1, 3]
75
- @x.save.should_not == nil
76
- @r.should == [4, 2, 1, 3]
73
+ @x.save.wont_equal nil
74
+ @r.must_equal [4, 2, 1, 3]
75
+ @x.save.wont_equal nil
76
+ @r.must_equal [4, 2, 1, 3]
77
77
  end
78
78
 
79
79
  it "should cancel the save if before_save_hook block returns false" do
80
80
  @x.after_save_hook{r 1}
81
81
  @x.before_save_hook{r false}
82
82
  @x.before_save_hook{r 4}
83
- @x.save.should == nil
84
- @r.should == [4, false]
83
+ @x.save.must_equal nil
84
+ @r.must_equal [4, false]
85
85
  @r.clear
86
86
 
87
87
  @x.after_save_hook{r 1}
88
88
  @x.before_save_hook{r false}
89
89
  @x.before_save_hook{r 4}
90
- @x.save.should == nil
91
- @r.should == [4, false]
90
+ @x.save.must_equal nil
91
+ @r.must_equal [4, false]
92
92
  @r.clear
93
- @x.save.should == nil
94
- @r.should == [4, false]
93
+ @x.save.must_equal nil
94
+ @r.must_equal [4, false]
95
95
  end
96
96
 
97
97
  it "should support before_destroy_hook and after_destroy_hook" do
@@ -99,16 +99,16 @@ describe "InstanceHooks plugin" do
99
99
  @x.before_destroy_hook{r 2}
100
100
  @x.after_destroy_hook{r 3}
101
101
  @x.before_destroy_hook{r 4}
102
- @x.destroy.should_not == nil
103
- @r.should == [4, 2, 1, 3]
102
+ @x.destroy.wont_equal nil
103
+ @r.must_equal [4, 2, 1, 3]
104
104
  end
105
105
 
106
106
  it "should cancel the destroy if before_destroy_hook block returns false" do
107
107
  @x.after_destroy_hook{r 1}
108
108
  @x.before_destroy_hook{r false}
109
109
  @x.before_destroy_hook{r 4}
110
- @x.destroy.should == nil
111
- @r.should == [4, false]
110
+ @x.destroy.must_equal nil
111
+ @r.must_equal [4, false]
112
112
  end
113
113
 
114
114
  it "should support before_validation_hook and after_validation_hook" do
@@ -116,19 +116,19 @@ describe "InstanceHooks plugin" do
116
116
  @o.before_validation_hook{r 2}
117
117
  @o.after_validation_hook{r 3}
118
118
  @o.before_validation_hook{r 4}
119
- @o.valid?.should == true
120
- @r.should == [4, 2, 1, 3]
119
+ @o.valid?.must_equal true
120
+ @r.must_equal [4, 2, 1, 3]
121
121
  end
122
122
 
123
123
  it "should cancel the save if before_validation_hook block returns false" do
124
124
  @o.after_validation_hook{r 1}
125
125
  @o.before_validation_hook{r false}
126
126
  @o.before_validation_hook{r 4}
127
- @o.valid?.should == false
128
- @r.should == [4, false]
127
+ @o.valid?.must_equal false
128
+ @r.must_equal [4, false]
129
129
  @r.clear
130
- @o.valid?.should == false
131
- @r.should == [4, false]
130
+ @o.valid?.must_equal false
131
+ @r.must_equal [4, false]
132
132
  end
133
133
 
134
134
  it "should clear only related hooks on successful create" do
@@ -140,15 +140,15 @@ describe "InstanceHooks plugin" do
140
140
  @o.after_save_hook{r 6}
141
141
  @o.before_create_hook{r 7}
142
142
  @o.after_create_hook{r 8}
143
- @o.save.should_not == nil
144
- @r.should == [5, 7, 8, 6]
143
+ @o.save.wont_equal nil
144
+ @r.must_equal [5, 7, 8, 6]
145
145
  @o.instance_variable_set(:@new, false)
146
- @o.save.should_not == nil
147
- @r.should == [5, 7, 8, 6, 4, 3]
148
- @o.save.should_not == nil
149
- @r.should == [5, 7, 8, 6, 4, 3]
146
+ @o.save.wont_equal nil
147
+ @r.must_equal [5, 7, 8, 6, 4, 3]
148
+ @o.save.wont_equal nil
149
+ @r.must_equal [5, 7, 8, 6, 4, 3]
150
150
  @o.destroy
151
- @r.should == [5, 7, 8, 6, 4, 3, 2, 1]
151
+ @r.must_equal [5, 7, 8, 6, 4, 3, 2, 1]
152
152
  end
153
153
 
154
154
  it "should clear only related hooks on successful update" do
@@ -158,12 +158,12 @@ describe "InstanceHooks plugin" do
158
158
  @x.after_update_hook{r 4}
159
159
  @x.before_save_hook{r 5}
160
160
  @x.after_save_hook{r 6}
161
- @x.save.should_not == nil
162
- @r.should == [5, 3, 4, 6]
163
- @x.save.should_not == nil
164
- @r.should == [5, 3, 4, 6]
161
+ @x.save.wont_equal nil
162
+ @r.must_equal [5, 3, 4, 6]
163
+ @x.save.wont_equal nil
164
+ @r.must_equal [5, 3, 4, 6]
165
165
  @x.destroy
166
- @r.should == [5, 3, 4, 6, 2, 1]
166
+ @r.must_equal [5, 3, 4, 6, 2, 1]
167
167
  end
168
168
 
169
169
  it "should clear only related hooks on successful destroy" do
@@ -172,23 +172,23 @@ describe "InstanceHooks plugin" do
172
172
  @x.before_update_hook{r 3}
173
173
  @x.before_save_hook{r 4}
174
174
  @x.destroy
175
- @r.should == [2, 1]
176
- @x.save.should_not == nil
177
- @r.should == [2, 1, 4, 3]
175
+ @r.must_equal [2, 1]
176
+ @x.save.wont_equal nil
177
+ @r.must_equal [2, 1, 4, 3]
178
178
  end
179
179
 
180
180
  it "should not clear validations hooks on successful save" do
181
181
  @x.after_validation_hook{@x.errors.add(:id, 'a') if @x.id == 1; r 1}
182
182
  @x.before_validation_hook{r 2}
183
- @x.save.should == nil
184
- @r.should == [2, 1]
185
- @x.save.should == nil
186
- @r.should == [2, 1, 2, 1]
183
+ @x.save.must_equal nil
184
+ @r.must_equal [2, 1]
185
+ @x.save.must_equal nil
186
+ @r.must_equal [2, 1, 2, 1]
187
187
  @x.id = 2
188
- @x.save.should == @x
189
- @r.should == [2, 1, 2, 1, 2, 1]
190
- @x.save.should == @x
191
- @r.should == [2, 1, 2, 1, 2, 1]
188
+ @x.save.must_equal @x
189
+ @r.must_equal [2, 1, 2, 1, 2, 1]
190
+ @x.save.must_equal @x
191
+ @r.must_equal [2, 1, 2, 1, 2, 1]
192
192
  end
193
193
 
194
194
  it "should not allow addition of instance hooks to frozen instances" do
@@ -197,10 +197,10 @@ describe "InstanceHooks plugin" do
197
197
  @x.before_update_hook{r 3}
198
198
  @x.before_save_hook{r 4}
199
199
  @x.freeze
200
- proc{@x.after_destroy_hook{r 1}}.should raise_error(Sequel::Error)
201
- proc{@x.before_destroy_hook{r 2}}.should raise_error(Sequel::Error)
202
- proc{@x.before_update_hook{r 3}}.should raise_error(Sequel::Error)
203
- proc{@x.before_save_hook{r 4}}.should raise_error(Sequel::Error)
200
+ proc{@x.after_destroy_hook{r 1}}.must_raise(Sequel::Error)
201
+ proc{@x.before_destroy_hook{r 2}}.must_raise(Sequel::Error)
202
+ proc{@x.before_update_hook{r 3}}.must_raise(Sequel::Error)
203
+ proc{@x.before_save_hook{r 4}}.must_raise(Sequel::Error)
204
204
  end
205
205
  end
206
206
 
@@ -230,47 +230,47 @@ describe "InstanceHooks plugin with transactions" do
230
230
  it "should support after_commit_hook" do
231
231
  @o.after_commit_hook{@db.execute('ac1')}
232
232
  @o.after_commit_hook{@db.execute('ac2')}
233
- @o.save.should_not be_nil
234
- @db.sqls.should == ['BEGIN', 'as', 'COMMIT', 'ac1', 'ac2']
233
+ @o.save.wont_equal nil
234
+ @db.sqls.must_equal ['BEGIN', 'as', 'COMMIT', 'ac1', 'ac2']
235
235
  end
236
236
 
237
237
  it "should support after_rollback_hook" do
238
238
  @or.after_rollback_hook{@db.execute('ar1')}
239
239
  @or.after_rollback_hook{@db.execute('ar2')}
240
- @or.save.should be_nil
241
- @db.sqls.should == ['BEGIN', 'as', 'ROLLBACK', 'ar1', 'ar2']
240
+ @or.save.must_equal nil
241
+ @db.sqls.must_equal ['BEGIN', 'as', 'ROLLBACK', 'ar1', 'ar2']
242
242
  end
243
243
 
244
244
  it "should support after_commit_hook" do
245
245
  @o.after_destroy_commit_hook{@db.execute('adc1')}
246
246
  @o.after_destroy_commit_hook{@db.execute('adc2')}
247
- @o.destroy.should_not be_nil
248
- @db.sqls.should == ['BEGIN', "DELETE FROM items WHERE (id = 1)", 'ad', 'COMMIT', 'adc1', 'adc2']
247
+ @o.destroy.wont_equal nil
248
+ @db.sqls.must_equal ['BEGIN', "DELETE FROM items WHERE (id = 1)", 'ad', 'COMMIT', 'adc1', 'adc2']
249
249
  end
250
250
 
251
251
  it "should support after_rollback_hook" do
252
252
  @or.after_destroy_rollback_hook{@db.execute('adr1')}
253
253
  @or.after_destroy_rollback_hook{@db.execute('adr2')}
254
- @or.destroy.should be_nil
255
- @db.sqls.should == ['BEGIN', "DELETE FROM items WHERE (id = 1)", 'ad', 'ROLLBACK', 'adr1', 'adr2']
254
+ @or.destroy.must_equal nil
255
+ @db.sqls.must_equal ['BEGIN', "DELETE FROM items WHERE (id = 1)", 'ad', 'ROLLBACK', 'adr1', 'adr2']
256
256
  end
257
257
 
258
258
  it "should have *_hook methods return self "do
259
- @o.before_destroy_hook{r 1}.should equal(@o)
260
- @o.before_validation_hook{r 1}.should equal(@o)
261
- @o.before_save_hook{r 1}.should equal(@o)
262
- @o.before_update_hook{r 1}.should equal(@o)
263
- @o.before_create_hook{r 1}.should equal(@o)
259
+ @o.before_destroy_hook{r 1}.must_be_same_as(@o)
260
+ @o.before_validation_hook{r 1}.must_be_same_as(@o)
261
+ @o.before_save_hook{r 1}.must_be_same_as(@o)
262
+ @o.before_update_hook{r 1}.must_be_same_as(@o)
263
+ @o.before_create_hook{r 1}.must_be_same_as(@o)
264
264
 
265
- @o.after_destroy_hook{r 1}.should equal(@o)
266
- @o.after_validation_hook{r 1}.should equal(@o)
267
- @o.after_save_hook{r 1}.should equal(@o)
268
- @o.after_update_hook{r 1}.should equal(@o)
269
- @o.after_create_hook{r 1}.should equal(@o)
270
- @o.after_commit_hook{r 1}.should equal(@o)
271
- @o.after_rollback_hook{r 1}.should equal(@o)
272
- @o.after_destroy_commit_hook{r 1}.should equal(@o)
273
- @o.after_destroy_rollback_hook{r 1}.should equal(@o)
265
+ @o.after_destroy_hook{r 1}.must_be_same_as(@o)
266
+ @o.after_validation_hook{r 1}.must_be_same_as(@o)
267
+ @o.after_save_hook{r 1}.must_be_same_as(@o)
268
+ @o.after_update_hook{r 1}.must_be_same_as(@o)
269
+ @o.after_create_hook{r 1}.must_be_same_as(@o)
270
+ @o.after_commit_hook{r 1}.must_be_same_as(@o)
271
+ @o.after_rollback_hook{r 1}.must_be_same_as(@o)
272
+ @o.after_destroy_commit_hook{r 1}.must_be_same_as(@o)
273
+ @o.after_destroy_rollback_hook{r 1}.must_be_same_as(@o)
274
274
  end
275
275
 
276
276
  end