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
@@ -11,30 +11,15 @@ unless Object.const_defined?('Sequel')
11
11
  end
12
12
  Sequel::Deprecation.backtrace_filter = lambda{|line, lineno| lineno < 4 || line =~ /_spec\.rb/}
13
13
 
14
- require File.join(File.dirname(File.expand_path(__FILE__)), "../rspec_helper.rb")
14
+ gem 'minitest'
15
+ require 'minitest/autorun'
16
+ require 'minitest/hooks/default'
17
+ require 'minitest/shared_description'
15
18
 
16
- RSPEC_EXAMPLE_GROUP.class_eval do
19
+ class Minitest::HooksSpec
17
20
  def meta_def(obj, name, &block)
18
21
  (class << obj; self end).send(:define_method, name, &block)
19
22
  end
20
-
21
- if ENV['SEQUEL_DEPRECATION_WARNINGS']
22
- class << self
23
- alias qspecify specify
24
- end
25
- else
26
- def self.qspecify(*a, &block)
27
- specify(*a) do
28
- begin
29
- output = Sequel::Deprecation.output
30
- Sequel::Deprecation.output = false
31
- instance_exec(&block)
32
- ensure
33
- Sequel::Deprecation.output = output
34
- end
35
- end
36
- end
37
- end
38
23
  end
39
24
 
40
25
  if ENV['SEQUEL_COLUMNS_INTROSPECTION']
@@ -1,7 +1,7 @@
1
1
  require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper')
2
2
 
3
3
  describe "Sequel.version" do
4
- specify "should be in the form X.Y.Z with all being numbers" do
5
- Sequel.version.should =~ /\A\d+\.\d+\.\d+\z/
4
+ it "should be in the form X.Y.Z with all being numbers" do
5
+ Sequel.version.must_match(/\A\d+\.\d+\.\d+\z/)
6
6
  end
7
7
  end
@@ -22,11 +22,11 @@ if RUBY_VERSION < '1.9.0'
22
22
  Sequel.extension :ruby18_symbol_extensions
23
23
  end
24
24
 
25
- require File.join(File.dirname(File.expand_path(__FILE__)), "rspec_helper.rb")
25
+ require 'minitest/autorun'
26
26
 
27
27
  describe "Sequel core extensions" do
28
- specify "should have Sequel.core_extensions? be true if enabled" do
29
- Sequel.core_extensions?.should == true
28
+ it "should have Sequel.core_extensions? be true if enabled" do
29
+ Sequel.core_extensions?.must_equal true
30
30
  end
31
31
  end
32
32
 
@@ -45,216 +45,216 @@ describe "Core extensions" do
45
45
 
46
46
  if RUBY_VERSION < '1.9.0'
47
47
  it "should not allow inequality operations on true, false, or nil" do
48
- @d.lit(:x > 1).should == "(x > 1)"
49
- @d.lit(:x < true).should == "(x < 't')"
50
- @d.lit(:x >= false).should == "(x >= 'f')"
51
- @d.lit(:x <= nil).should == "(x <= NULL)"
48
+ @d.lit(:x > 1).must_equal "(x > 1)"
49
+ @d.lit(:x < true).must_equal "(x < 't')"
50
+ @d.lit(:x >= false).must_equal "(x >= 'f')"
51
+ @d.lit(:x <= nil).must_equal "(x <= NULL)"
52
52
  end
53
53
 
54
54
  it "should not allow inequality operations on boolean complex expressions" do
55
- @d.lit(:x > (:y > 5)).should == "(x > (y > 5))"
56
- @d.lit(:x < (:y < 5)).should == "(x < (y < 5))"
57
- @d.lit(:x >= (:y >= 5)).should == "(x >= (y >= 5))"
58
- @d.lit(:x <= (:y <= 5)).should == "(x <= (y <= 5))"
59
- @d.lit(:x > {:y => nil}).should == "(x > (y IS NULL))"
60
- @d.lit(:x < ~{:y => nil}).should == "(x < (y IS NOT NULL))"
61
- @d.lit(:x >= {:y => 5}).should == "(x >= (y = 5))"
62
- @d.lit(:x <= ~{:y => 5}).should == "(x <= (y != 5))"
63
- @d.lit(:x >= {:y => [1,2,3]}).should == "(x >= (y IN (1, 2, 3)))"
64
- @d.lit(:x <= ~{:y => [1,2,3]}).should == "(x <= (y NOT IN (1, 2, 3)))"
55
+ @d.lit(:x > (:y > 5)).must_equal "(x > (y > 5))"
56
+ @d.lit(:x < (:y < 5)).must_equal "(x < (y < 5))"
57
+ @d.lit(:x >= (:y >= 5)).must_equal "(x >= (y >= 5))"
58
+ @d.lit(:x <= (:y <= 5)).must_equal "(x <= (y <= 5))"
59
+ @d.lit(:x > {:y => nil}).must_equal "(x > (y IS NULL))"
60
+ @d.lit(:x < ~{:y => nil}).must_equal "(x < (y IS NOT NULL))"
61
+ @d.lit(:x >= {:y => 5}).must_equal "(x >= (y = 5))"
62
+ @d.lit(:x <= ~{:y => 5}).must_equal "(x <= (y != 5))"
63
+ @d.lit(:x >= {:y => [1,2,3]}).must_equal "(x >= (y IN (1, 2, 3)))"
64
+ @d.lit(:x <= ~{:y => [1,2,3]}).must_equal "(x <= (y NOT IN (1, 2, 3)))"
65
65
  end
66
66
 
67
67
  it "should support >, <, >=, and <= via Symbol#>,<,>=,<=" do
68
- @d.l(:x > 100).should == '(x > 100)'
69
- @d.l(:x < 100.01).should == '(x < 100.01)'
70
- @d.l(:x >= 100000000000000000000000000000000000).should == '(x >= 100000000000000000000000000000000000)'
71
- @d.l(:x <= 100).should == '(x <= 100)'
68
+ @d.l(:x > 100).must_equal '(x > 100)'
69
+ @d.l(:x < 100.01).must_equal '(x < 100.01)'
70
+ @d.l(:x >= 100000000000000000000000000000000000).must_equal '(x >= 100000000000000000000000000000000000)'
71
+ @d.l(:x <= 100).must_equal '(x <= 100)'
72
72
  end
73
73
 
74
74
  it "should support negation of >, <, >=, and <= via Symbol#~" do
75
- @d.l(~(:x > 100)).should == '(x <= 100)'
76
- @d.l(~(:x < 100.01)).should == '(x >= 100.01)'
77
- @d.l(~(:x >= 100000000000000000000000000000000000)).should == '(x < 100000000000000000000000000000000000)'
78
- @d.l(~(:x <= 100)).should == '(x > 100)'
75
+ @d.l(~(:x > 100)).must_equal '(x <= 100)'
76
+ @d.l(~(:x < 100.01)).must_equal '(x >= 100.01)'
77
+ @d.l(~(:x >= 100000000000000000000000000000000000)).must_equal '(x < 100000000000000000000000000000000000)'
78
+ @d.l(~(:x <= 100)).must_equal '(x > 100)'
79
79
  end
80
80
 
81
81
  it "should support double negation via ~" do
82
- @d.l(~~(:x > 100)).should == '(x > 100)'
82
+ @d.l(~~(:x > 100)).must_equal '(x > 100)'
83
83
  end
84
84
  end
85
85
  it "should support NOT via Symbol#~" do
86
- @d.l(~:x).should == 'NOT x'
87
- @d.l(~:x__y).should == 'NOT x.y'
86
+ @d.l(~:x).must_equal 'NOT x'
87
+ @d.l(~:x__y).must_equal 'NOT x.y'
88
88
  end
89
89
 
90
90
  it "should support + - * / via Symbol#+,-,*,/" do
91
- @d.l(:x + 1 > 100).should == '((x + 1) > 100)'
92
- @d.l((:x * :y) < 100.01).should == '((x * y) < 100.01)'
93
- @d.l((:x - :y/2) >= 100000000000000000000000000000000000).should == '((x - (y / 2)) >= 100000000000000000000000000000000000)'
94
- @d.l((((:x - :y)/(:x + :y))*:z) <= 100).should == '((((x - y) / (x + y)) * z) <= 100)'
95
- @d.l(~((((:x - :y)/(:x + :y))*:z) <= 100)).should == '((((x - y) / (x + y)) * z) > 100)'
91
+ @d.l(:x + 1 > 100).must_equal '((x + 1) > 100)'
92
+ @d.l((:x * :y) < 100.01).must_equal '((x * y) < 100.01)'
93
+ @d.l((:x - :y/2) >= 100000000000000000000000000000000000).must_equal '((x - (y / 2)) >= 100000000000000000000000000000000000)'
94
+ @d.l((((:x - :y)/(:x + :y))*:z) <= 100).must_equal '((((x - y) / (x + y)) * z) <= 100)'
95
+ @d.l(~((((:x - :y)/(:x + :y))*:z) <= 100)).must_equal '((((x - y) / (x + y)) * z) > 100)'
96
96
  end
97
97
 
98
98
  it "should support LIKE via Symbol#like" do
99
- @d.l(:x.like('a')).should == '(x LIKE \'a\' ESCAPE \'\\\')'
100
- @d.l(:x.like(/a/)).should == '(x ~ \'a\')'
101
- @d.l(:x.like('a', 'b')).should == '((x LIKE \'a\' ESCAPE \'\\\') OR (x LIKE \'b\' ESCAPE \'\\\'))'
102
- @d.l(:x.like(/a/, /b/i)).should == '((x ~ \'a\') OR (x ~* \'b\'))'
103
- @d.l(:x.like('a', /b/)).should == '((x LIKE \'a\' ESCAPE \'\\\') OR (x ~ \'b\'))'
99
+ @d.l(:x.like('a')).must_equal '(x LIKE \'a\' ESCAPE \'\\\')'
100
+ @d.l(:x.like(/a/)).must_equal '(x ~ \'a\')'
101
+ @d.l(:x.like('a', 'b')).must_equal '((x LIKE \'a\' ESCAPE \'\\\') OR (x LIKE \'b\' ESCAPE \'\\\'))'
102
+ @d.l(:x.like(/a/, /b/i)).must_equal '((x ~ \'a\') OR (x ~* \'b\'))'
103
+ @d.l(:x.like('a', /b/)).must_equal '((x LIKE \'a\' ESCAPE \'\\\') OR (x ~ \'b\'))'
104
104
 
