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
@@ -17,51 +17,51 @@ describe "pg_enum extension" do
17
17
  end
18
18
 
19
19
  it "should include enum information in the schema entry" do
20
- @db.schema(:a).should == [[:a, {:oid=>1, :ruby_default=>nil, :type=>:enum, :enum_values=>%w'a b c'}]]
20
+ @db.schema(:a).must_equal [[:a, {:oid=>1, :ruby_default=>nil, :type=>:enum, :enum_values=>%w'a b c'}]]
21
21
  end
22
22
 
23
23
  it "should typecast objects to string" do
24
- @db.typecast_value(:enum, :a).should == 'a'
24
+ @db.typecast_value(:enum, :a).must_equal 'a'
25
25
  end
26
26
 
27
27
  it "should add array parsers for enum values" do
28
- @db.conversion_procs[212389].call('{a,b,c}').should == %w'a b c'
28
+ @db.conversion_procs[212389].call('{a,b,c}').must_equal %w'a b c'
29
29
  end
30
30
 
31
31
  it "should support #create_enum method for adding a new enum" do
32
32
  @db.create_enum(:foo, [:a, :b, :c])
33
- @db.sqls.first.should == "CREATE TYPE foo AS ENUM ('a', 'b', 'c')"
33
+ @db.sqls.first.must_equal "CREATE TYPE foo AS ENUM ('a', 'b', 'c')"
34
34
  @db.create_enum(:sch__foo, %w'a b c')
35
- @db.sqls.first.should == "CREATE TYPE sch.foo AS ENUM ('a', 'b', 'c')"
35
+ @db.sqls.first.must_equal "CREATE TYPE sch.foo AS ENUM ('a', 'b', 'c')"
36
36
  end
37
37
 
38
38
  it "should support #drop_enum method for dropping an enum" do
39
39
  @db.drop_enum(:foo)
40
- @db.sqls.first.should == "DROP TYPE foo"
40
+ @db.sqls.first.must_equal "DROP TYPE foo"
41
41
  @db.drop_enum(:sch__foo, :if_exists=>true)
42
- @db.sqls.first.should == "DROP TYPE IF EXISTS sch.foo"
42
+ @db.sqls.first.must_equal "DROP TYPE IF EXISTS sch.foo"
43
43
  @db.drop_enum('foo', :cascade=>true)
44
- @db.sqls.first.should == "DROP TYPE foo CASCADE"
44
+ @db.sqls.first.must_equal "DROP TYPE foo CASCADE"
45
45
  end
46
46
 
47
47
  it "should support #add_enum_value method for adding value to an existing enum" do
48
48
  @db.add_enum_value(:foo, :a)
49
- @db.sqls.first.should == "ALTER TYPE foo ADD VALUE 'a'"
49
+ @db.sqls.first.must_equal "ALTER TYPE foo ADD VALUE 'a'"
50
50
  end
51
51
 
52
52
  it "should support :before option for #add_enum_value method for adding value before an existing enum value" do
53
53
  @db.add_enum_value('foo', :a, :before=>:b)
54
- @db.sqls.first.should == "ALTER TYPE foo ADD VALUE 'a' BEFORE 'b'"
54
+ @db.sqls.first.must_equal "ALTER TYPE foo ADD VALUE 'a' BEFORE 'b'"
55
55
  end
56
56
 
57
57
  it "should support :after option for #add_enum_value method for adding value after an existing enum value" do
58
58
  @db.add_enum_value(:sch__foo, :a, :after=>:b)
59
- @db.sqls.first.should == "ALTER TYPE sch.foo ADD VALUE 'a' AFTER 'b'"
59
+ @db.sqls.first.must_equal "ALTER TYPE sch.foo ADD VALUE 'a' AFTER 'b'"
60
60
  end
61
61
 
62
62
  it "should support :if_not_exists option for #add_enum_value method for not adding the value if it exists" do
63
63
  @db.add_enum_value(:foo, :a, :if_not_exists=>true)
64
- @db.sqls.first.should == "ALTER TYPE foo ADD VALUE IF NOT EXISTS 'a'"
64
+ @db.sqls.first.must_equal "ALTER TYPE foo ADD VALUE IF NOT EXISTS 'a'"
65
65
  end
66
66
 
67
67
  it "should reverse a create_enum directive in a migration" do
@@ -84,7 +84,7 @@ describe "pg_enum extension" do
84
84
  Sequel.migration{change(&p)}.apply(db, :up)
85
85
  Sequel.migration{change(&p)}.apply(db, :down)
86
86
 
