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
@@ -6,20 +6,20 @@ describe Sequel::Model, "set_schema" do
6
6
  @model.plugin :schema
7
7
  end
8
8
 
9
- specify "sets schema with implicit table name" do
9
+ it "sets schema with implicit table name" do
10
10
  @model.set_schema do
11
11
  primary_key :ssn, :type=>:string
12
12
  end
13
- @model.primary_key.should == :ssn
14
- @model.table_name.should == :items
13
+ @model.primary_key.must_equal :ssn
14
+ @model.table_name.must_equal :items
15
15
  end
16
16
 
17
- specify "sets schema with explicit table name" do
17
+ it "sets schema with explicit table name" do
18
18
  @model.set_schema :foo do
19
19
  primary_key :id
20
20
  end
21
- @model.primary_key.should == :id
22
- @model.table_name.should == :foo
21
+ @model.primary_key.must_equal :id
22
+ @model.table_name.must_equal :foo
23
23
  end
24
24
  end
25
25
 
@@ -38,37 +38,38 @@ describe Sequel::Model, "create_table and schema" do
38
38
 
39
39
  it "should get the create table SQL list from the db and execute it line by line" do
40
40
  @model.create_table
41
- DB.sqls.should == ['CREATE TABLE items (name text, price float NOT NULL)']
41
+ DB.sqls.must_equal ['CREATE TABLE items (name text, price float NOT NULL)']
42
42
  end
43
43
 
44
44
  it "should allow setting schema and creating the table in one call" do
45
45
  @model.create_table { text :name }
46
- DB.sqls.should == ['CREATE TABLE items (name text)']
46
+ DB.sqls.must_equal ['CREATE TABLE items (name text)']
47
47
  end
48
48
 
49
49
  it "should reload the schema from the database" do
50
50
  schem = {:name=>{:type=>:string}, :price=>{:type=>:float}}
51
- @model.db.should_receive(:schema).with(@model.dataset, :reload=>true).and_return(schem.to_a.sort_by{|x| x[0].to_s})
52
- @model.create_table
53
- @model.db_schema.should == schem
54
- @model.instance_variable_get(:@columns).should == [:name, :price]
51
+ @model.db.stub(:schema, schem.to_a.sort_by{|x| x[0].to_s}) do
52
+ @model.create_table
53
+ @model.db_schema.must_equal schem
54
+ end
55
+ @model.instance_variable_get(:@columns).must_equal [:name, :price]
55
56
  end
56
57
 
57
58
  it "should return the schema generator via schema" do
58
- @model.schema.should be_a_kind_of(Sequel::Schema::Generator)
59
+ @model.schema.must_be_kind_of(Sequel::Schema::Generator)
59
60
  end
60
61
 
61
62
  it "should use the superclasses schema if it exists" do
62
63
  @submodel = Class.new(@model)
63
- @submodel.schema.should be_a_kind_of(Sequel::Schema::Generator)
64
+ @submodel.schema.must_be_kind_of(Sequel::Schema::Generator)
64
65
  end
65
66
 
66
67
  it "should return nil if no schema is present" do
67
68
  @model = Class.new(Sequel::Model)
68
69
  @model.plugin :schema
69
- @model.schema.should == nil
70
+ @model.schema.must_equal nil
70
71
  @submodel = Class.new(@model)
71
- @submodel.schema.should == nil
72
+ @submodel.schema.must_equal nil
72
73
  end
73
74
  end
74
75
 
@@ -80,34 +81,37 @@ describe Sequel::Model, "schema methods" do
80
81
  end
81
82
 
82
83
  it "table_exists? should get the table name and question the model's db if table_exists?" do
83
- @model.db.should_receive(:table_exists?).and_return(false)
84
- @model.table_exists?.should == false
84
+ DB.stub(:table_exists?, false) do
85
+ @model.table_exists?.must_equal false
86
+ end
85
87
  end
86
88
 
87
89
  it "drop_table should drop the related table" do
88
90
  @model.drop_table
89
- DB.sqls.should == ['DROP TABLE items']
91
+ DB.sqls.must_equal ['DROP TABLE items']
90
92
  end
91
93
 
92
94
  it "drop_table? should drop the table if it exists" do
93
95
  @model.drop_table?
94
- DB.sqls.should == ["SELECT NULL AS nil FROM items LIMIT 1", 'DROP TABLE items']
96
+ DB.sqls.must_equal ["SELECT NULL AS nil FROM items LIMIT 1", 'DROP TABLE items']
95
97
  end
96
98
 
97
99
  it "create_table! should drop table if it exists and then create the table" do
98
100
  @model.create_table!
99
- DB.sqls.should == ["SELECT NULL AS nil FROM items LIMIT 1", 'DROP TABLE items', 'CREATE TABLE items ()']
101
+ DB.sqls.must_equal ["SELECT NULL AS nil FROM items LIMIT 1", 'DROP TABLE items', 'CREATE TABLE items ()']
100
102
  end
101
103
 
102
104
  it "create_table? should not create the table if it already exists" do
103
- @model.should_receive(:table_exists?).and_return(true)
104
- @model.create_table?
105
- DB.sqls.should == []
105
+ DB.stub(:table_exists?, true) do
106
+ @model.create_table?
107
+ end
108
+ DB.sqls.must_equal []
106
109
  end