105
- @d.l('a'.like(:x)).should == "('a' LIKE x ESCAPE '\\')"
106
- @d.l('a'.like(:x, 'b')).should == "(('a' LIKE x ESCAPE '\\') OR ('a' LIKE 'b' ESCAPE '\\'))"
107
- @d.l('a'.like(:x, /b/)).should == "(('a' LIKE x ESCAPE '\\') OR ('a' ~ 'b'))"
108
- @d.l('a'.like(:x, /b/i)).should == "(('a' LIKE x ESCAPE '\\') OR ('a' ~* 'b'))"
105
+ @d.l('a'.like(:x)).must_equal "('a' LIKE x ESCAPE '\\')"
106
+ @d.l('a'.like(:x, 'b')).must_equal "(('a' LIKE x ESCAPE '\\') OR ('a' LIKE 'b' ESCAPE '\\'))"
107
+ @d.l('a'.like(:x, /b/)).must_equal "(('a' LIKE x ESCAPE '\\') OR ('a' ~ 'b'))"
108
+ @d.l('a'.like(:x, /b/i)).must_equal "(('a' LIKE x ESCAPE '\\') OR ('a' ~* 'b'))"
109
109
 
110
- @d.l(/a/.like(:x)).should == "('a' ~ x)"
111
- @d.l(/a/.like(:x, 'b')).should == "(('a' ~ x) OR ('a' ~ 'b'))"
112
- @d.l(/a/.like(:x, /b/)).should == "(('a' ~ x) OR ('a' ~ 'b'))"
113
- @d.l(/a/.like(:x, /b/i)).should == "(('a' ~ x) OR ('a' ~* 'b'))"
110
+ @d.l(/a/.like(:x)).must_equal "('a' ~ x)"
111
+ @d.l(/a/.like(:x, 'b')).must_equal "(('a' ~ x) OR ('a' ~ 'b'))"
112
+ @d.l(/a/.like(:x, /b/)).must_equal "(('a' ~ x) OR ('a' ~ 'b'))"
113
+ @d.l(/a/.like(:x, /b/i)).must_equal "(('a' ~ x) OR ('a' ~* 'b'))"
114
114
 
115
- @d.l(/a/i.like(:x)).should == "('a' ~* x)"
116
- @d.l(/a/i.like(:x, 'b')).should == "(('a' ~* x) OR ('a' ~* 'b'))"
117
- @d.l(/a/i.like(:x, /b/)).should == "(('a' ~* x) OR ('a' ~* 'b'))"
118
- @d.l(/a/i.like(:x, /b/i)).should == "(('a' ~* x) OR ('a' ~* 'b'))"
115
+ @d.l(/a/i.like(:x)).must_equal "('a' ~* x)"
116
+ @d.l(/a/i.like(:x, 'b')).must_equal "(('a' ~* x) OR ('a' ~* 'b'))"
117
+ @d.l(/a/i.like(:x, /b/)).must_equal "(('a' ~* x) OR ('a' ~* 'b'))"
118
+ @d.l(/a/i.like(:x, /b/i)).must_equal "(('a' ~* x) OR ('a' ~* 'b'))"
119
119
  end
120
120
 
121
121
  it "should support NOT LIKE via Symbol#like and Symbol#~" do
122
- @d.l(~:x.like('a')).should == '(x NOT LIKE \'a\' ESCAPE \'\\\')'
123
- @d.l(~:x.like(/a/)).should == '(x !~ \'a\')'
124
- @d.l(~:x.like('a', 'b')).should == '((x NOT LIKE \'a\' ESCAPE \'\\\') AND (x NOT LIKE \'b\' ESCAPE \'\\\'))'
125
- @d.l(~:x.like(/a/, /b/i)).should == '((x !~ \'a\') AND (x !~* \'b\'))'
126
- @d.l(~:x.like('a', /b/)).should == '((x NOT LIKE \'a\' ESCAPE \'\\\') AND (x !~ \'b\'))'
122
+ @d.l(~:x.like('a')).must_equal '(x NOT LIKE \'a\' ESCAPE \'\\\')'
123
+ @d.l(~:x.like(/a/)).must_equal '(x !~ \'a\')'
124
+ @d.l(~:x.like('a', 'b')).must_equal '((x NOT LIKE \'a\' ESCAPE \'\\\') AND (x NOT LIKE \'b\' ESCAPE \'\\\'))'
125
+ @d.l(~:x.like(/a/, /b/i)).must_equal '((x !~ \'a\') AND (x !~* \'b\'))'
126
+ @d.l(~:x.like('a', /b/)).must_equal '((x NOT LIKE \'a\' ESCAPE \'\\\') AND (x !~ \'b\'))'
127
127
 
128
- @d.l(~'a'.like(:x)).should == "('a' NOT LIKE x ESCAPE '\\')"
129
- @d.l(~'a'.like(:x, 'b')).should == "(('a' NOT LIKE x ESCAPE '\\') AND ('a' NOT LIKE 'b' ESCAPE '\\'))"
130
- @d.l(~'a'.like(:x, /b/)).should == "(('a' NOT LIKE x ESCAPE '\\') AND ('a' !~ 'b'))"
131
- @d.l(~'a'.like(:x, /b/i)).should == "(('a' NOT LIKE x ESCAPE '\\') AND ('a' !~* 'b'))"
128
+ @d.l(~'a'.like(:x)).must_equal "('a' NOT LIKE x ESCAPE '\\')"
129
+ @d.l(~'a'.like(:x, 'b')).must_equal "(('a' NOT LIKE x ESCAPE '\\') AND ('a' NOT LIKE 'b' ESCAPE '\\'))"
130
+ @d.l(~'a'.like(:x, /b/)).must_equal "(('a' NOT LIKE x ESCAPE '\\') AND ('a' !~ 'b'))"
131
+ @d.l(~'a'.like(:x, /b/i)).must_equal "(('a' NOT LIKE x ESCAPE '\\') AND ('a' !~* 'b'))"
132
132
 
133
- @d.l(~/a/.like(:x)).should == "('a' !~ x)"
134
- @d.l(~/a/.like(:x, 'b')).should == "(('a' !~ x) AND ('a' !~ 'b'))"
135
- @d.l(~/a/.like(:x, /b/)).should == "(('a' !~ x) AND ('a' !~ 'b'))"
136
- @d.l(~/a/.like(:x, /b/i)).should == "(('a' !~ x) AND ('a' !~* 'b'))"
133
+ @d.l(~/a/.like(:x)).must_equal "('a' !~ x)"
134
+ @d.l(~/a/.like(:x, 'b')).must_equal "(('a' !~ x) AND ('a' !~ 'b'))"
135
+ @d.l(~/a/.like(:x, /b/)).must_equal "(('a' !~ x) AND ('a' !~ 'b'))"
136
+ @d.l(~/a/.like(:x, /b/i)).must_equal "(('a' !~ x) AND ('a' !~* 'b'))"
137
137
 
138
- @d.l(~/a/i.like(:x)).should == "('a' !~* x)"
139
- @d.l(~/a/i.like(:x, 'b')).should == "(('a' !~* x) AND ('a' !~* 'b'))"
140
- @d.l(~/a/i.like(:x, /b/)).should == "(('a' !~* x) AND ('a' !~* 'b'))"
141
- @d.l(~/a/i.like(:x, /b/i)).should == "(('a' !~* x) AND ('a' !~* 'b'))"
138
+ @d.l(~/a/i.like(:x)).must_equal "('a' !~* x)"
139
+ @d.l(~/a/i.like(:x, 'b')).must_equal "(('a' !~* x) AND ('a' !~* 'b'))"
140
+ @d.l(~/a/i.like(:x, /b/)).must_equal "(('a' !~* x) AND ('a' !~* 'b'))"
141
+ @d.l(~/a/i.like(:x, /b/i)).must_equal "(('a' !~* x) AND ('a' !~* 'b'))"
142
142
  end
143
143
 
144
144
  it "should support ILIKE via Symbol#ilike" do
145
- @d.l(:x.ilike('a')).should == '(UPPER(x) LIKE UPPER(\'a\') ESCAPE \'\\\')'
146
- @d.l(:x.ilike(/a/)).should == '(x ~* \'a\')'
147
- @d.l(:x.ilike('a', 'b')).should == '((UPPER(x) LIKE UPPER(\'a\') ESCAPE \'\\\') OR (UPPER(x) LIKE UPPER(\'b\') ESCAPE \'\\\'))'
148
- @d.l(:x.ilike(/a/, /b/i)).should == '((x ~* \'a\') OR (x ~* \'b\'))'
149
- @d.l(:x.ilike('a', /b/)).should == '((UPPER(x) LIKE UPPER(\'a\') ESCAPE \'\\\') OR (x ~* \'b\'))'
145
+ @d.l(:x.ilike('a')).must_equal '(UPPER(x) LIKE UPPER(\'a\') ESCAPE \'\\\')'
146
+ @d.l(:x.ilike(/a/)).must_equal '(x ~* \'a\')'
147
+ @d.l(:x.ilike('a', 'b')).must_equal '((UPPER(x) LIKE UPPER(\'a\') ESCAPE \'\\\') OR (UPPER(x) LIKE UPPER(\'b\') ESCAPE \'\\\'))'
148
+ @d.l(:x.ilike(/a/, /b/i)).must_equal '((x ~* \'a\') OR (x ~* \'b\'))'
149
+ @d.l(:x.ilike('a', /b/)).must_equal '((UPPER(x) LIKE UPPER(\'a\') ESCAPE \'\\\') OR (x ~* \'b\'))'
150
150
 