87
- db.actions.should == [
87
+ db.actions.must_equal [
88
88
  [:create_enum, :type_name, ["value1", "value2", "value3"] ],
89
89
  [:drop_enum, :type_name]
90
90
  ]
@@ -9,39 +9,39 @@ describe "Sequel::Postgres::HStoreOp" do
9
9
  end
10
10
 
11
11
  it "#- should use the - operator" do
12
- @ds.literal(@h - :a).should == "(h - a)"
12
+ @ds.literal(@h - :a).must_equal "(h - a)"
13
13
  end
14
14
 
15
15
  it "#- should cast String argument to text when using - operator" do
16
- @ds.literal(@h - 'a').should == "(h - CAST('a' AS text))"
16
+ @ds.literal(@h - 'a').must_equal "(h - CAST('a' AS text))"
17
17
  end
18
18
 
19
19
  it "#- should not cast LiteralString argument to text when using - operator" do
20
- @ds.literal(@h - Sequel.lit('a')).should == "(h - a)"
20
+ @ds.literal(@h - Sequel.lit('a')).must_equal "(h - a)"
21
21
  end
22
22
 
23
23
  it "#- should handle arrays" do
24
- @ds.literal(@h - %w'a').should == "(h - ARRAY['a'])"
24
+ @ds.literal(@h - %w'a').must_equal "(h - ARRAY['a'])"
25
25
  end
26
26
 
27
27
  it "#- should handle hashes" do
28
- @ds.literal(@h - {'a'=>'b'}).should == "(h - '\"a\"=>\"b\"'::hstore)"
28
+ @ds.literal(@h - {'a'=>'b'}).must_equal "(h - '\"a\"=>\"b\"'::hstore)"
29
29
  end
30
30
 
31
31
  it "#- should return an HStoreOp" do
32
- @ds.literal((@h - :a)['a']).should == "((h - a) -> 'a')"
32
+ @ds.literal((@h - :a)['a']).must_equal "((h - a) -> 'a')"
33
33
  end
34
34
 
35
35
  it "#[] should use the -> operator" do
36
- @ds.literal(@h['a']).should == "(h -> 'a')"
36
+ @ds.literal(@h['a']).must_equal "(h -> 'a')"
37
37
  end
38
38
 
39
39
  it "#[] should handle arrays" do
40
- @ds.literal(@h[%w'a']).should == "(h -> ARRAY['a'])"
40
+ @ds.literal(@h[%w'a']).must_equal "(h -> ARRAY['a'])"
41
41
  end
42
42
 
43
43
  it "#[] should return a PGArrayOp if given an array" do
44
- @ds.literal(@h[%w'a'][0]).should == "(h -> ARRAY['a'])[0]"
44
+ @ds.literal(@h[%w'a'][0]).must_equal "(h -> ARRAY['a'])[0]"
45
45
  end
46
46
 
47
47
  it "#[] should not return a PGArrayOp if given an array but pg_array_op is not supported" do
@@ -49,188 +49,188 @@ describe "Sequel::Postgres::HStoreOp" do
49
49
  module Sequel::Postgres::HStoreOp::Sequel
50
50
  SQL = ::Sequel::SQL
51
51
  end
52
- @ds.literal(@h[%w'a']).should_not be_a_kind_of(Sequel::Postgres::ArrayOp)
52
+ @ds.literal(@h[%w'a']).wont_be_kind_of(Sequel::Postgres::ArrayOp)
53
53
  ensure
54
54
  Sequel::Postgres::HStoreOp.send(:remove_const, :Sequel)
55
55
  end
56
56
  end
57
57
 
58
58
  it "#[] should return a PGArrayOp if given a PGArray" do
59
- @ds.literal(@h[Sequel.pg_array(%w'a')][0]).should == "(h -> ARRAY['a'])[0]"
59
+ @ds.literal(@h[Sequel.pg_array(%w'a')][0]).must_equal "(h -> ARRAY['a'])[0]"
60
60
  end
61
61
 
62
62
  it "#[] should return a PGArrayOp if given a PGArrayOp" do
63
- @ds.literal(@h[Sequel.pg_array_op(:a)][0]).should == "(h -> a)[0]"
63
+ @ds.literal(@h[Sequel.pg_array_op(:a)][0]).must_equal "(h -> a)[0]"
64
64
  end
65
65
 
66
66
  it "#[] should return a string expression" do
67
- @ds.literal(@h['a'] + 'b').should == "((h -> 'a') || 'b')"
67
+ @ds.literal(@h['a'] + 'b').must_equal "((h -> 'a') || 'b')"
68
68
  end
69
69
 
70
70
  it "#concat and #merge should use the || operator" do
71
- @ds.literal(@h.concat(:h1)).should == "(h || h1)"
72
- @ds.literal(@h.merge(:h1)).should == "(h || h1)"
71
+ @ds.literal(@h.concat(:h1)).must_equal "(h || h1)"
72
+ @ds.literal(@h.merge(:h1)).must_equal "(h || h1)"
73
73
  end
74
74
 
75
75
  it "#concat and #merge should handle hashes" do
76
- @ds.literal(@h.concat('a'=>'b')).should == "(h || '\"a\"=>\"b\"'::hstore)"
77
- @ds.literal(@h.merge('a'=>'b')).should == "(h || '\"a\"=>\"b\"'::hstore)"
76
+ @ds.literal(@h.concat('a'=>'b')).must_equal "(h || '\"a\"=>\"b\"'::hstore)"
77
+ @ds.literal(@h.merge('a'=>'b')).must_equal "(h || '\"a\"=>\"b\"'::hstore)"
78
78
  end
79
79
 
80
80
  it "#concat should return an HStoreOp" do
81
- @ds.literal(@h.concat(:h1)['a']).should == "((h || h1) -> 'a')"
81
+ @ds.literal(@h.concat(:h1)['a']).must_equal "((h || h1) -> 'a')"
82
82
  end
83
83
 
84
84
  it "#contain_all should use the ?& operator" do
85
- @ds.literal(@h.contain_all(:h1)).should == "(h ?& h1)"
85
+ @ds.literal(@h.contain_all(:h1)).must_equal "(h ?& h1)"
86
86
  end
87
87
 
88
88
  it "#contain_all handle arrays" do
89
- @ds.literal(@h.contain_all(%w'h1')).should == "(h ?& ARRAY['h1'])"
89
+ @ds.literal(@h.contain_all(%w'h1')).must_equal "(h ?& ARRAY['h1'])"
90
90
  end
91
91
 
92
92
  it "#contain_any should use the ?| operator" do
93
- @ds.literal(@h.contain_any(:h1)).should == "(h ?| h1)"
93
+ @ds.literal(@h.contain_any(:h1)).must_equal "(h ?| h1)"
94
94
  end
95
95
 
96
96
  it "#contain_any should handle arrays" do
97
- @ds.literal(@h.contain_any(%w'h1')).should == "(h ?| ARRAY['h1'])"
97
+ @ds.literal(@h.contain_any(%w'h1')).must_equal "(h ?| ARRAY['h1'])"
98
98
  end
99
99
 
100
100
  it "#contains should use the @> operator" do
101
- @ds.literal(@h.contains(:h1)).should == "(h @> h1)"
101
+ @ds.literal(@h.contains(:h1)).must_equal "(h @> h1)"
102
102
  end
103
103
 
104
104
  it "#contains should handle hashes" do
105
- @ds.literal(@h.contains('a'=>'b')).should == "(h @> '\"a\"=>\"b\"'::hstore)"
105
+ @ds.literal(@h.contains('a'=>'b')).must_equal "(h @> '\"a\"=>\"b\"'::hstore)"
106
106
  end
107
107
 
108
108
  it "#contained_by should use the <@ operator" do
109
- @ds.literal(@h.contained_by(:h1)).should == "(h <@ h1)"
109
+ @ds.literal(@h.contained_by(:h1)).must_equal "(h <@ h1)"
110
110
  end
111
111
 
112
112
  it "#contained_by should handle hashes" do
113
- @ds.literal(@h.contained_by('a'=>'b')).should == "(h <@ '\"a\"=>\"b\"'::hstore)"
113
+ @ds.literal(@h.contained_by('a'=>'b')).must_equal "(h <@ '\"a\"=>\"b\"'::hstore)"
114
114
  end
115
115
 
116
116
  it "#defined should use the defined function" do
117
- @ds.literal(@h.defined('a')).should == "defined(h, 'a')"
117
+ @ds.literal(@h.defined('a')).must_equal "defined(h, 'a')"
118
118
  end
119
119
 
120
120
  it "#delete should use the delete function" do
121
- @ds.literal(@h.delete('a')).should == "delete(h, 'a')"
121
+ @ds.literal(@h.delete('a')).must_equal "delete(h, 'a')"
122
122
  end
123
123
 
124
124
  it "#delete should handle arrays" do
125
- @ds.literal(@h.delete(%w'a')).should == "delete(h, ARRAY['a'])"
125
+ @ds.literal(@h.delete(%w'a')).must_equal "delete(h, ARRAY['a'])"
126
126
  end
127
127
 
128
128
  it "#delete should handle hashes" do
129
- @ds.literal(@h.delete('a'=>'b')).should == "delete(h, '\"a\"=>\"b\"'::hstore)"
129
+ @ds.literal(@h.delete('a'=>'b')).must_equal "delete(h, '\"a\"=>\"b\"'::hstore)"
130
130
  end
131
131
 
132
132
  it "#delete should return an HStoreOp" do
133
- @ds.literal(@h.delete('a')['a']).should == "(delete(h, 'a') -> 'a')"
133
+ @ds.literal(@h.delete('a')['a']).must_equal "(delete(h, 'a') -> 'a')"
134
134
  end
135
135
 
136
136
  it "#each should use the each function" do
137
- @ds.literal(@h.each).should == "each(h)"
137
+ @ds.literal(@h.each).must_equal "each(h)"
138
138
  end
139
139
 
140
140
  it "#has_key? and aliases should use the ? operator" do
141
- @ds.literal(@h.has_key?('a')).should == "(h ? 'a')"
142
- @ds.literal(@h.key?('a')).should == "(h ? 'a')"
143
- @ds.literal(@h.member?('a')).should == "(h ? 'a')"
144
- @ds.literal(@h.include?('a')).should == "(h ? 'a')"
145
- @ds.literal(@h.exist?('a')).should == "(h ? 'a')"
141
+ @ds.literal(@h.has_key?('a')).must_equal "(h ? 'a')"
142
+ @ds.literal(@h.key?('a')).must_equal "(h ? 'a')"
143
+ @ds.literal(@h.member?('a')).must_equal "(h ? 'a')"
144
+ @ds.literal(@h.include?('a')).must_equal "(h ? 'a')"
145
+ @ds.literal(@h.exist?('a')).must_equal "(h ? 'a')"
146
146
  end
147
147
 
148
148
  it "#hstore should return the receiver" do
149
- @h.hstore.should equal(@h)
149
+ @h.hstore.must_be_same_as(@h)
150
150
  end
151
151
 
152
152
  it "#keys and #akeys should use the akeys function" do
153
- @ds.literal(@h.keys).should == "akeys(h)"
154
- @ds.literal(@h.akeys).should == "akeys(h)"
153
+ @ds.literal(@h.keys).must_equal "akeys(h)"
154
+ @ds.literal(@h.akeys).must_equal "akeys(h)"
155
155
  end
156
156
 
157
157
  it "#keys and #akeys should return PGArrayOps" do
158
- @ds.literal(@h.keys[0]).should == "akeys(h)[0]"
159
- @ds.literal(@h.akeys[0]).should == "akeys(h)[0]"
158
+ @ds.literal(@h.keys[0]).must_equal "akeys(h)[0]"
159
+ @ds.literal(@h.akeys[0]).must_equal "akeys(h)[0]"
160
160
  end
161
161
 
162
162
  it "#populate should use the populate_record function" do
163
- @ds.literal(@h.populate(:a)).should == "populate_record(a, h)"
163
+ @ds.literal(@h.populate(:a)).must_equal "populate_record(a, h)"
164
164
  end
165
165
 
166
166
  it "#record_set should use the #= operator" do
167
- @ds.literal(@h.record_set(:a)).should == "(a #= h)"
167
+ @ds.literal(@h.record_set(:a)).must_equal "(a #= h)"
168
168
  end
169
169
 
170
170
  it "#skeys should use the skeys function" do
171
- @ds.literal(@h.skeys).should == "skeys(h)"
171
+ @ds.literal(@h.skeys).must_equal "skeys(h)"
172
172
  end
173
173
 
174
174
  it "#slice should should use the slice function" do
175
- @ds.literal(@h.slice(:a)).should == "slice(h, a)"
175
+ @ds.literal(@h.slice(:a)).must_equal "slice(h, a)"
176
176
  end
177
177
 
178
178
  it "#slice should handle arrays" do
179
- @ds.literal(@h.slice(%w'a')).should == "slice(h, ARRAY['a'])"
179
+ @ds.literal(@h.slice(%w'a')).must_equal "slice(h, ARRAY['a'])"
180
180
  end
181
181
 
182
182
  it "#slice should return an HStoreOp" do
183
- @ds.literal(@h.slice(:a)['a']).should == "(slice(h, a) -> 'a')"
183
+ @ds.literal(@h.slice(:a)['a']).must_equal "(slice(h, a) -> 'a')"
184
184
  end
185
185
 
186
186
  it "#svals should use the svals function" do
187
- @ds.literal(@h.svals).should == "svals(h)"
187
+ @ds.literal(@h.svals).must_equal "svals(h)"
188
188
  end
189
189
 
190
190
  it "#to_array should use the hstore_to_array function" do
191
- @ds.literal(@h.to_array).should == "hstore_to_array(h)"
191
+ @ds.literal(@h.to_array).must_equal "hstore_to_array(h)"
192
192
  end
193
193
 
194
194
  it "#to_array should return a PGArrayOp" do
195
- @ds.literal(@h.to_array[0]).should == "hstore_to_array(h)[0]"
195
+ @ds.literal(@h.to_array[0]).must_equal "hstore_to_array(h)[0]"
196
196
  end
197
197
 
198
198
  it "#to_matrix should use the hstore_to_matrix function" do
199
- @ds.literal(@h.to_matrix).should == "hstore_to_matrix(h)"
199
+ @ds.literal(@h.to_matrix).must_equal "hstore_to_matrix(h)"
200
200
  end
201
201
 
202
202
  it "#to_matrix should return a PGArrayOp" do
203
- @ds.literal(@h.to_matrix[0]).should == "hstore_to_matrix(h)[0]"
203
+ @ds.literal(@h.to_matrix[0]).must_equal "hstore_to_matrix(h)[0]"
204
204
  end
205
205
 
206
206
  it "#values and #avals should use the avals function" do
207
- @ds.literal(@h.values).should == "avals(h)"
208
- @ds.literal(@h.avals).should == "avals(h)"
207
+ @ds.literal(@h.values).must_equal "avals(h)"
208
+ @ds.literal(@h.avals).must_equal "avals(h)"
209
209
  end
210
210
 
211
211
  it "#values and #avals should return PGArrayOps" do
212
- @ds.literal(@h.values[0]).should == "avals(h)[0]"
213
- @ds.literal(@h.avals[0]).should == "avals(h)[0]"
212
+ @ds.literal(@h.values[0]).must_equal "avals(h)[0]"
213
+ @ds.literal(@h.avals[0]).must_equal "avals(h)[0]"
214
214
  end
215
215
 
216
216
  it "should have Sequel.hstore_op return HStoreOp instances as-is" do
217
- Sequel.hstore_op(@h).should equal(@h)
217
+ Sequel.hstore_op(@h).must_be_same_as(@h)
218
218
  end
219
219
 
220
220
  it "should have Sequel.hstore return HStoreOp instances" do
221
- Sequel.hstore(:h).should == @h
221
+ Sequel.hstore(:h).must_equal @h
222
222
  end
223
223
 
224
224
  it "should be able to turn expressions into hstore ops using hstore" do
225
- @ds.literal(Sequel.qualify(:b, :a).hstore['a']).should == "(b.a -> 'a')"
226
- @ds.literal(Sequel.function(:a, :b).hstore['a']).should == "(a(b) -> 'a')"
225
+ @ds.literal(Sequel.qualify(:b, :a).hstore['a']).must_equal "(b.a -> 'a')"
226
+ @ds.literal(Sequel.function(:a, :b).hstore['a']).must_equal "(a(b) -> 'a')"
227
227
  end
228
228
 
229
229
  it "should be able to turn literal strings into hstore ops using hstore" do
230
- @ds.literal(Sequel.lit('a').hstore['a']).should == "(a -> 'a')"
230
+ @ds.literal(Sequel.lit('a').hstore['a']).must_equal "(a -> 'a')"
231
231
  end
232
232
 
233
233
  it "should allow transforming HStore instances into HStoreOp instances" do
234
- @ds.literal(Sequel.hstore('a'=>'b').op['a']).should == "('\"a\"=>\"b\"'::hstore -> 'a')"
234
+ @ds.literal(Sequel.hstore('a'=>'b').op['a']).must_equal "('\"a\"=>\"b\"'::hstore -> 'a')"
235
235
  end
236
236
  end
@@ -10,197 +10,197 @@ describe "pg_hstore extension" do
10
10
  end
11
11
 
12
12
  it "should parse hstore strings correctly" do
13
- @c.parse('').to_hash.should == {}
14
- @c.parse('"a"=>"b"').to_hash.should == {'a'=>'b'}
15
- @c.parse('"a"=>"b", "c"=>NULL').to_hash.should == {'a'=>'b', 'c'=>nil}
16
- @c.parse('"a"=>"b", "c"=>"NULL"').to_hash.should == {'a'=>'b', 'c'=>'NULL'}
17
- @c.parse('"a"=>"b", "c"=>"\\\\ \\"\'=>"').to_hash.should == {'a'=>'b', 'c'=>'\ "\'=>'}
13
+ @c.parse('').to_hash.must_equal({})
14
+ @c.parse('"a"=>"b"').to_hash.must_equal('a'=>'b')
15
+ @c.parse('"a"=>"b", "c"=>NULL').to_hash.must_equal('a'=>'b', 'c'=>nil)
16
+ @c.parse('"a"=>"b", "c"=>"NULL"').to_hash.must_equal('a'=>'b', 'c'=>'NULL')
17
+ @c.parse('"a"=>"b", "c"=>"\\\\ \\"\'=>"').to_hash.must_equal('a'=>'b', 'c'=>'\ "\'=>')
18
18
  end
19
19
 
20
20
  it "should cache parse results" do
21
21
  r = @c::Parser.new('')
22
22
  o = r.parse
23
- o.should == {}
24
- r.parse.should equal(o)
23
+ o.must_equal({})
24
+ r.parse.must_be_same_as(o)
25
25
  end
26
26
 
27
27
  it "should literalize HStores to strings correctly" do
28
- @db.literal(Sequel.hstore({})).should == '\'\'::hstore'
29
- @db.literal(Sequel.hstore("a"=>"b")).should == '\'"a"=>"b"\'::hstore'
30
- @db.literal(Sequel.hstore("c"=>nil)).should == '\'"c"=>NULL\'::hstore'
31
- @db.literal(Sequel.hstore("c"=>'NULL')).should == '\'"c"=>"NULL"\'::hstore'
32
- @db.literal(Sequel.hstore('c'=>'\ "\'=>')).should == '\'"c"=>"\\\\ \\"\'\'=>"\'::hstore'
33
- ['\'"a"=>"b","c"=>"d"\'::hstore', '\'"c"=>"d","a"=>"b"\'::hstore'].should include(@db.literal(Sequel.hstore("a"=>"b","c"=>"d")))
28
+ @db.literal(Sequel.hstore({})).must_equal '\'\'::hstore'
29
+ @db.literal(Sequel.hstore("a"=>"b")).must_equal '\'"a"=>"b"\'::hstore'
30
+ @db.literal(Sequel.hstore("c"=>nil)).must_equal '\'"c"=>NULL\'::hstore'
31
+ @db.literal(Sequel.hstore("c"=>'NULL')).must_equal '\'"c"=>"NULL"\'::hstore'
32
+ @db.literal(Sequel.hstore('c'=>'\ "\'=>')).must_equal '\'"c"=>"\\\\ \\"\'\'=>"\'::hstore'
33
+ ['\'"a"=>"b","c"=>"d"\'::hstore', '\'"c"=>"d","a"=>"b"\'::hstore'].must_include(@db.literal(Sequel.hstore("a"=>"b","c"=>"d")))
34
34
  end
35
35
 
36
36
  it "should have Sequel.hstore method for creating HStore instances" do
37
- Sequel.hstore({}).should be_a_kind_of(@c)
37
+ Sequel.hstore({}).class.must_equal(@c)
38
38
  end
39
39
 
40
40
  it "should have Sequel.hstore return HStores as-is" do
41
41
  a = Sequel.hstore({})
42
- Sequel.hstore(a).should equal(a)
42
+ Sequel.hstore(a).object_id.must_equal(a.object_id)
43
43
  end
44
44
 
45
45
  it "should HStore#to_hash method for getting underlying hash" do
46
- Sequel.hstore({}).to_hash.should be_a_kind_of(Hash)
46
+ Sequel.hstore({}).to_hash.must_be_kind_of(Hash)
47
47
  end
48
48
 
49
49
  it "should convert keys and values to strings on creation" do
50
- Sequel.hstore(1=>2).to_hash.should == {"1"=>"2"}
50
+ Sequel.hstore(1=>2).to_hash.must_equal("1"=>"2")
51
51
  end
52
52
 
53
53
  it "should convert keys and values to strings on assignment" do
54
54
  v = Sequel.hstore({})
55
55
  v[1] = 2
56
- v.to_hash.should == {"1"=>"2"}
56
+ v.to_hash.must_equal("1"=>"2")
57
57
  v.store(:'1', 3)
58
- v.to_hash.should == {"1"=>"3"}
58
+ v.to_hash.must_equal("1"=>"3")
59
59
  end
60
60
 
61
61
  it "should not convert nil values to strings on creation" do
62
- Sequel.hstore(:foo=>nil).to_hash.should == {"foo"=>nil}
62
+ Sequel.hstore(:foo=>nil).to_hash.must_equal("foo"=>nil)
63
63
  end
64
64
 
65
65
  it "should not convert nil values to strings on assignment" do
66
66
  v = Sequel.hstore({})
67
67
  v[:foo] = nil
68
- v.to_hash.should == {"foo"=>nil}
68
+ v.to_hash.must_equal("foo"=>nil)
69
69
  end
70
70
 
71
71
  it "should convert lookups by key to string" do
72
- Sequel.hstore('foo'=>'bar')[:foo].should == 'bar'
73
- Sequel.hstore('1'=>'bar')[1].should == 'bar'
72
+ Sequel.hstore('foo'=>'bar')[:foo].must_equal 'bar'
73
+ Sequel.hstore('1'=>'bar')[1].must_equal 'bar'
74
74
 
75
- Sequel.hstore('foo'=>'bar').fetch(:foo).should == 'bar'
76
- Sequel.hstore('foo'=>'bar').fetch(:foo2, 2).should == 2
75
+ Sequel.hstore('foo'=>'bar').fetch(:foo).must_equal 'bar'
76
+ Sequel.hstore('foo'=>'bar').fetch(:foo2, 2).must_equal 2
77
77
  k = nil
78
- Sequel.hstore('foo2'=>'bar').fetch(:foo){|key| k = key }.should == 'foo'
79
- k.should == 'foo'
78
+ Sequel.hstore('foo2'=>'bar').fetch(:foo){|key| k = key }.must_equal 'foo'
79
+ k.must_equal 'foo'
80
80
 
81
- Sequel.hstore('foo'=>'bar').has_key?(:foo).should == true
82
- Sequel.hstore('foo'=>'bar').has_key?(:bar).should == false
83
- Sequel.hstore('foo'=>'bar').key?(:foo).should == true
84
- Sequel.hstore('foo'=>'bar').key?(:bar).should == false
85
- Sequel.hstore('foo'=>'bar').member?(:foo).should == true
86
- Sequel.hstore('foo'=>'bar').member?(:bar).should == false
87
- Sequel.hstore('foo'=>'bar').include?(:foo).should == true
88
- Sequel.hstore('foo'=>'bar').include?(:bar).should == false
81
+ Sequel.hstore('foo'=>'bar').has_key?(:foo).must_equal true
82
+ Sequel.hstore('foo'=>'bar').has_key?(:bar).must_equal false
83
+ Sequel.hstore('foo'=>'bar').key?(:foo).must_equal true
84
+ Sequel.hstore('foo'=>'bar').key?(:bar).must_equal false
85
+ Sequel.hstore('foo'=>'bar').member?(:foo).must_equal true
86
+ Sequel.hstore('foo'=>'bar').member?(:bar).must_equal false
87
+ Sequel.hstore('foo'=>'bar').include?(:foo).must_equal true
88
+ Sequel.hstore('foo'=>'bar').include?(:bar).must_equal false
89
89
 
90
- Sequel.hstore('foo'=>'bar', '1'=>'2').values_at(:foo3, :foo, :foo2, 1).should == [nil, 'bar', nil, '2']
90
+ Sequel.hstore('foo'=>'bar', '1'=>'2').values_at(:foo3, :foo, :foo2, 1).must_equal [nil, 'bar', nil, '2']
91
91
 
92
92
  if RUBY_VERSION >= '1.9.0'
93
- Sequel.hstore('foo'=>'bar').assoc(:foo).should == ['foo', 'bar']
94
- Sequel.hstore('foo'=>'bar').assoc(:foo2).should == nil
93
+ Sequel.hstore('foo'=>'bar').assoc(:foo).must_equal ['foo', 'bar']
94
+ Sequel.hstore('foo'=>'bar').assoc(:foo2).must_equal nil
95
95
  end
96
96
  end
97
97
 
98
98
  it "should convert has_value?/value? lookups to string" do
99
- Sequel.hstore('foo'=>'bar').has_value?(:bar).should == true
100
- Sequel.hstore('foo'=>'bar').has_value?(:foo).should == false
101
- Sequel.hstore('foo'=>'bar').value?(:bar).should == true
102
- Sequel.hstore('foo'=>'bar').value?(:foo).should == false
99
+ Sequel.hstore('foo'=>'bar').has_value?(:bar).must_equal true
100
+ Sequel.hstore('foo'=>'bar').has_value?(:foo).must_equal false
101
+ Sequel.hstore('foo'=>'bar').value?(:bar).must_equal true
102
+ Sequel.hstore('foo'=>'bar').value?(:foo).must_equal false
103
103
  end
104
104
 
105
105
  it "should handle nil values in has_value?/value? lookups" do
106
- Sequel.hstore('foo'=>'').has_value?('').should == true
107
- Sequel.hstore('foo'=>'').has_value?(nil).should == false
108
- Sequel.hstore('foo'=>nil).has_value?(nil).should == true
106
+ Sequel.hstore('foo'=>'').has_value?('').must_equal true
107
+ Sequel.hstore('foo'=>'').has_value?(nil).must_equal false
108
+ Sequel.hstore('foo'=>nil).has_value?(nil).must_equal true
109
109
  end
110
110
 
111
111
  it "should have underlying hash convert lookups by key to string" do
112
- Sequel.hstore('foo'=>'bar').to_hash[:foo].should == 'bar'
113
- Sequel.hstore('1'=>'bar').to_hash[1].should == 'bar'
112
+ Sequel.hstore('foo'=>'bar').to_hash[:foo].must_equal 'bar'
113
+ Sequel.hstore('1'=>'bar').to_hash[1].must_equal 'bar'
114
114
  end
115
115
 
116
116
  if RUBY_VERSION >= '1.9.0'
117
117
  it "should convert key lookups to string" do
118
- Sequel.hstore('foo'=>'bar').key(:bar).should == 'foo'
119
- Sequel.hstore('foo'=>'bar').key(:bar2).should be_nil
118
+ Sequel.hstore('foo'=>'bar').key(:bar).must_equal 'foo'
119
+ Sequel.hstore('foo'=>'bar').key(:bar2).must_equal nil
120
120
  end
121
121
 
122
122
  it "should handle nil values in key lookups" do
123
- Sequel.hstore('foo'=>'').key('').should == 'foo'
124
- Sequel.hstore('foo'=>'').key(nil).should == nil
125
- Sequel.hstore('foo'=>nil).key(nil).should == 'foo'
123
+ Sequel.hstore('foo'=>'').key('').must_equal 'foo'
124
+ Sequel.hstore('foo'=>'').key(nil).must_equal nil
125
+ Sequel.hstore('foo'=>nil).key(nil).must_equal 'foo'
126
126
  end
127
127
 
128
128
  it "should convert rassoc lookups to string" do
129
- Sequel.hstore('foo'=>'bar').rassoc(:bar).should == ['foo', 'bar']
130
- Sequel.hstore('foo'=>'bar').rassoc(:bar2).should be_nil
129
+ Sequel.hstore('foo'=>'bar').rassoc(:bar).must_equal ['foo', 'bar']
130
+ Sequel.hstore('foo'=>'bar').rassoc(:bar2).must_equal nil
131
131
  end
132
132
 
133
133
  it "should handle nil values in rassoc lookups" do
134
- Sequel.hstore('foo'=>'').rassoc('').should == ['foo', '']
135
- Sequel.hstore('foo'=>'').rassoc(nil).should == nil
136
- Sequel.hstore('foo'=>nil).rassoc(nil).should == ['foo', nil]
134
+ Sequel.hstore('foo'=>'').rassoc('').must_equal ['foo', '']
135
+ Sequel.hstore('foo'=>'').rassoc(nil).must_equal nil
136
+ Sequel.hstore('foo'=>nil).rassoc(nil).must_equal ['foo', nil]
137
137
  end
138
138
  end
139
139
 
140
140
  it "should have delete convert key to string" do
141
141
  v = Sequel.hstore('foo'=>'bar')
142
- v.delete(:foo).should == 'bar'
143
- v.to_hash.should == {}
142
+ v.delete(:foo).must_equal 'bar'
143
+ v.to_hash.must_equal({})
144
144
  end
145
145
 
146
146
  it "should handle #replace with hashes that do not use strings" do
147
147
  v = Sequel.hstore('foo'=>'bar')
148
148
  v.replace(:bar=>1)
149
- v.should be_a_kind_of(@c)
150
- v.should == {'bar'=>'1'}
151
- v.to_hash[:bar].should == '1'
149
+ v.class.must_equal(@c)
150
+ v.must_equal('bar'=>'1')
151
+ v.to_hash[:bar].must_equal '1'
152
152
  end
153
153
 
154
154
  it "should handle #merge with hashes that do not use strings" do
155
155
  v = Sequel.hstore('foo'=>'bar').merge(:bar=>1)
156
- v.should be_a_kind_of(@c)
157
- v.should == {'foo'=>'bar', 'bar'=>'1'}
156
+ v.class.must_equal(@c)
157
+ v.must_equal('foo'=>'bar', 'bar'=>'1')
158
158
  end
159
159
 
160
160
  it "should handle #merge/#update with hashes that do not use strings" do
161
161
  v = Sequel.hstore('foo'=>'bar')
162
162
  v.merge!(:bar=>1)
163
- v.should be_a_kind_of(@c)
164
- v.should == {'foo'=>'bar', 'bar'=>'1'}
163
+ v.class.must_equal(@c)
164
+ v.must_equal('foo'=>'bar', 'bar'=>'1')
165
165
 
166
166
  v = Sequel.hstore('foo'=>'bar')
167
167
  v.update(:bar=>1)
168
- v.should be_a_kind_of(@c)
169
- v.should == {'foo'=>'bar', 'bar'=>'1'}
168
+ v.class.must_equal(@c)
169
+ v.must_equal('foo'=>'bar', 'bar'=>'1')
170
170
  end
171
171
 
172
172
  it "should support using hstores as bound variables" do
173
- @db.bound_variable_arg(1, nil).should == 1
174
- @db.bound_variable_arg({'1'=>'2'}, nil).should == '"1"=>"2"'
175
- @db.bound_variable_arg(Sequel.hstore('1'=>'2'), nil).should == '"1"=>"2"'
176
- @db.bound_variable_arg(Sequel.hstore('1'=>nil), nil).should == '"1"=>NULL'
177
- @db.bound_variable_arg(Sequel.hstore('1'=>"NULL"), nil).should == '"1"=>"NULL"'
178
- @db.bound_variable_arg(Sequel.hstore('1'=>"'\\ \"=>"), nil).should == '"1"=>"\'\\\\ \\"=>"'
179
- ['"a"=>"b","c"=>"d"', '"c"=>"d","a"=>"b"'].should include(@db.bound_variable_arg(Sequel.hstore("a"=>"b","c"=>"d"), nil))
173
+ @db.bound_variable_arg(1, nil).must_equal 1
174
+ @db.bound_variable_arg({'1'=>'2'}, nil).must_equal '"1"=>"2"'
175
+ @db.bound_variable_arg(Sequel.hstore('1'=>'2'), nil).must_equal '"1"=>"2"'
176
+ @db.bound_variable_arg(Sequel.hstore('1'=>nil), nil).must_equal '"1"=>NULL'
177
+ @db.bound_variable_arg(Sequel.hstore('1'=>"NULL"), nil).must_equal '"1"=>"NULL"'
178
+ @db.bound_variable_arg(Sequel.hstore('1'=>"'\\ \"=>"), nil).must_equal '"1"=>"\'\\\\ \\"=>"'
179
+ ['"a"=>"b","c"=>"d"', '"c"=>"d","a"=>"b"'].must_include(@db.bound_variable_arg(Sequel.hstore("a"=>"b","c"=>"d"), nil))
180
180
  end
181
181
 
182
182
  it "should parse hstore type from the schema correctly" do
183
183
  @db.fetch = [{:name=>'id', :db_type=>'integer'}, {:name=>'i', :db_type=>'hstore'}]
184
- @db.schema(:items).map{|e| e[1][:type]}.should == [:integer, :hstore]
184
+ @db.schema(:items).map{|e| e[1][:type]}.must_equal [:integer, :hstore]
185
185
  end
186
186
 
187
187
  it "should support typecasting for the hstore type" do
188
188
  h = Sequel.hstore(1=>2)
189
- @db.typecast_value(:hstore, h).should equal(h)
190
- @db.typecast_value(:hstore, {}).should be_a_kind_of(@c)
191
- @db.typecast_value(:hstore, {}).should == Sequel.hstore({})
192
- @db.typecast_value(:hstore, {'a'=>'b'}).should == Sequel.hstore("a"=>"b")
193
- proc{@db.typecast_value(:hstore, [])}.should raise_error(Sequel::InvalidValue)
189
+ @db.typecast_value(:hstore, h).object_id.must_equal(h.object_id)
190
+ @db.typecast_value(:hstore, {}).class.must_equal(@c)
191
+ @db.typecast_value(:hstore, {}).must_equal Sequel.hstore({})
192
+ @db.typecast_value(:hstore, {'a'=>'b'}).must_equal Sequel.hstore("a"=>"b")
193
+ proc{@db.typecast_value(:hstore, [])}.must_raise(Sequel::InvalidValue)
194
194
  end
195
195
 
196
196
  it "should be serializable" do
197
197
  v = Sequel.hstore('foo'=>'bar')
198
198
  dump = Marshal.dump(v)
199
- Marshal.load(dump).should == v
199
+ Marshal.load(dump).must_equal v
200
200
  end
201
201
 
202
202
  it "should return correct results for Database#schema_type_class" do
203
- @db.schema_type_class(:hstore).should == Sequel::Postgres::HStore
204
- @db.schema_type_class(:integer).should == Integer
203
+ @db.schema_type_class(:hstore).must_equal Sequel::Postgres::HStore
204
+ @db.schema_type_class(:integer).must_equal Integer
205
205
  end
206
206
  end