107
110
 
108
111
  it "create_table? should create the table if it doesn't exist" do
109
- @model.should_receive(:table_exists?).and_return(false)
110
- @model.create_table?
111
- DB.sqls.should == ['CREATE TABLE items ()']
112
+ DB.stub(:table_exists?, false) do
113
+ @model.create_table?
114
+ end
115
+ DB.sqls.must_equal ['CREATE TABLE items ()']
112
116
  end
113
117
  end
@@ -10,17 +10,17 @@ describe "scissors plugin" do
10
10
 
11
11
  it "Model.delete should delete from the dataset" do
12
12
  @m.delete
13
- @m.db.sqls.should == ['DELETE FROM items']
13
+ @m.db.sqls.must_equal ['DELETE FROM items']
14
14
  end
15
15
 
16
16
  it "Model.update should update the dataset" do
17
17
  @m.update(:a=>1)
18
- @m.db.sqls.should == ['UPDATE items SET a = 1']
18
+ @m.db.sqls.must_equal ['UPDATE items SET a = 1']
19
19
  end
20
20
 
21
21
  it "Model.destory each instance in the dataset" do
22
22
  @m.dataset._fetch = {:id=>1}
23
23
  @m.destroy
24
- @m.db.sqls.should == ['BEGIN', 'SELECT * FROM items', 'DELETE FROM items WHERE id = 1', 'COMMIT']
24
+ @m.db.sqls.must_equal ['BEGIN', 'SELECT * FROM items', 'DELETE FROM items WHERE id = 1', 'COMMIT']
25
25
  end
26
26
  end
@@ -6,33 +6,33 @@ describe "Dataset#select_remove" do
6
6
  @d.columns :a, :b, :c
7
7
  end
8
8
 
9
- specify "should remove columns from the selected columns" do
10
- @d.sql.should == 'SELECT * FROM test'
11
- @d.select_remove(:a).sql.should == 'SELECT b, c FROM test'
12
- @d.select_remove(:b).sql.should == 'SELECT a, c FROM test'
13
- @d.select_remove(:c).sql.should == 'SELECT a, b FROM test'
9
+ it "should remove columns from the selected columns" do
10
+ @d.sql.must_equal 'SELECT * FROM test'
11
+ @d.select_remove(:a).sql.must_equal 'SELECT b, c FROM test'
12
+ @d.select_remove(:b).sql.must_equal 'SELECT a, c FROM test'
13
+ @d.select_remove(:c).sql.must_equal 'SELECT a, b FROM test'
14
14
  end
15
15
 
16
- specify "should work correctly if there are already columns selected" do
16
+ it "should work correctly if there are already columns selected" do
17
17
  d = @d.select(:a, :b, :c)
18
18
  d.columns :a, :b, :c
19
- d.select_remove(:c).sql.should == 'SELECT a, b FROM test'
19
+ d.select_remove(:c).sql.must_equal 'SELECT a, b FROM test'
20
20
  end
21
21
 
22
- specify "should have no effect if the columns given are not currently selected" do
23
- @d.select_remove(:d).sql.should == 'SELECT a, b, c FROM test'
22
+ it "should have no effect if the columns given are not currently selected" do
23
+ @d.select_remove(:d).sql.must_equal 'SELECT a, b, c FROM test'
24
24
  end
25
25
 
26
- specify "should handle expressions where Sequel can't determine the alias by itself" do
26
+ it "should handle expressions where Sequel can't determine the alias by itself" do
27
27
  d = @d.select(:a, Sequel.function(:b), Sequel.as(:c, :b))
28
28
  d.columns :a, :"b()", :b
29
- d.select_remove(:"b()").sql.should == 'SELECT a, c AS b FROM test'
29
+ d.select_remove(:"b()").sql.must_equal 'SELECT a, c AS b FROM test'
30
30
  end
31
31
 
32
- specify "should remove expressions if given exact expressions" do
32
+ it "should remove expressions if given exact expressions" do
33
33
  d = @d.select(:a, Sequel.function(:b), Sequel.as(:c, :b))
34
34
  d.columns :a, :"b()", :b
35
- d.select_remove(Sequel.function(:b)).sql.should == 'SELECT a, c AS b FROM test'
36
- d.select_remove(Sequel.as(:c, :b)).sql.should == 'SELECT a, b() FROM test'
35
+ d.select_remove(Sequel.function(:b)).sql.must_equal 'SELECT a, c AS b FROM test'
36
+ d.select_remove(Sequel.as(:c, :b)).sql.must_equal 'SELECT a, b() FROM test'
37
37
  end
38
38
  end
@@ -5,21 +5,21 @@ describe "Dataset#to_csv" do
5
5
  @ds = Sequel.mock(:fetch=>[{:a=>1, :b=>2, :c=>3}, {:a=>4, :b=>5, :c=>6}, {:a=>7, :b=>8, :c=>9}])[:items].columns(:a, :b, :c).extension(:sequel_3_dataset_methods)
6
6
  end
7
7
 
8
- specify "should format a CSV representation of the records" do
9
- @ds.to_csv.should == "a, b, c\r\n1, 2, 3\r\n4, 5, 6\r\n7, 8, 9\r\n"
8
+ it "should format a CSV representation of the records" do
9
+ @ds.to_csv.must_equal "a, b, c\r\n1, 2, 3\r\n4, 5, 6\r\n7, 8, 9\r\n"
10
10
  end