151
- @d.l('a'.ilike(:x)).should == "(UPPER('a') LIKE UPPER(x) ESCAPE '\\')"
152
- @d.l('a'.ilike(:x, 'b')).should == "((UPPER('a') LIKE UPPER(x) ESCAPE '\\') OR (UPPER('a') LIKE UPPER('b') ESCAPE '\\'))"
153
- @d.l('a'.ilike(:x, /b/)).should == "((UPPER('a') LIKE UPPER(x) ESCAPE '\\') OR ('a' ~* 'b'))"
154
- @d.l('a'.ilike(:x, /b/i)).should == "((UPPER('a') LIKE UPPER(x) ESCAPE '\\') OR ('a' ~* 'b'))"
151
+ @d.l('a'.ilike(:x)).must_equal "(UPPER('a') LIKE UPPER(x) ESCAPE '\\')"
152
+ @d.l('a'.ilike(:x, 'b')).must_equal "((UPPER('a') LIKE UPPER(x) ESCAPE '\\') OR (UPPER('a') LIKE UPPER('b') ESCAPE '\\'))"
153
+ @d.l('a'.ilike(:x, /b/)).must_equal "((UPPER('a') LIKE UPPER(x) ESCAPE '\\') OR ('a' ~* 'b'))"
154
+ @d.l('a'.ilike(:x, /b/i)).must_equal "((UPPER('a') LIKE UPPER(x) ESCAPE '\\') OR ('a' ~* 'b'))"
155
155
 
156
- @d.l(/a/.ilike(:x)).should == "('a' ~* x)"
157
- @d.l(/a/.ilike(:x, 'b')).should == "(('a' ~* x) OR ('a' ~* 'b'))"
158
- @d.l(/a/.ilike(:x, /b/)).should == "(('a' ~* x) OR ('a' ~* 'b'))"
159
- @d.l(/a/.ilike(:x, /b/i)).should == "(('a' ~* x) OR ('a' ~* 'b'))"
156
+ @d.l(/a/.ilike(:x)).must_equal "('a' ~* x)"
157
+ @d.l(/a/.ilike(:x, 'b')).must_equal "(('a' ~* x) OR ('a' ~* 'b'))"
158
+ @d.l(/a/.ilike(:x, /b/)).must_equal "(('a' ~* x) OR ('a' ~* 'b'))"
159
+ @d.l(/a/.ilike(:x, /b/i)).must_equal "(('a' ~* x) OR ('a' ~* 'b'))"
160
160
 
161
- @d.l(/a/i.ilike(:x)).should == "('a' ~* x)"
162
- @d.l(/a/i.ilike(:x, 'b')).should == "(('a' ~* x) OR ('a' ~* 'b'))"
163
- @d.l(/a/i.ilike(:x, /b/)).should == "(('a' ~* x) OR ('a' ~* 'b'))"
164
- @d.l(/a/i.ilike(:x, /b/i)).should == "(('a' ~* x) OR ('a' ~* 'b'))"
161
+ @d.l(/a/i.ilike(:x)).must_equal "('a' ~* x)"
162
+ @d.l(/a/i.ilike(:x, 'b')).must_equal "(('a' ~* x) OR ('a' ~* 'b'))"
163
+ @d.l(/a/i.ilike(:x, /b/)).must_equal "(('a' ~* x) OR ('a' ~* 'b'))"
164
+ @d.l(/a/i.ilike(:x, /b/i)).must_equal "(('a' ~* x) OR ('a' ~* 'b'))"
165
165
  end
166
166
 
167
167
  it "should support NOT ILIKE via Symbol#ilike and Symbol#~" do
168
- @d.l(~:x.ilike('a')).should == '(UPPER(x) NOT LIKE UPPER(\'a\') ESCAPE \'\\\')'
169
- @d.l(~:x.ilike(/a/)).should == '(x !~* \'a\')'
170
- @d.l(~:x.ilike('a', 'b')).should == '((UPPER(x) NOT LIKE UPPER(\'a\') ESCAPE \'\\\') AND (UPPER(x) NOT LIKE UPPER(\'b\') ESCAPE \'\\\'))'
171
- @d.l(~:x.ilike(/a/, /b/i)).should == '((x !~* \'a\') AND (x !~* \'b\'))'
172
- @d.l(~:x.ilike('a', /b/)).should == '((UPPER(x) NOT LIKE UPPER(\'a\') ESCAPE \'\\\') AND (x !~* \'b\'))'
168
+ @d.l(~:x.ilike('a')).must_equal '(UPPER(x) NOT LIKE UPPER(\'a\') ESCAPE \'\\\')'
169
+ @d.l(~:x.ilike(/a/)).must_equal '(x !~* \'a\')'
170
+ @d.l(~:x.ilike('a', 'b')).must_equal '((UPPER(x) NOT LIKE UPPER(\'a\') ESCAPE \'\\\') AND (UPPER(x) NOT LIKE UPPER(\'b\') ESCAPE \'\\\'))'
171
+ @d.l(~:x.ilike(/a/, /b/i)).must_equal '((x !~* \'a\') AND (x !~* \'b\'))'
172
+ @d.l(~:x.ilike('a', /b/)).must_equal '((UPPER(x) NOT LIKE UPPER(\'a\') ESCAPE \'\\\') AND (x !~* \'b\'))'
173
173
 
174
- @d.l(~'a'.ilike(:x)).should == "(UPPER('a') NOT LIKE UPPER(x) ESCAPE '\\')"
175
- @d.l(~'a'.ilike(:x, 'b')).should == "((UPPER('a') NOT LIKE UPPER(x) ESCAPE '\\') AND (UPPER('a') NOT LIKE UPPER('b') ESCAPE '\\'))"
176
- @d.l(~'a'.ilike(:x, /b/)).should == "((UPPER('a') NOT LIKE UPPER(x) ESCAPE '\\') AND ('a' !~* 'b'))"
177
- @d.l(~'a'.ilike(:x, /b/i)).should == "((UPPER('a') NOT LIKE UPPER(x) ESCAPE '\\') AND ('a' !~* 'b'))"
174
+ @d.l(~'a'.ilike(:x)).must_equal "(UPPER('a') NOT LIKE UPPER(x) ESCAPE '\\')"
175
+ @d.l(~'a'.ilike(:x, 'b')).must_equal "((UPPER('a') NOT LIKE UPPER(x) ESCAPE '\\') AND (UPPER('a') NOT LIKE UPPER('b') ESCAPE '\\'))"
176
+ @d.l(~'a'.ilike(:x, /b/)).must_equal "((UPPER('a') NOT LIKE UPPER(x) ESCAPE '\\') AND ('a' !~* 'b'))"
177
+ @d.l(~'a'.ilike(:x, /b/i)).must_equal "((UPPER('a') NOT LIKE UPPER(x) ESCAPE '\\') AND ('a' !~* 'b'))"
178
178
 
179
- @d.l(~/a/.ilike(:x)).should == "('a' !~* x)"
180
- @d.l(~/a/.ilike(:x, 'b')).should == "(('a' !~* x) AND ('a' !~* 'b'))"
181
- @d.l(~/a/.ilike(:x, /b/)).should == "(('a' !~* x) AND ('a' !~* 'b'))"
182
- @d.l(~/a/.ilike(:x, /b/i)).should == "(('a' !~* x) AND ('a' !~* 'b'))"
179
+ @d.l(~/a/.ilike(:x)).must_equal "('a' !~* x)"
180
+ @d.l(~/a/.ilike(:x, 'b')).must_equal "(('a' !~* x) AND ('a' !~* 'b'))"
181
+ @d.l(~/a/.ilike(:x, /b/)).must_equal "(('a' !~* x) AND ('a' !~* 'b'))"
182
+ @d.l(~/a/.ilike(:x, /b/i)).must_equal "(('a' !~* x) AND ('a' !~* 'b'))"
183
183
 
184
- @d.l(~/a/i.ilike(:x)).should == "('a' !~* x)"
185
- @d.l(~/a/i.ilike(:x, 'b')).should == "(('a' !~* x) AND ('a' !~* 'b'))"
186
- @d.l(~/a/i.ilike(:x, /b/)).should == "(('a' !~* x) AND ('a' !~* 'b'))"
187
- @d.l(~/a/i.ilike(:x, /b/i)).should == "(('a' !~* x) AND ('a' !~* 'b'))"
184
+ @d.l(~/a/i.ilike(:x)).must_equal "('a' !~* x)"
185
+ @d.l(~/a/i.ilike(:x, 'b')).must_equal "(('a' !~* x) AND ('a' !~* 'b'))"
186
+ @d.l(~/a/i.ilike(:x, /b/)).must_equal "(('a' !~* x) AND ('a' !~* 'b'))"
187
+ @d.l(~/a/i.ilike(:x, /b/i)).must_equal "(('a' !~* x) AND ('a' !~* 'b'))"
188
188
  end
189
189
 
190
190
  it "should support sql_expr on arrays with all two pairs" do