11
11
 
12
- specify "should exclude column titles if so specified" do
13
- @ds.to_csv(false).should == "1, 2, 3\r\n4, 5, 6\r\n7, 8, 9\r\n"
12
+ it "should exclude column titles if so specified" do
13
+ @ds.to_csv(false).must_equal "1, 2, 3\r\n4, 5, 6\r\n7, 8, 9\r\n"
14
14
  end
15
15
  end
16
16
 
17
17
  describe "Dataset#[]=" do
18
- specify "should perform an update on the specified filter" do
18
+ it "should perform an update on the specified filter" do
19
19
  db = Sequel.mock
20
20
  ds = db[:items].extension(:sequel_3_dataset_methods)
21
21
  ds[:a => 1] = {:x => 3}
22
- db.sqls.should == ['UPDATE items SET x = 3 WHERE (a = 1)']
22
+ db.sqls.must_equal ['UPDATE items SET x = 3 WHERE (a = 1)']
23
23
  end
24
24
  end
25
25
 
@@ -29,73 +29,73 @@ describe "Dataset#insert_multiple" do
29
29
  @ds = @db[:items].extension(:sequel_3_dataset_methods)
30
30
  end
31
31
 
32
- specify "should insert all items in the supplied array" do
32
+ it "should insert all items in the supplied array" do
33
33
  @ds.insert_multiple(['aa', 5, 3, {:a => 2}])