191
- @d.l([[:x, 100],[:y, 'a']].sql_expr).should == '((x = 100) AND (y = \'a\'))'
192
- @d.l([[:x, true], [:y, false]].sql_expr).should == '((x IS TRUE) AND (y IS FALSE))'
193
- @d.l([[:x, nil], [:y, [1,2,3]]].sql_expr).should == '((x IS NULL) AND (y IN (1, 2, 3)))'
191
+ @d.l([[:x, 100],[:y, 'a']].sql_expr).must_equal '((x = 100) AND (y = \'a\'))'
192
+ @d.l([[:x, true], [:y, false]].sql_expr).must_equal '((x IS TRUE) AND (y IS FALSE))'
193
+ @d.l([[:x, nil], [:y, [1,2,3]]].sql_expr).must_equal '((x IS NULL) AND (y IN (1, 2, 3)))'
194
194
  end
195
195
 
196
196
  it "should support sql_negate on arrays with all two pairs" do
197
- @d.l([[:x, 100],[:y, 'a']].sql_negate).should == '((x != 100) AND (y != \'a\'))'
198
- @d.l([[:x, true], [:y, false]].sql_negate).should == '((x IS NOT TRUE) AND (y IS NOT FALSE))'
199
- @d.l([[:x, nil], [:y, [1,2,3]]].sql_negate).should == '((x IS NOT NULL) AND (y NOT IN (1, 2, 3)))'
197
+ @d.l([[:x, 100],[:y, 'a']].sql_negate).must_equal '((x != 100) AND (y != \'a\'))'
198
+ @d.l([[:x, true], [:y, false]].sql_negate).must_equal '((x IS NOT TRUE) AND (y IS NOT FALSE))'
199
+ @d.l([[:x, nil], [:y, [1,2,3]]].sql_negate).must_equal '((x IS NOT NULL) AND (y NOT IN (1, 2, 3)))'
200
200
  end
201
201
 
202
202
  it "should support ~ on arrays with all two pairs" do
203
- @d.l(~[[:x, 100],[:y, 'a']]).should == '((x != 100) OR (y != \'a\'))'
204
- @d.l(~[[:x, true], [:y, false]]).should == '((x IS NOT TRUE) OR (y IS NOT FALSE))'
205
- @d.l(~[[:x, nil], [:y, [1,2,3]]]).should == '((x IS NOT NULL) OR (y NOT IN (1, 2, 3)))'
203
+ @d.l(~[[:x, 100],[:y, 'a']]).must_equal '((x != 100) OR (y != \'a\'))'
204
+ @d.l(~[[:x, true], [:y, false]]).must_equal '((x IS NOT TRUE) OR (y IS NOT FALSE))'
205
+ @d.l(~[[:x, nil], [:y, [1,2,3]]]).must_equal '((x IS NOT NULL) OR (y NOT IN (1, 2, 3)))'
206
206
  end
207
207
 
208
208
  it "should support sql_or on arrays with all two pairs" do
209
- @d.l([[:x, 100],[:y, 'a']].sql_or).should == '((x = 100) OR (y = \'a\'))'
210
- @d.l([[:x, true], [:y, false]].sql_or).should == '((x IS TRUE) OR (y IS FALSE))'
211
- @d.l([[:x, nil], [:y, [1,2,3]]].sql_or).should == '((x IS NULL) OR (y IN (1, 2, 3)))'
209
+ @d.l([[:x, 100],[:y, 'a']].sql_or).must_equal '((x = 100) OR (y = \'a\'))'
210
+ @d.l([[:x, true], [:y, false]].sql_or).must_equal '((x IS TRUE) OR (y IS FALSE))'
211
+ @d.l([[:x, nil], [:y, [1,2,3]]].sql_or).must_equal '((x IS NULL) OR (y IN (1, 2, 3)))'
212
212
  end
213
213
 
214
214
  it "should support Array#sql_string_join for concatenation of SQL strings" do
215
- @d.lit([:x].sql_string_join).should == '(x)'
216
- @d.lit([:x].sql_string_join(', ')).should == '(x)'
217
- @d.lit([:x, :y].sql_string_join).should == '(x || y)'
218
- @d.lit([:x, :y].sql_string_join(', ')).should == "(x || ', ' || y)"
219
- @d.lit([:x.sql_function(1), :y.sql_subscript(1)].sql_string_join).should == '(x(1) || y[1])'
220
- @d.lit([:x.sql_function(1), 'y.z'.lit].sql_string_join(', ')).should == "(x(1) || ', ' || y.z)"
221
- @d.lit([:x, 1, :y].sql_string_join).should == "(x || '1' || y)"
222
- @d.lit([:x, 1, :y].sql_string_join(', ')).should == "(x || ', ' || '1' || ', ' || y)"
223
- @d.lit([:x, 1, :y].sql_string_join(:y__z)).should == "(x || y.z || '1' || y.z || y)"
224
- @d.lit([:x, 1, :y].sql_string_join(1)).should == "(x || '1' || '1' || '1' || y)"
225
- @d.lit([:x, :y].sql_string_join('y.x || x.y'.lit)).should == "(x || y.x || x.y || y)"
226
- @d.lit([[:x, :y].sql_string_join, [:a, :b].sql_string_join].sql_string_join).should == "(x || y || a || b)"
215
+ @d.lit([:x].sql_string_join).must_equal '(x)'
216
+ @d.lit([:x].sql_string_join(', ')).must_equal '(x)'
217
+ @d.lit([:x, :y].sql_string_join).must_equal '(x || y)'
218
+ @d.lit([:x, :y].sql_string_join(', ')).must_equal "(x || ', ' || y)"
219
+ @d.lit([:x.sql_function(1), :y.sql_subscript(1)].sql_string_join).must_equal '(x(1) || y[1])'
220
+ @d.lit([:x.sql_function(1), 'y.z'.lit].sql_string_join(', ')).must_equal "(x(1) || ', ' || y.z)"
221
+ @d.lit([:x, 1, :y].sql_string_join).must_equal "(x || '1' || y)"
222
+ @d.lit([:x, 1, :y].sql_string_join(', ')).must_equal "(x || ', ' || '1' || ', ' || y)"
223
+ @d.lit([:x, 1, :y].sql_string_join(:y__z)).must_equal "(x || y.z || '1' || y.z || y)"
224
+ @d.lit([:x, 1, :y].sql_string_join(1)).must_equal "(x || '1' || '1' || '1' || y)"
225
+ @d.lit([:x, :y].sql_string_join('y.x || x.y'.lit)).must_equal "(x || y.x || x.y || y)"
226
+ @d.lit([[:x, :y].sql_string_join, [:a, :b].sql_string_join].sql_string_join).must_equal "(x || y || a || b)"
227
227
  end
228
228
 
229
229
  it "should support sql_expr on hashes" do
230
- @d.l({:x => 100, :y => 'a'}.sql_expr)[1...-1].split(' AND ').sort.should == ['(x = 100)', '(y = \'a\')']
231
- @d.l({:x => true, :y => false}.sql_expr)[1...-1].split(' AND ').sort.should == ['(x IS TRUE)', '(y IS FALSE)']
232
- @d.l({:x => nil, :y => [1,2,3]}.sql_expr)[1...-1].split(' AND ').sort.should == ['(x IS NULL)', '(y IN (1, 2, 3))']
230
+ @d.l({:x => 100, :y => 'a'}.sql_expr)[1...-1].split(' AND ').sort.must_equal ['(x = 100)', '(y = \'a\')']
231
+ @d.l({:x => true, :y => false}.sql_expr)[1...-1].split(' AND ').sort.must_equal ['(x IS TRUE)', '(y IS FALSE)']
232
+ @d.l({:x => nil, :y => [1,2,3]}.sql_expr)[1...-1].split(' AND ').sort.must_equal ['(x IS NULL)', '(y IN (1, 2, 3))']
233
233
  end
234
234
 
235
235
  it "should support sql_negate on hashes" do
236
- @d.l({:x => 100, :y => 'a'}.sql_negate)[1...-1].split(' AND ').sort.should == ['(x != 100)', '(y != \'a\')']
237
- @d.l({:x => true, :y => false}.sql_negate)[1...-1].split(' AND ').sort.should == ['(x IS NOT TRUE)', '(y IS NOT FALSE)']
238
- @d.l({:x => nil, :y => [1,2,3]}.sql_negate)[1...-1].split(' AND ').sort.should == ['(x IS NOT NULL)', '(y NOT IN (1, 2, 3))']
236
+ @d.l({:x => 100, :y => 'a'}.sql_negate)[1...-1].split(' AND ').sort.must_equal ['(x != 100)', '(y != \'a\')']
237
+ @d.l({:x => true, :y => false}.sql_negate)[1...-1].split(' AND ').sort.must_equal ['(x IS NOT TRUE)', '(y IS NOT FALSE)']
238
+ @d.l({:x => nil, :y => [1,2,3]}.sql_negate)[1...-1].split(' AND ').sort.must_equal ['(x IS NOT NULL)', '(y NOT IN (1, 2, 3))']
239
239
  end
240
240
 
241
241
  it "should support ~ on hashes" do
242
- @d.l(~{:x => 100, :y => 'a'})[1...-1].split(' OR ').sort.should == ['(x != 100)', '(y != \'a\')']
243
- @d.l(~{:x => true, :y => false})[1...-1].split(' OR ').sort.should == ['(x IS NOT TRUE)', '(y IS NOT FALSE)']
244
- @d.l(~{:x => nil, :y => [1,2,3]})[1...-1].split(' OR ').sort.should == ['(x IS NOT NULL)', '(y NOT IN (1, 2, 3))']
242
+ @d.l(~{:x => 100, :y => 'a'})[1...-1].split(' OR ').sort.must_equal ['(x != 100)', '(y != \'a\')']
243
+ @d.l(~{:x => true, :y => false})[1...-1].split(' OR ').sort.must_equal ['(x IS NOT TRUE)', '(y IS NOT FALSE)']
244
+ @d.l(~{:x => nil, :y => [1,2,3]})[1...-1].split(' OR ').sort.must_equal ['(x IS NOT NULL)', '(y NOT IN (1, 2, 3))']
245
245
  end
246
246
 
247
247
  it "should support sql_or on hashes" do
248
- @d.l({:x => 100, :y => 'a'}.sql_or)[1...-1].split(' OR ').sort.should == ['(x = 100)', '(y = \'a\')']
249
- @d.l({:x => true, :y => false}.sql_or)[1...-1].split(' OR ').sort.should == ['(x IS TRUE)', '(y IS FALSE)']
250
- @d.l({:x => nil, :y => [1,2,3]}.sql_or)[1...-1].split(' OR ').sort.should == ['(x IS NULL)', '(y IN (1, 2, 3))']
248
+ @d.l({:x => 100, :y => 'a'}.sql_or)[1...-1].split(' OR ').sort.must_equal ['(x = 100)', '(y = \'a\')']
249
+ @d.l({:x => true, :y => false}.sql_or)[1...-1].split(' OR ').sort.must_equal ['(x IS TRUE)', '(y IS FALSE)']
250
+ @d.l({:x => nil, :y => [1,2,3]}.sql_or)[1...-1].split(' OR ').sort.must_equal ['(x IS NULL)', '(y IN (1, 2, 3))']
251
251
  end
252
252
 
253
253
  it "should Hash#& and Hash#|" do
254
- @d.l({:y => :z} & :x).should == '((y = z) AND x)'
255
- @d.l({:x => :a} & {:y => :z}).should == '((x = a) AND (y = z))'
256
- @d.l({:y => :z} | :x).should == '((y = z) OR x)'
257
- @d.l({:x => :a} | {:y => :z}).should == '((x = a) OR (y = z))'
254
+ @d.l({:y => :z} & :x).must_equal '((y = z) AND x)'
255
+ @d.l({:x => :a} & {:y => :z}).must_equal '((x = a) AND (y = z))'
256
+ @d.l({:y => :z} | :x).must_equal '((y = z) OR x)'
257
+ @d.l({:x => :a} | {:y => :z}).must_equal '((x = a) OR (y = z))'
258
258
  end
259
259
  end
260
260
 
@@ -263,30 +263,30 @@ describe "Array#case and Hash#case" do
263
263
  @d = Sequel.mock.dataset
264
264
  end
265
265
 
266
- specify "should return SQL CASE expression" do
267
- @d.literal({:x=>:y}.case(:z)).should == '(CASE WHEN x THEN y ELSE z END)'
268
- @d.literal({:x=>:y}.case(:z, :exp)).should == '(CASE exp WHEN x THEN y ELSE z END)'
266
+ it "should return SQL CASE expression" do
267
+ @d.literal({:x=>:y}.case(:z)).must_equal '(CASE WHEN x THEN y ELSE z END)'
268
+ @d.literal({:x=>:y}.case(:z, :exp)).must_equal '(CASE exp WHEN x THEN y ELSE z END)'
269
269
  ['(CASE WHEN x THEN y WHEN a THEN b ELSE z END)',
270
- '(CASE WHEN a THEN b WHEN x THEN y ELSE z END)'].should(include(@d.literal({:x=>:y, :a=>:b}.case(:z))))
271
- @d.literal([[:x, :y]].case(:z)).should == '(CASE WHEN x THEN y ELSE z END)'
272
- @d.literal([[:x, :y], [:a, :b]].case(:z)).should == '(CASE WHEN x THEN y WHEN a THEN b ELSE z END)'
273
- @d.literal([[:x, :y], [:a, :b]].case(:z, :exp)).should == '(CASE exp WHEN x THEN y WHEN a THEN b ELSE z END)'
274
- @d.literal([[:x, :y], [:a, :b]].case(:z, :exp__w)).should == '(CASE exp.w WHEN x THEN y WHEN a THEN b ELSE z END)'
270
+ '(CASE WHEN a THEN b WHEN x THEN y ELSE z END)'].must_include(@d.literal({:x=>:y, :a=>:b}.case(:z)))
271
+ @d.literal([[:x, :y]].case(:z)).must_equal '(CASE WHEN x THEN y ELSE z END)'
272
+ @d.literal([[:x, :y], [:a, :b]].case(:z)).must_equal '(CASE WHEN x THEN y WHEN a THEN b ELSE z END)'
273
+ @d.literal([[:x, :y], [:a, :b]].case(:z, :exp)).must_equal '(CASE exp WHEN x THEN y WHEN a THEN b ELSE z END)'
274
+ @d.literal([[:x, :y], [:a, :b]].case(:z, :exp__w)).must_equal '(CASE exp.w WHEN x THEN y WHEN a THEN b ELSE z END)'
275
275
  end
276
276
 
277
- specify "should return SQL CASE expression with expression even if nil" do
278
- @d.literal({:x=>:y}.case(:z, nil)).should == '(CASE NULL WHEN x THEN y ELSE z END)'
277
+ it "should return SQL CASE expression with expression even if nil" do
278
+ @d.literal({:x=>:y}.case(:z, nil)).must_equal '(CASE NULL WHEN x THEN y ELSE z END)'
279
279
  end
280
280
 
281
- specify "should raise an error if an array that isn't all two pairs is used" do
282
- proc{[:b].case(:a)}.should raise_error(Sequel::Error)
283
- proc{[:b, :c].case(:a)}.should raise_error(Sequel::Error)
284
- proc{[[:b, :c], :d].case(:a)}.should raise_error(Sequel::Error)
281
+ it "should raise an error if an array that isn't all two pairs is used" do
282
+ proc{[:b].case(:a)}.must_raise(Sequel::Error)
283
+ proc{[:b, :c].case(:a)}.must_raise(Sequel::Error)
284
+ proc{[[:b, :c], :d].case(:a)}.must_raise(Sequel::Error)
285
285
  end
286
286
 
287
- specify "should raise an error if an empty array/hash is used" do
288
- proc{[].case(:a)}.should raise_error(Sequel::Error)
289
- proc{{}.case(:a)}.should raise_error(Sequel::Error)
287
+ it "should raise an error if an empty array/hash is used" do
288
+ proc{[].case(:a)}.must_raise(Sequel::Error)
289
+ proc{{}.case(:a)}.must_raise(Sequel::Error)
290
290
  end
291
291
  end
292
292
 
@@ -295,65 +295,65 @@ describe "Array#sql_value_list and #sql_array" do
295
295
  @d = Sequel.mock.dataset
296
296
  end
297
297
 
298
- specify "should treat the array as an SQL value list instead of conditions when used as a placeholder value" do
299
- @d.filter("(a, b) IN ?", [[:x, 1], [:y, 2]]).sql.should == 'SELECT * WHERE ((a, b) IN ((x = 1) AND (y = 2)))'
300
- @d.filter("(a, b) IN ?", [[:x, 1], [:y, 2]].sql_value_list).sql.should == 'SELECT * WHERE ((a, b) IN ((x, 1), (y, 2)))'
301
- @d.filter("(a, b) IN ?", [[:x, 1], [:y, 2]].sql_array).sql.should == 'SELECT * WHERE ((a, b) IN ((x, 1), (y, 2)))'
298
+ it "should treat the array as an SQL value list instead of conditions when used as a placeholder value" do
299
+ @d.filter("(a, b) IN ?", [[:x, 1], [:y, 2]]).sql.must_equal 'SELECT * WHERE ((a, b) IN ((x = 1) AND (y = 2)))'
300
+ @d.filter("(a, b) IN ?", [[:x, 1], [:y, 2]].sql_value_list).sql.must_equal 'SELECT * WHERE ((a, b) IN ((x, 1), (y, 2)))'
301
+ @d.filter("(a, b) IN ?", [[:x, 1], [:y, 2]].sql_array).sql.must_equal 'SELECT * WHERE ((a, b) IN ((x, 1), (y, 2)))'
302
302
  end
303
303
 
304
- specify "should be no difference when used as a hash value" do
305
- @d.filter([:a, :b]=>[[:x, 1], [:y, 2]]).sql.should == 'SELECT * WHERE ((a, b) IN ((x, 1), (y, 2)))'
306
- @d.filter([:a, :b]=>[[:x, 1], [:y, 2]].sql_value_list).sql.should == 'SELECT * WHERE ((a, b) IN ((x, 1), (y, 2)))'
307
- @d.filter([:a, :b]=>[[:x, 1], [:y, 2]].sql_array).sql.should == 'SELECT * WHERE ((a, b) IN ((x, 1), (y, 2)))'
304
+ it "should be no difference when used as a hash value" do
305
+ @d.filter([:a, :b]=>[[:x, 1], [:y, 2]]).sql.must_equal 'SELECT * WHERE ((a, b) IN ((x, 1), (y, 2)))'
306
+ @d.filter([:a, :b]=>[[:x, 1], [:y, 2]].sql_value_list).sql.must_equal 'SELECT * WHERE ((a, b) IN ((x, 1), (y, 2)))'
307
+ @d.filter([:a, :b]=>[[:x, 1], [:y, 2]].sql_array).sql.must_equal 'SELECT * WHERE ((a, b) IN ((x, 1), (y, 2)))'
308
308
  end
309
309
  end
310
310
 
311
311
  describe "String#lit" do
312
312
  before do
313
- @ds = ds = Sequel::Database.new[:t]
313
+ @ds = Sequel::Database.new[:t]
314
314
  end
315
315
 
316
- specify "should return an LiteralString object" do
317
- 'xyz'.lit.should be_a_kind_of(Sequel::LiteralString)
318
- 'xyz'.lit.to_s.should == 'xyz'
316
+ it "should return an LiteralString object" do
317
+ 'xyz'.lit.must_be_kind_of(Sequel::LiteralString)
318
+ 'xyz'.lit.to_s.must_equal 'xyz'
319
319
  end
320
320
 