34
- @db.sqls.should == ["INSERT INTO items VALUES ('aa')",
34
+ @db.sqls.must_equal ["INSERT INTO items VALUES ('aa')",
35
35
  "INSERT INTO items VALUES (5)",
36
36
  "INSERT INTO items VALUES (3)",
37
37
  "INSERT INTO items (a) VALUES (2)"]
38
38
  end
39
39
 
40
- specify "should pass array items through the supplied block if given" do
40
+ it "should pass array items through the supplied block if given" do
41
41
  @ds.insert_multiple(["inevitable", "hello", "the ticking clock"]){|i| i.gsub('l', 'r')}
42
- @db.sqls.should == ["INSERT INTO items VALUES ('inevitabre')",
42
+ @db.sqls.must_equal ["INSERT INTO items VALUES ('inevitabre')",
43
43
  "INSERT INTO items VALUES ('herro')",
44
44
  "INSERT INTO items VALUES ('the ticking crock')"]
45
45
  end
46
46
 
47
- specify "should return array of inserted ids" do
48
- @ds.insert_multiple(['aa', 5, 3, {:a => 2}]).should == [2, 3, 4, 5]
47
+ it "should return array of inserted ids" do
48
+ @ds.insert_multiple(['aa', 5, 3, {:a => 2}]).must_equal [2, 3, 4, 5]
49
49
  end
50
50
 
51
- specify "should work exactly like in metioned in the example" do
51
+ it "should work exactly like in metioned in the example" do
52
52
  @ds.insert_multiple([{:x=>1}, {:x=>2}]){|row| row[:y] = row[:x] * 2 ; row }
53
53
  sqls = @db.sqls
54
- ["INSERT INTO items (x, y) VALUES (1, 2)", "INSERT INTO items (y, x) VALUES (2, 1)"].should include(sqls[0])
55
- ["INSERT INTO items (x, y) VALUES (2, 4)", "INSERT INTO items (y, x) VALUES (4, 2)"].should include(sqls[1])
54
+ ["INSERT INTO items (x, y) VALUES (1, 2)", "INSERT INTO items (y, x) VALUES (2, 1)"].must_include(sqls[0])
55
+ ["INSERT INTO items (x, y) VALUES (2, 4)", "INSERT INTO items (y, x) VALUES (4, 2)"].must_include(sqls[1])
56
56
  end
57
57
  end
58
58
 
59
59
  describe "Dataset#db=" do
60
- specify "should change the dataset's database" do
60
+ it "should change the dataset's database" do
61
61
  db = Sequel.mock
62
62
  ds = db[:items].extension(:sequel_3_dataset_methods)
63
63
  db2 = Sequel.mock
64
64
  ds.db = db2
65
- ds.db.should == db2
66
- ds.db.should_not == db
65
+ ds.db.must_equal db2
66
+ ds.db.wont_equal db
67
67
  end
68
68
  end
69
69
 
70
70
  describe "Dataset#opts=" do
71
- specify "should change the dataset's opts" do
71
+ it "should change the dataset's opts" do
72
72
  db = Sequel.mock
73
73
  ds = db[:items].extension(:sequel_3_dataset_methods)
74
- ds.sql.should == 'SELECT * FROM items'
74
+ ds.sql.must_equal 'SELECT * FROM items'
75
75
  ds.opts = {}
76
- ds.sql.should == 'SELECT *'
77
- ds.opts.should == {}
76
+ ds.sql.must_equal 'SELECT *'
77
+ ds.opts.must_equal({})
78
78
  end
79
79
  end
80
80
 
81
81
  describe "Dataset#set" do
82
- specify "should act as alias to #update" do
82
+ it "should act as alias to #update" do
83
83
  db = Sequel.mock
84
84
  ds = db[:items].extension(:sequel_3_dataset_methods)
85
85
  ds.set({:x => 3})
86
- db.sqls.should == ['UPDATE items SET x = 3']
86
+ db.sqls.must_equal ['UPDATE items SET x = 3']
87
87
  end
88
88
  end
89
89
 
90
90
  describe "Sequel::Dataset#qualify_to_first_source" do
91
- specify "should qualify to the first source" do
92
- Sequel.mock.dataset.extension(:sequel_3_dataset_methods).from(:t).filter{a<b}.qualify_to_first_source.sql.should == 'SELECT t.* FROM t WHERE (t.a < t.b)'
91
+ it "should qualify to the first source" do
92
+ Sequel.mock.dataset.extension(:sequel_3_dataset_methods).from(:t).filter{a<b}.qualify_to_first_source.sql.must_equal 'SELECT t.* FROM t WHERE (t.a < t.b)'
93
93
  end
94
94
  end
95
95
 
96
96
  describe "Sequel::Dataset#qualify_to" do
97
- specify "should qualify to the given table" do
98
- Sequel.mock.dataset.extension(:sequel_3_dataset_methods).from(:t).filter{a<b}.qualify_to(:e).sql.should == 'SELECT e.* FROM t WHERE (e.a < e.b)'
97
+ it "should qualify to the given table" do
98
+ Sequel.mock.dataset.extension(:sequel_3_dataset_methods).from(:t).filter{a<b}.qualify_to(:e).sql.must_equal 'SELECT e.* FROM t WHERE (e.a < e.b)'
99
99
  end
100
100
  end
101
101
 
@@ -17,82 +17,82 @@ describe "serialization_modification_detection plugin" do
17
17
  end
18
18
 
19
19
  it "should not detect columns that haven't been changed" do
20
- @o1.changed_columns.should == []
21
- @o1.h.should == {}
20
+ @o1.changed_columns.must_equal []
21
+ @o1.h.must_equal({})
22
22
  @o1.h[1] = 2
23
23
  @o1.h.clear
24
- @o1.changed_columns.should == []
24
+ @o1.changed_columns.must_equal []
25
25
 
26
- @o2.changed_columns.should == []
27
- @o2.h.should == {}
26
+ @o2.changed_columns.must_equal []
27
+ @o2.h.must_equal({})
28
28
  @o2.h[1] = 2
29
29
  @o2.h.clear
30
- @o2.changed_columns.should == []
30
+ @o2.changed_columns.must_equal []
31
31
  end
32
32
 
33
33
  it "should detect columns that have been changed" do
34
- @o1.changed_columns.should == []
35
- @o1.h.should == {}
34
+ @o1.changed_columns.must_equal []
35
+ @o1.h.must_equal({})
36
36
  @o1.h[1] = 2
37
- @o1.changed_columns.should == [:h]
37
+ @o1.changed_columns.must_equal [:h]
38
38
 
39
- @o2.changed_columns.should == []
40
- @o2.h.should == {}
39
+ @o2.changed_columns.must_equal []
40
+ @o2.h.must_equal({})
41
41
  @o2.h[1] = 2
42
- @o2.changed_columns.should == [:h]
42
+ @o2.changed_columns.must_equal [:h]
43
43
 
44
- @o3.changed_columns.should == []
45
- @o3.h.should == nil
44
+ @o3.changed_columns.must_equal []
45
+ @o3.h.must_equal nil
46
46
  @o3.h = {}
47
- @o3.changed_columns.should == [:h]
47
+ @o3.changed_columns.must_equal [:h]
48
48
 
49
- @o4.changed_columns.should == []
50
- @o4.h.should == nil
49
+ @o4.changed_columns.must_equal []
50
+ @o4.h.must_equal nil
51
51
  @o4.h = {}
52
- @o4.changed_columns.should == [:h]
52
+ @o4.changed_columns.must_equal [:h]
53
53
  end
54
54
 
55
55
  it "should report correct changed_columns after saving" do
56
56
  @o1.h[1] = 2
57
57
  @o1.save
58
- @o1.changed_columns.should == []
58
+ @o1.changed_columns.must_equal []
59
59
 
60
60
  @o2.h[1] = 2
61
61
  @o2.save_changes
62
- @o2.changed_columns.should == []
62
+ @o2.changed_columns.must_equal []
63
63
 
64
64
  @o3.h = {1=>2}
65
65
  @o3.save
66
- @o3.changed_columns.should == []
66
+ @o3.changed_columns.must_equal []
67
67
 
68
68
  @o4.h = {1=>2}
69
69
  @o4.save
70
- @o4.changed_columns.should == []
70
+ @o4.changed_columns.must_equal []
71
71
  end
72
72
 
73
73
  it "should work with frozen objects" do
74
- @o1.changed_columns.should == []
75
- @o1.h.should == {}
74
+ @o1.changed_columns.must_equal []
75
+ @o1.h.must_equal({})
76
76
  @o1.freeze
77
77
  @o1.h[1] = 2
78
- @o1.changed_columns.should == [:h]
78
+ @o1.changed_columns.must_equal [:h]
79
79
  end
80
80
 
81
81
  it "should work with duplicating objects" do
82
- @o2.changed_columns.should == []
82
+ @o2.changed_columns.must_equal []
83
83
  o = @o2.dup
84
- @o2.h.should == {}
84
+ @o2.h.must_equal({})
85
85
  @o2.h[1] = 2
86
- @o2.changed_columns.should == [:h]
87
- o.changed_columns.should == []
86
+ @o2.changed_columns.must_equal [:h]
87
+ o.changed_columns.must_equal []
88
88
  end
89
89
 
90
90
  it "should work with duplicating objects after modifying them" do
91
- @o2.changed_columns.should == []
92
- @o2.h.should == {}
91
+ @o2.changed_columns.must_equal []
92
+ @o2.h.must_equal({})
93
93
  @o2.h[1] = 2
94
- @o2.changed_columns.should == [:h]
94
+ @o2.changed_columns.must_equal [:h]
95
95
  o = @o2.dup
96
- o.changed_columns.should == [:h]
96
+ o.changed_columns.must_equal [:h]
97
97
  end
98
98
  end
@@ -15,15 +15,15 @@ describe "Serialization plugin" do
15
15
  it "should allow setting additional serializable attributes via plugin :serialization call" do
16
16
  @c.plugin :serialization, :yaml, :abc
17
17
  @c.create(:abc => 1, :def=> 2)
18
- DB.sqls.last.should =~ /INSERT INTO items \((abc, def|def, abc)\) VALUES \(('--- 1\n(\.\.\.\n)?', 2|2, '--- 1\n(\.\.\.\n)?')\)/
18
+ DB.sqls.last.must_match(/INSERT INTO items \((abc, def|def, abc)\) VALUES \(('--- 1\n(\.\.\.\n)?', 2|2, '--- 1\n(\.\.\.\n)?')\)/)
19
19
 
20
20
  @c.plugin :serialization, :marshal, :def
21
21
  @c.create(:abc => 1, :def=> 1)
22
- DB.sqls.last.should =~ /INSERT INTO items \((abc, def|def, abc)\) VALUES \(('--- 1\n(\.\.\.\n)?', 'BAhpBg==\n'|'BAhpBg==\n', '--- 1\n(\.\.\.\n)?')\)/
22
+ DB.sqls.last.must_match(/INSERT INTO items \((abc, def|def, abc)\) VALUES \(('--- 1\n(\.\.\.\n)?', 'BAhpBg==\n'|'BAhpBg==\n', '--- 1\n(\.\.\.\n)?')\)/)
23
23
 
24
24
  @c.plugin :serialization, :json, :ghi
25
25
  @c.create(:ghi => [123])
26
- DB.sqls.last.should =~ /INSERT INTO items \((ghi)\) VALUES \('\[123\]'\)/
26
+ DB.sqls.last.must_match(/INSERT INTO items \((ghi)\) VALUES \('\[123\]'\)/)
27
27
  end
28
28
 
29
29
  it "should handle validations of underlying column" do
@@ -32,16 +32,16 @@ describe "Serialization plugin" do
32
32
  def o.validate
33
33
  errors.add(:abc, "not present") unless self[:abc]
34
34
  end
35
- o.valid?.should == false
35
+ o.valid?.must_equal false
36
36
  o.abc = {}
37
- o.valid?.should == true
37
+ o.valid?.must_equal true
38
38
  end
39
39
 
40
40
  it "should set column values even when not validating" do
41
41
  @c.set_primary_key :id
42
42
  @c.plugin :serialization, :yaml, :abc
43
43
  @c.load({:id=>1}).set(:abc=>{}).save(:validate=>false)
44
- DB.sqls.last.gsub("\n", '').should == "UPDATE items SET abc = '--- {}' WHERE (id = 1)"
44
+ DB.sqls.last.gsub("\n", '').must_equal "UPDATE items SET abc = '--- {}' WHERE (id = 1)"
45
45
  end
46
46
 
47
47
  it "should allow serializing attributes to yaml" do
@@ -49,12 +49,12 @@ describe "Serialization plugin" do
49
49
  @c.create(:abc => 1)
50
50
  @c.create(:abc => "hello")
51
51
 
52
- DB.sqls.map{|s| s.sub("...\n", '')}.should == ["INSERT INTO items (abc) VALUES ('--- 1\n')", "INSERT INTO items (abc) VALUES ('--- hello\n')"]
52
+ DB.sqls.map{|s| s.sub("...\n", '')}.must_equal ["INSERT INTO items (abc) VALUES ('--- 1\n')", "INSERT INTO items (abc) VALUES ('--- hello\n')"]
53
53
  end
54
54
 
55
55
  it "serialized_columns should be the columns serialized" do
56
56
  @c.plugin :serialization, :yaml, :abc
57
- @c.serialized_columns.should == [:abc]
57
+ @c.serialized_columns.must_equal [:abc]
58
58
  end
59
59
 
60
60
  it "should allow serializing attributes to marshal" do
@@ -63,7 +63,7 @@ describe "Serialization plugin" do
63
63
  @c.create(:abc => "hello")
64
64
  x = [Marshal.dump("hello")].pack('m')
65
65
 
66
- DB.sqls.should == [ \
66
+ DB.sqls.must_equal [ \
67
67
  "INSERT INTO items (abc) VALUES ('BAhpBg==\n')", \
68
68
  "INSERT INTO items (abc) VALUES ('#{x}')", \
69
69
  ]
@@ -75,7 +75,7 @@ describe "Serialization plugin" do
75
75
  @c.create(:ghi => ["hello"])
76
76
 
77
77
  x = ["hello"].to_json
78
- DB.sqls.should == [ \
78
+ DB.sqls.must_equal [ \
79
79
  "INSERT INTO items (ghi) VALUES ('[1]')", \
80
80
  "INSERT INTO items (ghi) VALUES ('#{x}')", \
81
81
  ]
@@ -84,11 +84,11 @@ describe "Serialization plugin" do
84
84
  it "should allow serializing attributes using arbitrary callable" do
85
85
  @c.plugin :serialization, [proc{|s| s.reverse}, proc{}], :abc
86
86
  @c.create(:abc => "hello")
87
- DB.sqls.should == ["INSERT INTO items (abc) VALUES ('olleh')"]
87
+ DB.sqls.must_equal ["INSERT INTO items (abc) VALUES ('olleh')"]
88
88
  end
89
89
 
90
90
  it "should raise an error if specificing serializer as an unregistered symbol" do
91
- proc{@c.plugin :serialization, :foo, :abc}.should raise_error(Sequel::Error)
91
+ proc{@c.plugin :serialization, :foo, :abc}.must_raise(Sequel::Error)
92
92
  end
93
93
 
94
94
  it "should translate values to and from yaml serialization format using accessor methods" do
@@ -97,15 +97,15 @@ describe "Serialization plugin" do
97
97
  @c.dataset._fetch = {:id => 1, :abc => "--- 1\n", :def => "--- hello\n"}
98
98
 
99
99
  o = @c.first
100
- o.id.should == 1
101
- o.abc.should == 1
102
- o.abc.should == 1
103
- o.def.should == "hello"
104
- o.def.should == "hello"
100
+ o.id.must_equal 1
101
+ o.abc.must_equal 1
102
+ o.abc.must_equal 1
103
+ o.def.must_equal "hello"
104
+ o.def.must_equal "hello"
105
105
 
106
106
  o.update(:abc => 23)
107
107
  @c.create(:abc => [1, 2, 3])
108
- DB.sqls.should == ["SELECT * FROM items LIMIT 1",
108
+ DB.sqls.must_equal ["SELECT * FROM items LIMIT 1",
109
109
  "UPDATE items SET abc = '#{23.to_yaml}' WHERE (id = 1)",
110
110
  "INSERT INTO items (abc) VALUES ('#{[1, 2, 3].to_yaml}')",
111
111
  "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
@@ -117,15 +117,15 @@ describe "Serialization plugin" do
117
117
  @c.dataset._fetch = [:id => 1, :abc =>[Marshal.dump(1)].pack('m'), :def =>[Marshal.dump('hello')].pack('m')]
118
118
 
119
119
  o = @c.first
120
- o.id.should == 1
121
- o.abc.should == 1
122
- o.abc.should == 1
123
- o.def.should == "hello"
124
- o.def.should == "hello"
120
+ o.id.must_equal 1
121
+ o.abc.must_equal 1
122
+ o.abc.must_equal 1
123
+ o.def.must_equal "hello"
124
+ o.def.must_equal "hello"
125
125
 
126
126
  o.update(:abc => 23)
127
127
  @c.create(:abc => [1, 2, 3])
128
- DB.sqls.should == ["SELECT * FROM items LIMIT 1",
128
+ DB.sqls.must_equal ["SELECT * FROM items LIMIT 1",
129
129
  "UPDATE items SET abc = '#{[Marshal.dump(23)].pack('m')}' WHERE (id = 1)",
130
130
  "INSERT INTO items (abc) VALUES ('#{[Marshal.dump([1, 2, 3])].pack('m')}')",
131
131
  "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
@@ -137,8 +137,8 @@ describe "Serialization plugin" do
137
137
  @c.dataset._fetch = [:id => 1, :abc =>Marshal.dump(1), :def =>Marshal.dump('hello')]
138
138
 
139
139
  o = @c.first
140
- o.abc.should == 1
141
- o.def.should == "hello"
140
+ o.abc.must_equal 1
141
+ o.def.must_equal "hello"
142
142
  end
143
143
 
144
144
  it "should raise exception for bad marshal data" do
@@ -147,8 +147,8 @@ describe "Serialization plugin" do
147
147
  @c.dataset._fetch = [:id => 1, :abc =>'foo', :def =>'bar']
148
148
 
149
149
  o = @c.first
150
- proc{o.abc}.should raise_error
151
- proc{o.def}.should raise_error
150
+ proc{o.abc}.must_raise TypeError, ArgumentError
151
+ proc{o.def}.must_raise TypeError, ArgumentError
152
152
  end
153
153
 
154
154
  it "should translate values to and from json serialization format using accessor methods" do
@@ -157,16 +157,16 @@ describe "Serialization plugin" do
157
157
  @c.dataset._fetch = {:id => 1, :abc => [1].to_json, :def => ["hello"].to_json}
158
158
 
159
159
  o = @c.first
160
- o.id.should == 1
161
- o.abc.should == [1]
162
- o.abc.should == [1]
163
- o.def.should == ["hello"]
164
- o.def.should == ["hello"]
160
+ o.id.must_equal 1
161
+ o.abc.must_equal [1]
162
+ o.abc.must_equal [1]
163
+ o.def.must_equal ["hello"]
164
+ o.def.must_equal ["hello"]
165
165
 
166
166
  o.update(:abc => [23])
167
167
  @c.create(:abc => [1,2,3])
168
168
 
169
- DB.sqls.should == ["SELECT * FROM items LIMIT 1",
169
+ DB.sqls.must_equal ["SELECT * FROM items LIMIT 1",
170
170
  "UPDATE items SET abc = '#{[23].to_json}' WHERE (id = 1)",
171
171
  "INSERT INTO items (abc) VALUES ('#{[1,2,3].to_json}')",
172
172
  "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
@@ -178,16 +178,16 @@ describe "Serialization plugin" do
178
178
  @c.dataset._fetch = {:id => 1, :abc => 'cba', :def => 'olleh'}
179
179
 
180
180
  o = @c.first
181
- o.id.should == 1
182
- o.abc.should == 'abc'
183
- o.abc.should == 'abc'
184
- o.def.should == "hello"
185
- o.def.should == "hello"
181
+ o.id.must_equal 1
182
+ o.abc.must_equal 'abc'
183
+ o.abc.must_equal 'abc'
184
+ o.def.must_equal "hello"
185
+ o.def.must_equal "hello"
186
186
 
187
187
  o.update(:abc => 'foo')
188
188
  @c.create(:abc => 'bar')
189
189
 
190
- DB.sqls.should == ["SELECT * FROM items LIMIT 1",
190
+ DB.sqls.must_equal ["SELECT * FROM items LIMIT 1",
191
191
  "UPDATE items SET abc = 'oof' WHERE (id = 1)",
192
192
  "INSERT INTO items (abc) VALUES ('rab')",
193
193
  "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
@@ -195,21 +195,22 @@ describe "Serialization plugin" do
195
195
 
196
196
  it "should handle registration of custom serializer/deserializer pairs" do
197
197
  @c.set_primary_key :id
198
+ require 'sequel/plugins/serialization'
198
199
  Sequel::Plugins::Serialization.register_format(:reverse, proc{|s| s.reverse}, proc{|s| s.reverse})
199
200
  @c.plugin :serialization, :reverse, :abc, :def
200
201
  @c.dataset._fetch = {:id => 1, :abc => 'cba', :def => 'olleh'}
201
202
 
202
203
  o = @c.first
203
- o.id.should == 1
204
- o.abc.should == 'abc'
205
- o.abc.should == 'abc'
206
- o.def.should == "hello"
207
- o.def.should == "hello"
204
+ o.id.must_equal 1
205
+ o.abc.must_equal 'abc'
206
+ o.abc.must_equal 'abc'
207
+ o.def.must_equal "hello"
208
+ o.def.must_equal "hello"
208
209
 
209
210
  o.update(:abc => 'foo')
210
211
  @c.create(:abc => 'bar')
211
212
 
212
- DB.sqls.should == ["SELECT * FROM items LIMIT 1",
213
+ DB.sqls.must_equal ["SELECT * FROM items LIMIT 1",
213
214
  "UPDATE items SET abc = 'oof' WHERE (id = 1)",
214
215
  "INSERT INTO items (abc) VALUES ('rab')",
215
216
  "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
@@ -221,15 +222,15 @@ describe "Serialization plugin" do
221
222
  @c.dataset._fetch = {:id => 1, :abc => "--- 1\n", :def => "--- hello\n"}
222
223
 
223
224
  o = Class.new(@c).first
224
- o.id.should == 1
225
- o.abc.should == 1
226
- o.abc.should == 1
227
- o.def.should == "hello"
228
- o.def.should == "hello"
225
+ o.id.must_equal 1
226
+ o.abc.must_equal 1
227
+ o.abc.must_equal 1
228
+ o.def.must_equal "hello"
229
+ o.def.must_equal "hello"
229
230
 
230
231
  o.update(:abc => 23)
231
232
  Class.new(@c).create(:abc => [1, 2, 3])
232
- DB.sqls.should == ["SELECT * FROM items LIMIT 1",
233
+ DB.sqls.must_equal ["SELECT * FROM items LIMIT 1",
233
234
  "UPDATE items SET abc = '#{23.to_yaml}' WHERE (id = 1)",
234
235
  "INSERT INTO items (abc) VALUES ('#{[1, 2, 3].to_yaml}')",
235
236
  "SELECT * FROM items WHERE (id = 10) LIMIT 1"]
@@ -240,19 +241,19 @@ describe "Serialization plugin" do
240
241
  @c.plugin :serialization, :yaml, :abc, :def
241
242
  o = @c.load(:id => 1, :abc => "--- 1\n", :def => "--- hello\n")
242
243
  o.abc = 23
243
- o.deserialized_values.length.should == 1
244
- o.abc.should == 23
244
+ o.deserialized_values.length.must_equal 1
245
+ o.abc.must_equal 23
245
246
  o.refresh
246
- o.deserialized_values.length.should == 0
247
+ o.deserialized_values.length.must_equal 0
247
248
  end
248
249
 
249
250
  it "should not clear the deserialized columns when refreshing after saving a new object" do
250
251
  @c.set_primary_key :id
251
252
  @c.plugin :serialization, :yaml, :abc, :def
252
253
  o = @c.new(:abc => "--- 1\n", :def => "--- hello\n")
253
- o.deserialized_values.length.should == 2
254
+ o.deserialized_values.length.must_equal 2
254
255
  o.save
255
- o.deserialized_values.length.should == 2
256
+ o.deserialized_values.length.must_equal 2
256
257
  end
257
258
 
258
259
  it "should not clear the deserialized columns when refreshing after saving a new object with insert_select" do
@@ -261,17 +262,17 @@ describe "Serialization plugin" do
261
262
  def (@c.instance_dataset).supports_insert_select?() true end
262
263
  def (@c.instance_dataset).insert_select(*) {:id=>1} end
263
264
  o = @c.new(:abc => "--- 1\n", :def => "--- hello\n")
264
- o.deserialized_values.length.should == 2
265
+ o.deserialized_values.length.must_equal 2
265
266
  o.save
266
- o.deserialized_values.length.should == 2
267
+ o.deserialized_values.length.must_equal 2
267
268
  end
268
269
 
269
270
  it "should raise an error if calling internal serialization methods with bad columns" do
270
271
  @c.set_primary_key :id
271
272
  @c.plugin :serialization
272
273
  o = @c.load(:id => 1, :abc => "--- 1\n", :def => "--- hello\n")
273
- lambda{o.send(:serialize_value, :abc, 1)}.should raise_error(Sequel::Error)
274
- lambda{o.send(:deserialize_value, :abc, "--- hello\n")}.should raise_error(Sequel::Error)
274
+ lambda{o.send(:serialize_value, :abc, 1)}.must_raise(Sequel::Error)
275
+ lambda{o.send(:deserialize_value, :abc, "--- hello\n")}.must_raise(Sequel::Error)
275
276
  end
276
277
 
277
278
  it "should add the accessors to a module included in the class, so they can be easily overridden" do
@@ -282,7 +283,7 @@ describe "Serialization plugin" do
282
283
  end
283
284
  @c.plugin :serialization, :yaml, :abc
284
285
  o = @c.load(:abc => "--- 1\n")
285
- o.abc.should == "1-blah"
286
+ o.abc.must_equal "1-blah"
286
287
  end
287
288
 
288
289
  it "should call super to get the deserialized value from a previous accessor" do
@@ -294,7 +295,7 @@ describe "Serialization plugin" do
294
295
  @c.send(:include, m)
295
296
  @c.plugin :serialization, :yaml, :abc
296
297
  o = @c.load(:abc => 3)
297
- o.abc.should == 9
298
+ o.abc.must_equal 9
298
299
  end
299
300
 
300
301
  it "should work correctly with frozen instances" do
@@ -304,37 +305,37 @@ describe "Serialization plugin" do
304
305
 
305
306
  o = @c.first
306
307
  o.freeze
307
- o.abc.should == 1
308
- o.abc.should == 1
309
- o.def.should == "hello"
310
- o.def.should == "hello"
311
- proc{o.abc = 2}.should raise_error
312
- proc{o.def = 'h'}.should raise_error
308
+ o.abc.must_equal 1
309
+ o.abc.must_equal 1
310
+ o.def.must_equal "hello"
311
+ o.def.must_equal "hello"
312
+ proc{o.abc = 2}.must_raise
313
+ proc{o.def = 'h'}.must_raise
313
314
  end
314
315
 
315
316
  it "should have dup duplicate internal structures" do
316
317
  @c.plugin :serialization, :yaml, :abc, :def
317
318
  o = @c.new
318
- o.dup.deserialized_values.should == o.deserialized_values
319
- o.dup.deserialized_values.should_not equal(o.deserialized_values)
319
+ o.dup.deserialized_values.must_equal o.deserialized_values
320
+ o.dup.deserialized_values.wont_be_same_as(o.deserialized_values)
320
321
  end
321
322
 
322
323
  it "should have changed_columns include serialized columns if those columns have changed" do
323
324
  @c.plugin :serialization, :yaml, :abc, :def
324
325
  @c.dataset._fetch = {:id => 1, :abc => "--- 1\n", :def => "--- hello\n"}
325
326
  o = @c.first
326
- o.changed_columns.should == []
327
+ o.changed_columns.must_equal []
327
328
  o.abc = 1
328
- o.changed_columns.should == []
329
+ o.changed_columns.must_equal []
329
330
  o.abc = 1
330
- o.changed_columns.should == []
331
+ o.changed_columns.must_equal []
331
332
  o.abc = 2
332
- o.changed_columns.should == [:abc]
333
+ o.changed_columns.must_equal [:abc]
333
334
  o.def = 'hello'
334
- o.changed_columns.should == [:abc]
335
+ o.changed_columns.must_equal [:abc]
335
336
  o.def = 'hello'
336
- o.changed_columns.should == [:abc]
337
+ o.changed_columns.must_equal [:abc]
337
338
  o.def = 'hello2'
338
- o.changed_columns.should == [:abc, :def]
339
+ o.changed_columns.must_equal [:abc, :def]
339
340
  end
340
341
  end