321
- specify "should inhibit string literalization" do
322
- @ds.update_sql(:stamp => "NOW()".lit).should == "UPDATE t SET stamp = NOW()"
321
+ it "should inhibit string literalization" do
322
+ @ds.update_sql(:stamp => "NOW()".lit).must_equal "UPDATE t SET stamp = NOW()"
323
323
  end
324
324
 
325
- specify "should return a PlaceholderLiteralString object if args are given" do
325
+ it "should return a PlaceholderLiteralString object if args are given" do
326
326
  a = 'DISTINCT ?'.lit(:a)
327
- a.should be_a_kind_of(Sequel::SQL::PlaceholderLiteralString)
328
- @ds.literal(a).should == 'DISTINCT a'
327
+ a.must_be_kind_of(Sequel::SQL::PlaceholderLiteralString)
328
+ @ds.literal(a).must_equal 'DISTINCT a'
329
329
  @ds.quote_identifiers = true
330
- @ds.literal(a).should == 'DISTINCT "a"'
330
+ @ds.literal(a).must_equal 'DISTINCT "a"'
331
331
  end
332
332
 
333
- specify "should handle named placeholders if given a single argument hash" do
333
+ it "should handle named placeholders if given a single argument hash" do
334
334
  a = 'DISTINCT :b'.lit(:b=>:a)
335
- a.should be_a_kind_of(Sequel::SQL::PlaceholderLiteralString)
336
- @ds.literal(a).should == 'DISTINCT a'
335
+ a.must_be_kind_of(Sequel::SQL::PlaceholderLiteralString)
336
+ @ds.literal(a).must_equal 'DISTINCT a'
337
337
  @ds.quote_identifiers = true
338
- @ds.literal(a).should == 'DISTINCT "a"'
338
+ @ds.literal(a).must_equal 'DISTINCT "a"'
339
339
  end
340
340
 
341
- specify "should treat placeholder literal strings as generic expressions" do
341
+ it "should treat placeholder literal strings as generic expressions" do
342
342
  a = ':b'.lit(:b=>:a)
343
- @ds.literal(a + 1).should == "(a + 1)"
344
- @ds.literal(a & :b).should == "(a AND b)"
345
- @ds.literal(a.sql_string + :b).should == "(a || b)"
343
+ @ds.literal(a + 1).must_equal "(a + 1)"
344
+ @ds.literal(a & :b).must_equal "(a AND b)"
345
+ @ds.literal(a.sql_string + :b).must_equal "(a || b)"
346
346
  end
347
347
  end
348
348
 
349
349
  describe "String#to_sequel_blob" do
350
- specify "should return a Blob object" do
351
- 'xyz'.to_sequel_blob.should be_a_kind_of(::Sequel::SQL::Blob)
352
- 'xyz'.to_sequel_blob.should == 'xyz'
350
+ it "should return a Blob object" do
351
+ 'xyz'.to_sequel_blob.must_be_kind_of(::Sequel::SQL::Blob)
352
+ 'xyz'.to_sequel_blob.must_equal 'xyz'
353
353
  end
354
354
 
355
- specify "should retain binary data" do
356
- "\1\2\3\4".to_sequel_blob.should == "\1\2\3\4"
355
+ it "should retain binary data" do
356
+ "\1\2\3\4".to_sequel_blob.must_equal "\1\2\3\4"
357
357
  end
358
358
  end
359
359
 
@@ -362,26 +362,26 @@ describe "String cast methods" do
362
362
  @ds = Sequel.mock.dataset
363
363
  end
364
364
 
365
- specify "should support cast method" do
366
- @ds.literal('abc'.cast(:integer)).should == "CAST('abc' AS integer)"
365
+ it "should support cast method" do
366
+ @ds.literal('abc'.cast(:integer)).must_equal "CAST('abc' AS integer)"
367
367
  end
368
368
 
369
- specify "should support cast_numeric and cast_string" do
369
+ it "should support cast_numeric and cast_string" do
370
370
  x = 'abc'.cast_numeric
371
- x.should be_a_kind_of(Sequel::SQL::NumericExpression)
372
- @ds.literal(x).should == "CAST('abc' AS integer)"
371
+ x.must_be_kind_of(Sequel::SQL::NumericExpression)
372
+ @ds.literal(x).must_equal "CAST('abc' AS integer)"
373
373
 
374
374
  x = 'abc'.cast_numeric(:real)
375
- x.should be_a_kind_of(Sequel::SQL::NumericExpression)
376
- @ds.literal(x).should == "CAST('abc' AS real)"
375
+ x.must_be_kind_of(Sequel::SQL::NumericExpression)
376
+ @ds.literal(x).must_equal "CAST('abc' AS real)"
377
377
 
378
378
  x = 'abc'.cast_string
379
- x.should be_a_kind_of(Sequel::SQL::StringExpression)
380
- @ds.literal(x).should == "CAST('abc' AS varchar(255))"
379
+ x.must_be_kind_of(Sequel::SQL::StringExpression)
380
+ @ds.literal(x).must_equal "CAST('abc' AS varchar(255))"
381
381
 
382
382
  x = 'abc'.cast_string(:varchar)
383
- x.should be_a_kind_of(Sequel::SQL::StringExpression)
384
- @ds.literal(x).should == "CAST('abc' AS varchar(255))"
383
+ x.must_be_kind_of(Sequel::SQL::StringExpression)
384
+ @ds.literal(x).must_equal "CAST('abc' AS varchar(255))"
385
385
  end
386
386
  end
387
387
 
@@ -390,14 +390,14 @@ describe "#desc" do
390
390
  @ds = Sequel.mock.dataset
391
391
  end
392
392
 
393
- specify "should format a DESC clause for a column ref" do
394
- @ds.literal(:test.desc).should == 'test DESC'
393
+ it "should format a DESC clause for a column ref" do
394
+ @ds.literal(:test.desc).must_equal 'test DESC'
395
395
 
396
- @ds.literal(:items__price.desc).should == 'items.price DESC'
396
+ @ds.literal(:items__price.desc).must_equal 'items.price DESC'
397
397
  end
398
398
 
399
- specify "should format a DESC clause for a function" do
400
- @ds.literal(:avg.sql_function(:test).desc).should == 'avg(test) DESC'
399
+ it "should format a DESC clause for a function" do
400
+ @ds.literal(:avg.sql_function(:test).desc).must_equal 'avg(test) DESC'
401
401
  end
402
402
  end
403
403
 
@@ -406,14 +406,14 @@ describe "#asc" do
406
406
  @ds = Sequel.mock.dataset
407
407
  end
408
408
 
409
- specify "should format a ASC clause for a column ref" do
410
- @ds.literal(:test.asc).should == 'test ASC'
409
+ it "should format a ASC clause for a column ref" do
410
+ @ds.literal(:test.asc).must_equal 'test ASC'
411
411
 
412
- @ds.literal(:items__price.asc).should == 'items.price ASC'
412
+ @ds.literal(:items__price.asc).must_equal 'items.price ASC'
413
413
  end
414
414
 
415
- specify "should format a ASC clause for a function" do
416
- @ds.literal(:avg.sql_function(:test).asc).should == 'avg(test) ASC'
415
+ it "should format a ASC clause for a function" do
416
+ @ds.literal(:avg.sql_function(:test).asc).must_equal 'avg(test) ASC'
417
417
  end
418
418
  end
419
419
 
@@ -422,18 +422,18 @@ describe "#as" do
422
422
  @ds = Sequel.mock.dataset
423
423
  end
424
424
 
425
- specify "should format a AS clause for a column ref" do
426
- @ds.literal(:test.as(:t)).should == 'test AS t'
425
+ it "should format a AS clause for a column ref" do
426
+ @ds.literal(:test.as(:t)).must_equal 'test AS t'
427
427
 
428
- @ds.literal(:items__price.as(:p)).should == 'items.price AS p'
428
+ @ds.literal(:items__price.as(:p)).must_equal 'items.price AS p'
429
429
  end
430
430
 
431
- specify "should format a AS clause for a function" do
432
- @ds.literal(:avg.sql_function(:test).as(:avg)).should == 'avg(test) AS avg'
431
+ it "should format a AS clause for a function" do
432
+ @ds.literal(:avg.sql_function(:test).as(:avg)).must_equal 'avg(test) AS avg'
433
433
  end
434
434
 
435
- specify "should format a AS clause for a literal value" do
436
- @ds.literal('abc'.as(:abc)).should == "'abc' AS abc"
435
+ it "should format a AS clause for a literal value" do
436
+ @ds.literal('abc'.as(:abc)).must_equal "'abc' AS abc"
437
437
  end
438
438
  end
439
439
 
@@ -446,48 +446,48 @@ describe "Column references" do
446
446
  @ds.quote_identifiers = true
447
447
  end
448
448
 
449
- specify "should be quoted properly" do
450
- @ds.literal(:xyz).should == "`xyz`"
451
- @ds.literal(:xyz__abc).should == "`xyz`.`abc`"
449
+ it "should be quoted properly" do
450
+ @ds.literal(:xyz).must_equal "`xyz`"
451
+ @ds.literal(:xyz__abc).must_equal "`xyz`.`abc`"
452
452
 
453
- @ds.literal(:xyz.as(:x)).should == "`xyz` AS `x`"
454
- @ds.literal(:xyz__abc.as(:x)).should == "`xyz`.`abc` AS `x`"
453
+ @ds.literal(:xyz.as(:x)).must_equal "`xyz` AS `x`"
454
+ @ds.literal(:xyz__abc.as(:x)).must_equal "`xyz`.`abc` AS `x`"
455
455
 
456
- @ds.literal(:xyz___x).should == "`xyz` AS `x`"
457
- @ds.literal(:xyz__abc___x).should == "`xyz`.`abc` AS `x`"
456
+ @ds.literal(:xyz___x).must_equal "`xyz` AS `x`"
457
+ @ds.literal(:xyz__abc___x).must_equal "`xyz`.`abc` AS `x`"
458
458
  end
459
459
 
460
- specify "should be quoted properly in SQL functions" do
461
- @ds.literal(:avg.sql_function(:xyz)).should == "avg(`xyz`)"
462
- @ds.literal(:avg.sql_function(:xyz, 1)).should == "avg(`xyz`, 1)"
463
- @ds.literal(:avg.sql_function(:xyz).as(:a)).should == "avg(`xyz`) AS `a`"
460
+ it "should be quoted properly in SQL functions" do
461
+ @ds.literal(:avg.sql_function(:xyz)).must_equal "avg(`xyz`)"
462
+ @ds.literal(:avg.sql_function(:xyz, 1)).must_equal "avg(`xyz`, 1)"
463
+ @ds.literal(:avg.sql_function(:xyz).as(:a)).must_equal "avg(`xyz`) AS `a`"
464
464
  end
465
465
 
466
- specify "should be quoted properly in ASC/DESC clauses" do
467
- @ds.literal(:xyz.asc).should == "`xyz` ASC"
468
- @ds.literal(:avg.sql_function(:xyz, 1).desc).should == "avg(`xyz`, 1) DESC"
466
+ it "should be quoted properly in ASC/DESC clauses" do
467
+ @ds.literal(:xyz.asc).must_equal "`xyz` ASC"
468
+ @ds.literal(:avg.sql_function(:xyz, 1).desc).must_equal "avg(`xyz`, 1) DESC"
469
469
  end
470
470
 
471
- specify "should be quoted properly in a cast function" do
472
- @ds.literal(:x.cast(:integer)).should == "CAST(`x` AS integer)"
473
- @ds.literal(:x__y.cast('varchar(20)')).should == "CAST(`x`.`y` AS varchar(20))"
471
+ it "should be quoted properly in a cast function" do
472
+ @ds.literal(:x.cast(:integer)).must_equal "CAST(`x` AS integer)"
473
+ @ds.literal(:x__y.cast('varchar(20)')).must_equal "CAST(`x`.`y` AS varchar(20))"
474
474
  end
475
475
  end
476
476
 
477
477
  describe "Blob" do
478
- specify "#to_sequel_blob should return self" do
478
+ it "#to_sequel_blob should return self" do
479
479
  blob = "x".to_sequel_blob
480
- blob.to_sequel_blob.object_id.should == blob.object_id
480
+ blob.to_sequel_blob.object_id.must_equal blob.object_id
481
481
  end
482
482
  end
483
483
 
484
484
  if RUBY_VERSION < '1.9.0'
485
485
  describe "Symbol#[]" do
486
- specify "should format an SQL Function" do
486
+ it "should format an SQL Function" do
487
487
  ds = Sequel.mock.dataset
488
- ds.literal(:xyz[]).should == 'xyz()'
489
- ds.literal(:xyz[1]).should == 'xyz(1)'
490
- ds.literal(:xyz[1, 2, :abc[3]]).should == 'xyz(1, 2, abc(3))'
488
+ ds.literal(:xyz[]).must_equal 'xyz()'
489
+ ds.literal(:xyz[1]).must_equal 'xyz(1)'
490
+ ds.literal(:xyz[1, 2, :abc[3]]).must_equal 'xyz(1, 2, abc(3))'
491
491
  end
492
492
  end
493
493
  end
@@ -497,18 +497,18 @@ describe "Symbol#*" do
497
497
  @ds = Sequel.mock.dataset
498
498
  end
499
499
 
500
- specify "should format a qualified wildcard if no argument" do
501
- @ds.literal(:xyz.*).should == 'xyz.*'
502
- @ds.literal(:abc.*).should == 'abc.*'
500
+ it "should format a qualified wildcard if no argument" do
501
+ @ds.literal(:xyz.*).must_equal 'xyz.*'
502
+ @ds.literal(:abc.*).must_equal 'abc.*'
503
503
  end
504
504
 
505
- specify "should format a filter expression if an argument" do
506
- @ds.literal(:xyz.*(3)).should == '(xyz * 3)'
507
- @ds.literal(:abc.*(5)).should == '(abc * 5)'
505
+ it "should format a filter expression if an argument" do
506
+ @ds.literal(:xyz.*(3)).must_equal '(xyz * 3)'
507
+ @ds.literal(:abc.*(5)).must_equal '(abc * 5)'
508
508
  end
509
509
 
510
- specify "should support qualified symbols if no argument" do
511
- @ds.literal(:xyz__abc.*).should == 'xyz.abc.*'
510
+ it "should support qualified symbols if no argument" do
511
+ @ds.literal(:xyz__abc.*).must_equal 'xyz.abc.*'
512
512
  end
513
513
  end
514
514
 
@@ -519,40 +519,40 @@ describe "Symbol" do
519
519
  @ds.identifier_input_method = :upcase
520
520
  end
521
521
 
522
- specify "#identifier should format an identifier" do
523
- @ds.literal(:xyz__abc.identifier).should == '"XYZ__ABC"'
522
+ it "#identifier should format an identifier" do
523
+ @ds.literal(:xyz__abc.identifier).must_equal '"XYZ__ABC"'
524
524
  end
525
525
 
526
- specify "#qualify should format a qualified column" do
527
- @ds.literal(:xyz.qualify(:abc)).should == '"ABC"."XYZ"'
526
+ it "#qualify should format a qualified column" do
527
+ @ds.literal(:xyz.qualify(:abc)).must_equal '"ABC"."XYZ"'
528
528
  end
529
529
 
530
- specify "#qualify should work on QualifiedIdentifiers" do
531
- @ds.literal(:xyz.qualify(:abc).qualify(:def)).should == '"DEF"."ABC"."XYZ"'
530
+ it "#qualify should work on QualifiedIdentifiers" do
531
+ @ds.literal(:xyz.qualify(:abc).qualify(:def)).must_equal '"DEF"."ABC"."XYZ"'
532
532
  end
533
533
 
534
- specify "should be able to qualify an identifier" do
535
- @ds.literal(:xyz.identifier.qualify(:xyz__abc)).should == '"XYZ"."ABC"."XYZ"'
534
+ it "should be able to qualify an identifier" do
535
+ @ds.literal(:xyz.identifier.qualify(:xyz__abc)).must_equal '"XYZ"."ABC"."XYZ"'
536
536
  end
537
537
 
538
- specify "should be able to specify a schema.table.column" do
539
- @ds.literal(:column.qualify(:table.qualify(:schema))).should == '"SCHEMA"."TABLE"."COLUMN"'
540
- @ds.literal(:column.qualify(:table__name.identifier.qualify(:schema))).should == '"SCHEMA"."TABLE__NAME"."COLUMN"'
538
+ it "should be able to specify a schema.table.column" do
539
+ @ds.literal(:column.qualify(:table.qualify(:schema))).must_equal '"SCHEMA"."TABLE"."COLUMN"'
540
+ @ds.literal(:column.qualify(:table__name.identifier.qualify(:schema))).must_equal '"SCHEMA"."TABLE__NAME"."COLUMN"'
541
541
  end
542
542
 
543
- specify "should be able to specify order" do
543
+ it "should be able to specify order" do
544
544
  @oe = :xyz.desc
545
- @oe.class.should == Sequel::SQL::OrderedExpression
546
- @oe.descending.should == true
545
+ @oe.class.must_equal Sequel::SQL::OrderedExpression
546
+ @oe.descending.must_equal true
547
547
  @oe = :xyz.asc
548
- @oe.class.should == Sequel::SQL::OrderedExpression
549
- @oe.descending.should == false
548
+ @oe.class.must_equal Sequel::SQL::OrderedExpression
549
+ @oe.descending.must_equal false
550
550
  end
551
551
 
552
- specify "should work correctly with objects" do
552
+ it "should work correctly with objects" do
553
553
  o = Object.new
554
554
  def o.sql_literal(ds) "(foo)" end
555
- @ds.literal(:column.qualify(o)).should == '(foo)."COLUMN"'
555
+ @ds.literal(:column.qualify(o)).must_equal '(foo)."COLUMN"'
556
556
  end
557
557
  end
558
558
 
@@ -561,69 +561,69 @@ describe "Symbol" do
561
561
  @ds = Sequel::Database.new.dataset
562
562
  end
563
563
 
564
- specify "should support sql_function method" do
565
- @ds.literal(:COUNT.sql_function('1')).should == "COUNT('1')"
566
- @ds.select(:COUNT.sql_function('1')).sql.should == "SELECT COUNT('1')"
564
+ it "should support sql_function method" do
565
+ @ds.literal(:COUNT.sql_function('1')).must_equal "COUNT('1')"
566
+ @ds.select(:COUNT.sql_function('1')).sql.must_equal "SELECT COUNT('1')"
567
567
  end
568
568
 
569
- specify "should support cast method" do
570
- @ds.literal(:abc.cast(:integer)).should == "CAST(abc AS integer)"
569
+ it "should support cast method" do
570
+ @ds.literal(:abc.cast(:integer)).must_equal "CAST(abc AS integer)"
571
571
  end
572
572
 
573
- specify "should support sql array accesses via sql_subscript" do
574
- @ds.literal(:abc.sql_subscript(1)).should == "abc[1]"
575
- @ds.literal(:abc__def.sql_subscript(1)).should == "abc.def[1]"
576
- @ds.literal(:abc.sql_subscript(1)|2).should == "abc[1, 2]"
577
- @ds.literal(:abc.sql_subscript(1)[2]).should == "abc[1][2]"
573
+ it "should support sql array accesses via sql_subscript" do
574
+ @ds.literal(:abc.sql_subscript(1)).must_equal "abc[1]"
575
+ @ds.literal(:abc__def.sql_subscript(1)).must_equal "abc.def[1]"
576
+ @ds.literal(:abc.sql_subscript(1)|2).must_equal "abc[1, 2]"
577
+ @ds.literal(:abc.sql_subscript(1)[2]).must_equal "abc[1][2]"
578
578
  end
579
579
 
580
- specify "should support cast_numeric and cast_string" do
580
+ it "should support cast_numeric and cast_string" do
581
581
  x = :abc.cast_numeric
582
- x.should be_a_kind_of(Sequel::SQL::NumericExpression)
583
- @ds.literal(x).should == "CAST(abc AS integer)"
582
+ x.must_be_kind_of(Sequel::SQL::NumericExpression)
583
+ @ds.literal(x).must_equal "CAST(abc AS integer)"
584
584
 
585
585
  x = :abc.cast_numeric(:real)
586
- x.should be_a_kind_of(Sequel::SQL::NumericExpression)
587
- @ds.literal(x).should == "CAST(abc AS real)"
586
+ x.must_be_kind_of(Sequel::SQL::NumericExpression)
587
+ @ds.literal(x).must_equal "CAST(abc AS real)"
588
588
 
589
589
  x = :abc.cast_string
590
- x.should be_a_kind_of(Sequel::SQL::StringExpression)
591
- @ds.literal(x).should == "CAST(abc AS varchar(255))"
590
+ x.must_be_kind_of(Sequel::SQL::StringExpression)
591
+ @ds.literal(x).must_equal "CAST(abc AS varchar(255))"
592
592
 
593
593
  x = :abc.cast_string(:varchar)
594
- x.should be_a_kind_of(Sequel::SQL::StringExpression)
595
- @ds.literal(x).should == "CAST(abc AS varchar(255))"
594
+ x.must_be_kind_of(Sequel::SQL::StringExpression)
595
+ @ds.literal(x).must_equal "CAST(abc AS varchar(255))"
596
596
  end
597
597
 
598
- specify "should support boolean methods" do
599
- @ds.literal(~:x).should == "NOT x"
600
- @ds.literal(:x & :y).should == "(x AND y)"
601
- @ds.literal(:x | :y).should == "(x OR y)"
598
+ it "should support boolean methods" do
599
+ @ds.literal(~:x).must_equal "NOT x"
600
+ @ds.literal(:x & :y).must_equal "(x AND y)"
601
+ @ds.literal(:x | :y).must_equal "(x OR y)"
602
602
  end
603
603
 
604
- specify "should support complex expression methods" do
605
- @ds.literal(:x.sql_boolean & 1).should == "(x AND 1)"
606
- @ds.literal(:x.sql_number & :y).should == "(x & y)"
607
- @ds.literal(:x.sql_string + :y).should == "(x || y)"
604
+ it "should support complex expression methods" do
605
+ @ds.literal(:x.sql_boolean & 1).must_equal "(x AND 1)"
606
+ @ds.literal(:x.sql_number & :y).must_equal "(x & y)"
607
+ @ds.literal(:x.sql_string + :y).must_equal "(x || y)"
608
608
  end
609
609
 
610
- specify "should allow database independent types when casting" do
610
+ it "should allow database independent types when casting" do
611
611
  db = @ds.db
612
612
  def db.cast_type_literal(type)
613
613
  return :foo if type == Integer
614
614
  return :bar if type == String
615
615
  type
616
616
  end
617
- @ds.literal(:abc.cast(String)).should == "CAST(abc AS bar)"
618
- @ds.literal(:abc.cast(String)).should == "CAST(abc AS bar)"
619
- @ds.literal(:abc.cast_string).should == "CAST(abc AS bar)"
620
- @ds.literal(:abc.cast_string(Integer)).should == "CAST(abc AS foo)"
621
- @ds.literal(:abc.cast_numeric).should == "CAST(abc AS foo)"
622
- @ds.literal(:abc.cast_numeric(String)).should == "CAST(abc AS bar)"
617
+ @ds.literal(:abc.cast(String)).must_equal "CAST(abc AS bar)"
618
+ @ds.literal(:abc.cast(String)).must_equal "CAST(abc AS bar)"
619
+ @ds.literal(:abc.cast_string).must_equal "CAST(abc AS bar)"
620
+ @ds.literal(:abc.cast_string(Integer)).must_equal "CAST(abc AS foo)"
621
+ @ds.literal(:abc.cast_numeric).must_equal "CAST(abc AS foo)"
622
+ @ds.literal(:abc.cast_numeric(String)).must_equal "CAST(abc AS bar)"
623
623
  end
624
624
 
625
- specify "should support SQL EXTRACT function via #extract " do
626
- @ds.literal(:abc.extract(:year)).should == "extract(year FROM abc)"
625
+ it "should support SQL EXTRACT function via #extract " do
626
+ @ds.literal(:abc.extract(:year)).must_equal "extract(year FROM abc)"
627
627
  end
628
628
  end
629
629
 
@@ -634,62 +634,62 @@ describe "Postgres extensions integration" do
634
634
  end
635
635
 
636
636
  it "Symbol#pg_array should return an ArrayOp" do
637
- @db.literal(:a.pg_array.unnest).should == "unnest(a)"
637
+ @db.literal(:a.pg_array.unnest).must_equal "unnest(a)"
638
638
  end
639
639
 
640
640
  it "Symbol#pg_row should return a PGRowOp" do
641
- @db.literal(:a.pg_row[:a]).should == "(a).a"
641
+ @db.literal(:a.pg_row[:a]).must_equal "(a).a"
642
642
  end
643
643
 
644
644
  it "Symbol#hstore should return an HStoreOp" do
645
- @db.literal(:a.hstore['a']).should == "(a -> 'a')"
645
+ @db.literal(:a.hstore['a']).must_equal "(a -> 'a')"
646
646
  end
647
647
 
648
648
  it "Symbol#pg_json should return an JSONOp" do
649
- @db.literal(:a.pg_json[%w'a b']).should == "(a #> ARRAY['a','b'])"
650
- @db.literal(:a.pg_json.extract('a')).should == "json_extract_path(a, 'a')"
649
+ @db.literal(:a.pg_json[%w'a b']).must_equal "(a #> ARRAY['a','b'])"
650
+ @db.literal(:a.pg_json.extract('a')).must_equal "json_extract_path(a, 'a')"
651
651
  end
652
652
 
653
653
  it "Symbol#pg_jsonb should return an JSONBOp" do
654
- @db.literal(:a.pg_jsonb[%w'a b']).should == "(a #> ARRAY['a','b'])"
655
- @db.literal(:a.pg_jsonb.extract('a')).should == "jsonb_extract_path(a, 'a')"
654
+ @db.literal(:a.pg_jsonb[%w'a b']).must_equal "(a #> ARRAY['a','b'])"
655
+ @db.literal(:a.pg_jsonb.extract('a')).must_equal "jsonb_extract_path(a, 'a')"
656
656
  end
657
657
 
658
658
  it "Symbol#pg_range should return a RangeOp" do
659
- @db.literal(:a.pg_range.lower).should == "lower(a)"
659
+ @db.literal(:a.pg_range.lower).must_equal "lower(a)"
660
660
  end
661
661
 
662
662
  it "Array#pg_array should return a PGArray" do
663
- @db.literal([1].pg_array.op.unnest).should == "unnest(ARRAY[1])"
664
- @db.literal([1].pg_array(:int4).op.unnest).should == "unnest(ARRAY[1]::int4[])"
663
+ @db.literal([1].pg_array.op.unnest).must_equal "unnest(ARRAY[1])"
664
+ @db.literal([1].pg_array(:int4).op.unnest).must_equal "unnest(ARRAY[1]::int4[])"
665
665
  end
666
666
 
667
667
  it "Array#pg_json should return a JSONArray" do
668
- @db.literal([1].pg_json).should == "'[1]'::json"
668
+ @db.literal([1].pg_json).must_equal "'[1]'::json"
669
669
  end
670
670
 
671
671
  it "Array#pg_jsonb should return a JSONBArray" do
672
- @db.literal([1].pg_jsonb).should == "'[1]'::jsonb"
672
+ @db.literal([1].pg_jsonb).must_equal "'[1]'::jsonb"
673
673
  end
674
674
 
675
675
  it "Array#pg_row should return a ArrayRow" do
676
- @db.literal([1].pg_row).should == "ROW(1)"
676
+ @db.literal([1].pg_row).must_equal "ROW(1)"
677
677
  end
678
678
 
679
679
  it "Hash#hstore should return an HStore" do
680
- @db.literal({'a'=>1}.hstore.op['a']).should == '(\'"a"=>"1"\'::hstore -> \'a\')'
680
+ @db.literal({'a'=>1}.hstore.op['a']).must_equal '(\'"a"=>"1"\'::hstore -> \'a\')'
681
681
  end
682
682
 
683
683
  it "Hash#pg_json should return an JSONHash" do
684
- @db.literal({'a'=>'b'}.pg_json).should == "'{\"a\":\"b\"}'::json"
684
+ @db.literal({'a'=>'b'}.pg_json).must_equal "'{\"a\":\"b\"}'::json"
685
685
  end
686
686
 
687
687
  it "Hash#pg_jsonb should return an JSONBHash" do
688
- @db.literal({'a'=>'b'}.pg_jsonb).should == "'{\"a\":\"b\"}'::jsonb"
688
+ @db.literal({'a'=>'b'}.pg_jsonb).must_equal "'{\"a\":\"b\"}'::jsonb"
689
689
  end
690
690
 
691
691
  it "Range#pg_range should return an PGRange" do
692
- @db.literal((1..2).pg_range).should == "'[1,2]'"
693
- @db.literal((1..2).pg_range(:int4range)).should == "'[1,2]'::int4range"
692
+ @db.literal((1..2).pg_range).must_equal "'[1,2]'"
693
+ @db.literal((1..2).pg_range(:int4range)).must_equal "'[1,2]'::int4range"
694
694
  end
695
695
  end