sequel 4.22.0 → 4.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -19,9 +19,9 @@ describe Sequel::Model, "single table inheritance plugin" do
19
19
  Object.send(:remove_const, :StiTest)
20
20
  end
21
21
 
22
- specify "should have simple_table = nil" do
23
- StiTest.simple_table.should == "sti_tests"
24
- StiTestSub1.simple_table.should == nil
22
+ it "should have simple_table = nil" do
23
+ StiTest.simple_table.must_equal "sti_tests"
24
+ StiTestSub1.simple_table.must_equal nil
25
25
  end
26
26
 
27
27
  it "should allow changing the inheritance column via a plugin :single_table_inheritance call" do
@@ -31,31 +31,31 @@ describe Sequel::Model, "single table inheritance plugin" do
31
31
  class ::StiTestSub1 < StiTest; end
32
32
  class ::StiTestSub2 < StiTest; end
33
33
  @ds._fetch = [{:blah=>'StiTest'}, {:blah=>'StiTestSub1'}, {:blah=>'StiTestSub2'}]
34
- StiTest.all.collect{|x| x.class}.should == [StiTest, StiTestSub1, StiTestSub2]
35
- StiTest.dataset.sql.should == "SELECT * FROM sti_tests"
36
- StiTestSub1.dataset.sql.should == "SELECT * FROM sti_tests WHERE (sti_tests.blah IN ('StiTestSub1'))"
37
- StiTestSub2.dataset.sql.should == "SELECT * FROM sti_tests WHERE (sti_tests.blah IN ('StiTestSub2'))"
34
+ StiTest.all.collect{|x| x.class}.must_equal [StiTest, StiTestSub1, StiTestSub2]
35
+ StiTest.dataset.sql.must_equal "SELECT * FROM sti_tests"
36
+ StiTestSub1.dataset.sql.must_equal "SELECT * FROM sti_tests WHERE (sti_tests.blah IN ('StiTestSub1'))"
37
+ StiTestSub2.dataset.sql.must_equal "SELECT * FROM sti_tests WHERE (sti_tests.blah IN ('StiTestSub2'))"
38
38
  end
39
39
 
40
40
  it "should return rows with the correct class based on the polymorphic_key value" do
41
41
  @ds._fetch = [{:kind=>'StiTest'}, {:kind=>'StiTestSub1'}, {:kind=>'StiTestSub2'}]
42
- StiTest.all.collect{|x| x.class}.should == [StiTest, StiTestSub1, StiTestSub2]
42
+ StiTest.all.collect{|x| x.class}.must_equal [StiTest, StiTestSub1, StiTestSub2]
43
43
  end
44
44
 
45
45
  it "should return rows with the correct class based on the polymorphic_key value when retreiving by primary key" do
46
46
  @ds._fetch = [{:kind=>'StiTestSub1'}]
47
- StiTest[1].class.should == StiTestSub1
47
+ StiTest[1].class.must_equal StiTestSub1
48
48
  end
49
49
 
50
50
  it "should return rows with the correct class for subclasses based on the polymorphic_key value" do
51
51
  class ::StiTestSub1Sub < StiTestSub1; end
52
52
  StiTestSub1.dataset._fetch = [{:kind=>'StiTestSub1'}, {:kind=>'StiTestSub1Sub'}]
53
- StiTestSub1.all.collect{|x| x.class}.should == [StiTestSub1, StiTestSub1Sub]
53
+ StiTestSub1.all.collect{|x| x.class}.must_equal [StiTestSub1, StiTestSub1Sub]
54
54
  end
55
55
 
56
56
  it "should fallback to the main class if the given class does not exist" do
57
57
  @ds._fetch = {:kind=>'StiTestSub3'}
58
- StiTest.all.collect{|x| x.class}.should == [StiTest]
58
+ StiTest.all.collect{|x| x.class}.must_equal [StiTest]
59
59
  end
60
60
 
61
61
  it "should fallback to the main class if the sti_key field is empty or nil without calling constantize" do
@@ -66,22 +66,22 @@ describe Sequel::Model, "single table inheritance plugin" do
66
66
  end
67
67
  StiTest.plugin :single_table_inheritance, :kind
68
68
  @ds._fetch = [{:kind=>''}, {:kind=>nil}]
69
- StiTest.all.collect{|x| x.class}.should == [StiTest, StiTest]
70
- called.should == false
69
+ StiTest.all.collect{|x| x.class}.must_equal [StiTest, StiTest]
70
+ called.must_equal false
71
71
  end
72
72
 
73
73
  it "should set the model class name when saving" do
74
74
  StiTest.new.save
75
75
  StiTestSub1.new.save
76
76
  StiTestSub2.new.save
77
- DB.sqls.should == ["INSERT INTO sti_tests (kind) VALUES ('StiTest')", "SELECT * FROM sti_tests WHERE (id = 10) LIMIT 1", "INSERT INTO sti_tests (kind) VALUES ('StiTestSub1')", "SELECT * FROM sti_tests WHERE ((sti_tests.kind IN ('StiTestSub1')) AND (id = 10)) LIMIT 1", "INSERT INTO sti_tests (kind) VALUES ('StiTestSub2')", "SELECT * FROM sti_tests WHERE ((sti_tests.kind IN ('StiTestSub2')) AND (id = 10)) LIMIT 1"]
77
+ DB.sqls.must_equal ["INSERT INTO sti_tests (kind) VALUES ('StiTest')", "SELECT * FROM sti_tests WHERE (id = 10) LIMIT 1", "INSERT INTO sti_tests (kind) VALUES ('StiTestSub1')", "SELECT * FROM sti_tests WHERE ((sti_tests.kind IN ('StiTestSub1')) AND (id = 10)) LIMIT 1", "INSERT INTO sti_tests (kind) VALUES ('StiTestSub2')", "SELECT * FROM sti_tests WHERE ((sti_tests.kind IN ('StiTestSub2')) AND (id = 10)) LIMIT 1"]
78
78
  end
79
79
 
80
80
  it "should destroy the model correctly" do
81
81
  StiTest.load(:id=>1).destroy
82
82
  StiTestSub1.load(:id=>1).destroy
83
83
  StiTestSub2.load(:id=>1).destroy
84
- DB.sqls.should == ["DELETE FROM sti_tests WHERE id = 1", "DELETE FROM sti_tests WHERE ((sti_tests.kind IN ('StiTestSub1')) AND (id = 1))", "DELETE FROM sti_tests WHERE ((sti_tests.kind IN ('StiTestSub2')) AND (id = 1))"]
84
+ DB.sqls.must_equal ["DELETE FROM sti_tests WHERE id = 1", "DELETE FROM sti_tests WHERE ((sti_tests.kind IN ('StiTestSub1')) AND (id = 1))", "DELETE FROM sti_tests WHERE ((sti_tests.kind IN ('StiTestSub2')) AND (id = 1))"]
85
85
  end
86
86
 
87
87
  it "should handle validations on the type column field" do
@@ -89,43 +89,43 @@ describe Sequel::Model, "single table inheritance plugin" do
89
89
  def o.validate
90
90
  errors.add(:kind, 'not present') unless kind
91
91
  end
92
- o.valid?.should == true
92
+ o.valid?.must_equal true
93
93
  end
94
94
 
95
95
  it "should set type column field even if validations are skipped" do
96
96
  StiTestSub1.new.save(:validate=>false)
97
- DB.sqls.should == ["INSERT INTO sti_tests (kind) VALUES ('StiTestSub1')", "SELECT * FROM sti_tests WHERE ((sti_tests.kind IN ('StiTestSub1')) AND (id = 10)) LIMIT 1"]
97
+ DB.sqls.must_equal ["INSERT INTO sti_tests (kind) VALUES ('StiTestSub1')", "SELECT * FROM sti_tests WHERE ((sti_tests.kind IN ('StiTestSub1')) AND (id = 10)) LIMIT 1"]
98
98
  end
99
99
 
100
100
  it "should override an existing value in the class name field" do
101
101
  StiTest.create(:kind=>'StiTestSub1')
102
- DB.sqls.should == ["INSERT INTO sti_tests (kind) VALUES ('StiTestSub1')", "SELECT * FROM sti_tests WHERE (id = 10) LIMIT 1"]
102
+ DB.sqls.must_equal ["INSERT INTO sti_tests (kind) VALUES ('StiTestSub1')", "SELECT * FROM sti_tests WHERE (id = 10) LIMIT 1"]
103
103
  end
104
104
 
105
105
  it "should handle type column with the same name as existing method names" do
106
106
  StiTest.plugin :single_table_inheritance, :type
107
107
  StiTest.columns :id, :type
108
108
  StiTest.create
109
- DB.sqls.should == ["INSERT INTO sti_tests (type) VALUES ('StiTest')", "SELECT * FROM sti_tests WHERE (id = 10) LIMIT 1"]
109
+ DB.sqls.must_equal ["INSERT INTO sti_tests (type) VALUES ('StiTest')", "SELECT * FROM sti_tests WHERE (id = 10) LIMIT 1"]
110
110
  end
111
111
 
112
112
  it "should add a filter to model datasets inside subclasses hook to only retreive objects with the matching key" do
113
- StiTest.dataset.sql.should == "SELECT * FROM sti_tests"
114
- StiTestSub1.dataset.sql.should == "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub1'))"
115
- StiTestSub2.dataset.sql.should == "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub2'))"
113
+ StiTest.dataset.sql.must_equal "SELECT * FROM sti_tests"
114
+ StiTestSub1.dataset.sql.must_equal "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub1'))"
115
+ StiTestSub2.dataset.sql.must_equal "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub2'))"
116
116
  end
117
117
 
118
118
  it "should add a correct filter for multiple levels of subclasses" do
119
119
  class ::StiTestSub1A < StiTestSub1; end
120
- StiTestSub1.dataset.sql.should == "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub1', 'StiTestSub1A'))"
121
- StiTestSub1A.dataset.sql.should == "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub1A'))"
120
+ StiTestSub1.dataset.sql.must_equal "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub1', 'StiTestSub1A'))"
121
+ StiTestSub1A.dataset.sql.must_equal "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub1A'))"
122
122
  class ::StiTestSub2A < StiTestSub2; end
123
- StiTestSub2.dataset.sql.should == "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub2', 'StiTestSub2A'))"
124
- StiTestSub2A.dataset.sql.should == "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub2A'))"
123
+ StiTestSub2.dataset.sql.must_equal "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub2', 'StiTestSub2A'))"
124
+ StiTestSub2A.dataset.sql.must_equal "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub2A'))"
125
125
  class ::StiTestSub1B < StiTestSub1A; end
126
- StiTestSub1.dataset.sql.should == "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub1', 'StiTestSub1A', 'StiTestSub1B'))"
127
- StiTestSub1A.dataset.sql.should == "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub1A', 'StiTestSub1B'))"
128
- StiTestSub1B.dataset.sql.should == "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub1B'))"
126
+ StiTestSub1.dataset.sql.must_equal "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub1', 'StiTestSub1A', 'StiTestSub1B'))"
127
+ StiTestSub1A.dataset.sql.must_equal "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub1A', 'StiTestSub1B'))"
128
+ StiTestSub1B.dataset.sql.must_equal "SELECT * FROM sti_tests WHERE (sti_tests.kind IN ('StiTestSub1B'))"
129
129
  end
130
130
 
131
131
  it "should work correctly with the :caching plugin" do
@@ -139,16 +139,16 @@ describe Sequel::Model, "single table inheritance plugin" do
139
139
  StiTest.plugin :caching, cache
140
140
  def StiTest.cache_key_prefix; "stitest" end
141
141
  c2 = Class.new StiTest
142
- c2.cache_key(:id).should == StiTest.cache_key(:id)
142
+ c2.cache_key(:id).must_equal StiTest.cache_key(:id)
143
143
 
144
144
  obj2 = c2.new
145
145
  obj2.values[:x] = 2
146
146
  obj2.save
147
147
  c2[obj2.id]
148
- c2.cache_get_pk(obj2.id).values.should == StiTest.cache_get_pk(obj2.id).values
148
+ c2.cache_get_pk(obj2.id).values.must_equal StiTest.cache_get_pk(obj2.id).values
149
149
  obj2.save
150
- c2.cache_get_pk(obj2.id).should == nil
151
- StiTest.cache_get_pk(obj2.id).should == nil
150
+ c2.cache_get_pk(obj2.id).must_equal nil
151
+ StiTest.cache_get_pk(obj2.id).must_equal nil
152
152
  end
153
153
 
154
154
  describe "with custom options" do
@@ -164,91 +164,91 @@ describe Sequel::Model, "single table inheritance plugin" do
164
164
  Object.send(:remove_const, :StiTest4)
165
165
  end
166
166
 
167
- specify "should have working row_proc if using set_dataset in subclass to remove columns" do
167
+ it "should have working row_proc if using set_dataset in subclass to remove columns" do
168
168
  StiTest2.plugin :single_table_inheritance, :kind
169
169
  class ::StiTest3 < ::StiTest2
170
170
  set_dataset(dataset.select(*(columns - [:blah])))
171
171
  end
172
172
  class ::StiTest4 < ::StiTest3; end
173
173
  StiTest3.dataset._fetch = {:id=>1, :kind=>'StiTest4'}
174
- StiTest3[1].should == StiTest4.load(:id=>1, :kind=>'StiTest4')
174
+ StiTest3[1].must_equal StiTest4.load(:id=>1, :kind=>'StiTest4')
175
175
  end
176
176
 
177
177
  it "should work with custom procs with strings" do
178
178
  StiTest2.plugin :single_table_inheritance, :kind, :model_map=>proc{|v| v == 1 ? 'StiTest3' : 'StiTest4'}, :key_map=>proc{|klass| klass.name == 'StiTest3' ? 1 : 2}
179
179
  class ::StiTest3 < ::StiTest2; end
180
180
  class ::StiTest4 < ::StiTest2; end
181
- StiTest2.dataset.row_proc.call(:kind=>0).should be_a_instance_of(StiTest4)
182
- StiTest2.dataset.row_proc.call(:kind=>1).should be_a_instance_of(StiTest3)
183
- StiTest2.dataset.row_proc.call(:kind=>2).should be_a_instance_of(StiTest4)
181
+ StiTest2.dataset.row_proc.call(:kind=>0).must_be_instance_of(StiTest4)
182
+ StiTest2.dataset.row_proc.call(:kind=>1).must_be_instance_of(StiTest3)
183
+ StiTest2.dataset.row_proc.call(:kind=>2).must_be_instance_of(StiTest4)
184
184
 
185
- StiTest2.create.kind.should == 2
186
- StiTest3.create.kind.should == 1
187
- StiTest4.create.kind.should == 2
185
+ StiTest2.create.kind.must_equal 2
186
+ StiTest3.create.kind.must_equal 1
187
+ StiTest4.create.kind.must_equal 2
188
188
  end
189
189
 
190
190
  it "should work with custom procs with symbols" do
191
191
  StiTest2.plugin :single_table_inheritance, :kind, :model_map=>proc{|v| v == 1 ? :StiTest3 : :StiTest4}, :key_map=>proc{|klass| klass.name == 'StiTest3' ? 1 : 2}
192
192
  class ::StiTest3 < ::StiTest2; end
193
193
  class ::StiTest4 < ::StiTest2; end
194
- StiTest2.dataset.row_proc.call(:kind=>0).should be_a_instance_of(StiTest4)
195
- StiTest2.dataset.row_proc.call(:kind=>1).should be_a_instance_of(StiTest3)
196
- StiTest2.dataset.row_proc.call(:kind=>2).should be_a_instance_of(StiTest4)
194
+ StiTest2.dataset.row_proc.call(:kind=>0).must_be_instance_of(StiTest4)
195
+ StiTest2.dataset.row_proc.call(:kind=>1).must_be_instance_of(StiTest3)
196
+ StiTest2.dataset.row_proc.call(:kind=>2).must_be_instance_of(StiTest4)
197
197
 
198
- StiTest2.create.kind.should == 2
199
- StiTest3.create.kind.should == 1
200
- StiTest4.create.kind.should == 2
198
+ StiTest2.create.kind.must_equal 2
199
+ StiTest3.create.kind.must_equal 1
200
+ StiTest4.create.kind.must_equal 2
201
201
  end
202
202
 
203
203
  it "should work with custom hashes" do
204
204
  StiTest2.plugin :single_table_inheritance, :kind, :model_map=>{0=>StiTest2, 1=>:StiTest3, 2=>'StiTest4'}, :key_map=>{StiTest2=>4, 'StiTest3'=>5, 'StiTest4'=>6}
205
205
  class ::StiTest3 < ::StiTest2; end
206
206
  class ::StiTest4 < ::StiTest2; end
207
- StiTest2.dataset.row_proc.call(:kind=>0).should be_a_instance_of(StiTest2)
208
- StiTest2.dataset.row_proc.call(:kind=>1).should be_a_instance_of(StiTest3)
209
- StiTest2.dataset.row_proc.call(:kind=>2).should be_a_instance_of(StiTest4)
210
- StiTest3.sti_model_map.should == StiTest2.sti_model_map
207
+ StiTest2.dataset.row_proc.call(:kind=>0).must_be_instance_of(StiTest2)
208
+ StiTest2.dataset.row_proc.call(:kind=>1).must_be_instance_of(StiTest3)
209
+ StiTest2.dataset.row_proc.call(:kind=>2).must_be_instance_of(StiTest4)
210
+ StiTest3.sti_model_map.must_equal StiTest2.sti_model_map
211
211
 
212
- StiTest2.create.kind.should == 4
213
- StiTest3.create.kind.should == 5
214
- StiTest4.create.kind.should == 6
212
+ StiTest2.create.kind.must_equal 4
213
+ StiTest3.create.kind.must_equal 5
214
+ StiTest4.create.kind.must_equal 6
215
215
 
216
216
  class ::StiTest5 < ::StiTest4; end
217
- StiTest5.create.kind.should == nil
217
+ StiTest5.create.kind.must_equal nil
218
218
  end
219
219
 
220
220
  it "should infer key_map from model_map if provided as a hash" do
221
221
  StiTest2.plugin :single_table_inheritance, :kind, :model_map=>{0=>StiTest2, 1=>'StiTest3', 2=>:StiTest4}
222
222
  class ::StiTest3 < ::StiTest2; end
223
223
  class ::StiTest4 < ::StiTest2; end
224
- StiTest2.dataset.row_proc.call(:kind=>0).should be_a_instance_of(StiTest2)
225
- StiTest2.dataset.row_proc.call(:kind=>1).should be_a_instance_of(StiTest3)
226
- StiTest2.dataset.row_proc.call(:kind=>2).should be_a_instance_of(StiTest4)
224
+ StiTest2.dataset.row_proc.call(:kind=>0).must_be_instance_of(StiTest2)
225
+ StiTest2.dataset.row_proc.call(:kind=>1).must_be_instance_of(StiTest3)
226
+ StiTest2.dataset.row_proc.call(:kind=>2).must_be_instance_of(StiTest4)
227
227
 
228
- StiTest2.create.kind.should == 0
229
- StiTest3.create.kind.should == 1
230
- StiTest4.create.kind.should == 2
228
+ StiTest2.create.kind.must_equal 0
229
+ StiTest3.create.kind.must_equal 1
230
+ StiTest4.create.kind.must_equal 2
231
231
  end
232
232
 
233
233
  it "should raise exceptions if a bad model value is used" do
234
234
  StiTest2.plugin :single_table_inheritance, :kind, :model_map=>{0=>1,1=>1.5, 2=>Date.today}
235
235
  class ::StiTest3 < ::StiTest2; end
236
236
  class ::StiTest4 < ::StiTest2; end
237
- proc{StiTest2.dataset.row_proc.call(:kind=>0)}.should raise_error(Sequel::Error)
238
- proc{StiTest2.dataset.row_proc.call(:kind=>1)}.should raise_error(Sequel::Error)
239
- proc{StiTest2.dataset.row_proc.call(:kind=>2)}.should raise_error(Sequel::Error)
237
+ proc{StiTest2.dataset.row_proc.call(:kind=>0)}.must_raise(Sequel::Error)
238
+ proc{StiTest2.dataset.row_proc.call(:kind=>1)}.must_raise(Sequel::Error)
239
+ proc{StiTest2.dataset.row_proc.call(:kind=>2)}.must_raise(Sequel::Error)
240
240
  end
241
241
 
242
242
  it "should work with non-bijective mappings" do
243
243
  StiTest2.plugin :single_table_inheritance, :kind, :model_map=>{0=>'StiTest3', 1=>'StiTest3', 2=>'StiTest4'}
244
244
  class ::StiTest3 < ::StiTest2; end
245
245
  class ::StiTest4 < ::StiTest2; end
246
- StiTest2.dataset.row_proc.call(:kind=>0).should be_a_instance_of(StiTest3)
247
- StiTest2.dataset.row_proc.call(:kind=>1).should be_a_instance_of(StiTest3)
248
- StiTest2.dataset.row_proc.call(:kind=>2).should be_a_instance_of(StiTest4)
246
+ StiTest2.dataset.row_proc.call(:kind=>0).must_be_instance_of(StiTest3)
247
+ StiTest2.dataset.row_proc.call(:kind=>1).must_be_instance_of(StiTest3)
248
+ StiTest2.dataset.row_proc.call(:kind=>2).must_be_instance_of(StiTest4)
249
249
 
250
- [0,1].should include(StiTest3.create.kind)
251
- StiTest4.create.kind.should == 2
250
+ [0,1].must_include(StiTest3.create.kind)
251
+ StiTest4.create.kind.must_equal 2
252
252
  end
253
253
 
254
254
  it "should work with non-bijective mappings and key map procs" do
@@ -257,9 +257,9 @@ describe Sequel::Model, "single table inheritance plugin" do
257
257
  class ::StiTest3 < ::StiTest2; end
258
258
  class ::StiTest4 < ::StiTest2; end
259
259
 
260
- StiTest2.dataset.sql.should == "SELECT * FROM sti_test2s"
261
- StiTest3.dataset.sql.should == "SELECT * FROM sti_test2s WHERE (sti_test2s.kind IN (0, 1))"
262
- StiTest4.dataset.sql.should == "SELECT * FROM sti_test2s WHERE (sti_test2s.kind IN (2))"
260
+ StiTest2.dataset.sql.must_equal "SELECT * FROM sti_test2s"
261
+ StiTest3.dataset.sql.must_equal "SELECT * FROM sti_test2s WHERE (sti_test2s.kind IN (0, 1))"
262
+ StiTest4.dataset.sql.must_equal "SELECT * FROM sti_test2s WHERE (sti_test2s.kind IN (2))"
263
263
  end
264
264
 
265
265
  it "should create correct sql with non-bijective mappings" do
@@ -267,9 +267,9 @@ describe Sequel::Model, "single table inheritance plugin" do
267
267
  class ::StiTest3 < ::StiTest2; end
268
268
  class ::StiTest4 < ::StiTest2; end
269
269
 
270
- StiTest2.dataset.sql.should == "SELECT * FROM sti_test2s"
270
+ StiTest2.dataset.sql.must_equal "SELECT * FROM sti_test2s"
271
271
  ["SELECT * FROM sti_test2s WHERE (sti_test2s.kind IN (0, 1))",
272
- "SELECT * FROM sti_test2s WHERE (sti_test2s.kind IN (1, 0))"].should include(StiTest3.dataset.sql)
272
+ "SELECT * FROM sti_test2s WHERE (sti_test2s.kind IN (1, 0))"].must_include(StiTest3.dataset.sql)
273
273
  end
274
274
 
275
275
  it "should destroy the model correctly" do
@@ -279,10 +279,10 @@ describe Sequel::Model, "single table inheritance plugin" do
279
279
  StiTest2.load(:id=>1).destroy
280
280
  StiTest3.load(:id=>1).destroy
281
281
  sqls = DB.sqls
282
- sqls.shift.should == "DELETE FROM sti_test2s WHERE id = 1"
282
+ sqls.shift.must_equal "DELETE FROM sti_test2s WHERE id = 1"
283
283
  ["DELETE FROM sti_test2s WHERE ((sti_test2s.kind IN ('sti3', 'sti3b')) AND (id = 1))",
284
- "DELETE FROM sti_test2s WHERE ((sti_test2s.kind IN ('sti3b', 'sti3')) AND (id = 1))"].should include(sqls.pop)
285
- sqls.should == []
284
+ "DELETE FROM sti_test2s WHERE ((sti_test2s.kind IN ('sti3b', 'sti3')) AND (id = 1))"].must_include(sqls.pop)
285
+ sqls.must_equal []
286
286
  end
287
287
 
288
288
  it "should honor a :key_chooser" do
@@ -290,8 +290,8 @@ describe Sequel::Model, "single table inheritance plugin" do
290
290
  class ::StiTest3 < ::StiTest2; end
291
291
  class ::StiTest4 < ::StiTest2; end
292
292
 
293
- StiTest3.create.kind.should == 'stitest3'
294
- StiTest4.create.kind.should == 'stitest4'
293
+ StiTest3.create.kind.must_equal 'stitest3'
294
+ StiTest4.create.kind.must_equal 'stitest4'
295
295
  end
296
296
  end
297
297
  end
@@ -7,11 +7,11 @@ describe "Sequel::Plugins::SkipCreateRefresh" do
7
7
  c.db.reset
8
8
  c.instance_dataset.meta_def(:insert){|*a| super(*a); 2}
9
9
  c.create(:x=>1)
10
- c.db.sqls.should == ['INSERT INTO a (x) VALUES (1)', 'SELECT * FROM a WHERE (id = 2) LIMIT 1']
10
+ c.db.sqls.must_equal ['INSERT INTO a (x) VALUES (1)', 'SELECT * FROM a WHERE (id = 2) LIMIT 1']
11
11
 
12
12
  c.plugin :skip_create_refresh
13
13
  c.db.reset
14
- c.create(:x=>3).values.should == {:id=>2, :x=>3}
15
- c.db.sqls.should == ['INSERT INTO a (x) VALUES (3)']
14
+ c.create(:x=>3).values.must_equal(:id=>2, :x=>3)
15
+ c.db.sqls.must_equal ['INSERT INTO a (x) VALUES (3)']
16
16
  end
17
17
  end
@@ -1,13 +1,5 @@
1
1
  require 'rubygems'
2
2
 
3
- if defined?(RSpec)
4
- begin
5
- require 'rspec/expectations'
6
- rescue LoadError
7
- nil
8
- end
9
- end
10
-
11
3
  if ENV['COVERAGE']
12
4
  require File.join(File.dirname(File.expand_path(__FILE__)), "../sequel_coverage")
13
5
  SimpleCov.sequel_coverage(:filter=>%r{lib/sequel/(extensions|plugins)/\w+\.rb\z})
@@ -37,27 +29,10 @@ def skip_warn(s)
37
29
  warn "Skipping test of #{s}" if ENV["SKIPPED_TEST_WARN"]
38
30
  end
39
31
 
40
- require File.join(File.dirname(File.expand_path(__FILE__)), "../rspec_helper.rb")
41
-
42
- RSPEC_EXAMPLE_GROUP.class_eval do
43
- if ENV['SEQUEL_DEPRECATION_WARNINGS']
44
- class << self
45
- alias qspecify specify
46
- end
47
- else
48
- def self.qspecify(*a, &block)
49
- specify(*a) do
50
- begin
51
- output = Sequel::Deprecation.output
52
- Sequel::Deprecation.output = false
53
- instance_exec(&block)
54
- ensure
55
- Sequel::Deprecation.output = output
56
- end
57
- end
58
- end
59
- end
60
- end
32
+ gem 'minitest'
33
+ require 'minitest/autorun'
34
+ require 'minitest/hooks/default'
35
+ require 'minitest/shared_description'
61
36
 
62
37
  Sequel.quote_identifiers = false
63
38
  Sequel.identifier_input_method = nil
@@ -5,20 +5,20 @@ describe "split_array_nil extension" do
5
5
  @ds = Sequel.mock[:table].extension(:split_array_nil)
6
6
  end
7
7
 
8
- specify "should split IN with nil in array into separate OR IS NULL clause" do
9
- @ds.filter(:a=>[1, nil]).sql.should == "SELECT * FROM table WHERE ((a IN (1)) OR (a IS NULL))"
8
+ it "should split IN with nil in array into separate OR IS NULL clause" do
9
+ @ds.filter(:a=>[1, nil]).sql.must_equal "SELECT * FROM table WHERE ((a IN (1)) OR (a IS NULL))"
10
10
  end
11
11
 
12
- specify "should split NOT IN with nil in array into separate AND IS NOT NULL clause" do
13
- @ds.exclude(:a=>[1, nil]).sql.should == "SELECT * FROM table WHERE ((a NOT IN (1)) AND (a IS NOT NULL))"
12
+ it "should split NOT IN with nil in array into separate AND IS NOT NULL clause" do
13
+ @ds.exclude(:a=>[1, nil]).sql.must_equal "SELECT * FROM table WHERE ((a NOT IN (1)) AND (a IS NOT NULL))"
14
14
  end
15
15
 
16
- specify "should not affect other IN/NOT in clauses" do
17
- @ds.filter(:a=>[1, 2]).sql.should == "SELECT * FROM table WHERE (a IN (1, 2))"
18
- @ds.exclude(:a=>[1, 2]).sql.should == "SELECT * FROM table WHERE (a NOT IN (1, 2))"
16
+ it "should not affect other IN/NOT in clauses" do
17
+ @ds.filter(:a=>[1, 2]).sql.must_equal "SELECT * FROM table WHERE (a IN (1, 2))"
18
+ @ds.exclude(:a=>[1, 2]).sql.must_equal "SELECT * FROM table WHERE (a NOT IN (1, 2))"
19
19
  end
20
20
 
21
- specify "should not affect other types of filters clauses" do
22
- @ds.filter(:a=>1).sql.should == "SELECT * FROM table WHERE (a = 1)"
21
+ it "should not affect other types of filters clauses" do
22
+ @ds.filter(:a=>1).sql.must_equal "SELECT * FROM table WHERE (a = 1)"
23
23
  end
24
24
  end
@@ -9,14 +9,14 @@ describe "Sequel::Plugins::SplitValues" do
9
9
  o = c.first
10
10
  c.db.reset
11
11
 
12
- o.should == c.load(:id=>1, :x=>2)
13
- o[:id].should == 1
14
- o[:x].should == 2
15
- o[:y].should == 3
16
- {c.load(:id=>1, :x=>2)=>4}[o].should == 4
17
- o.values.should == {:id=>1, :x=>2}
12
+ o.must_equal c.load(:id=>1, :x=>2)
13
+ o[:id].must_equal 1
14
+ o[:x].must_equal 2
15
+ o[:y].must_equal 3
16
+ {c.load(:id=>1, :x=>2)=>4}[o].must_equal 4
17
+ o.values.must_equal(:id=>1, :x=>2)
18
18
 
19
19
  o.save
20
- c.db.sqls.should == ["UPDATE a SET x = 2 WHERE (id = 1)"]
20
+ c.db.sqls.must_equal ["UPDATE a SET x = 2 WHERE (id = 1)"]
21
21
  end
22
22
  end
@@ -7,54 +7,54 @@ describe "Sequel sql_expr extension" do
7
7
  @ds = Sequel.mock.dataset
8
8
  end
9
9
 
10
- specify "Object#sql_expr should wrap the object in a GenericComplexExpression" do
10
+ it "Object#sql_expr should wrap the object in a GenericComplexExpression" do
11
11
  o = Object.new
12
12
  def o.sql_literal(ds) 'foo' end
13
13
  s = o.sql_expr
14
- @ds.literal(s).should == "foo"
15
- @ds.literal(s+1).should == "(foo + 1)"
16
- @ds.literal(s & true).should == "(foo AND 't')"
17
- @ds.literal(s < 1).should == "(foo < 1)"
18
- @ds.literal(s.sql_subscript(1)).should == "foo[1]"
19
- @ds.literal(s.like('a')).should == "(foo LIKE 'a' ESCAPE '\\')"
20
- @ds.literal(s.as(:a)).should == "foo AS a"
21
- @ds.literal(s.cast(Integer)).should == "CAST(foo AS integer)"
22
- @ds.literal(s.desc).should == "foo DESC"
23
- @ds.literal(s.sql_string + '1').should == "(foo || '1')"
24
- end
25
-
26
- specify "Numeric#sql_expr should wrap the object in a NumericExpression" do
14
+ @ds.literal(s).must_equal "foo"
15
+ @ds.literal(s+1).must_equal "(foo + 1)"
16
+ @ds.literal(s & true).must_equal "(foo AND 't')"
17
+ @ds.literal(s < 1).must_equal "(foo < 1)"
18
+ @ds.literal(s.sql_subscript(1)).must_equal "foo[1]"
19
+ @ds.literal(s.like('a')).must_equal "(foo LIKE 'a' ESCAPE '\\')"
20
+ @ds.literal(s.as(:a)).must_equal "foo AS a"
21
+ @ds.literal(s.cast(Integer)).must_equal "CAST(foo AS integer)"
22
+ @ds.literal(s.desc).must_equal "foo DESC"
23
+ @ds.literal(s.sql_string + '1').must_equal "(foo || '1')"
24
+ end
25
+
26
+ it "Numeric#sql_expr should wrap the object in a NumericExpression" do
27
27
  [1, 2.0, 2^70, BigDecimal.new('1.0')].each do |o|
28
- @ds.literal(o.sql_expr).should == @ds.literal(o)
29
- @ds.literal(o.sql_expr + 1).should == "(#{@ds.literal(o)} + 1)"
28
+ @ds.literal(o.sql_expr).must_equal @ds.literal(o)
29
+ @ds.literal(o.sql_expr + 1).must_equal "(#{@ds.literal(o)} + 1)"
30
30
  end
31
31
  end
32
32
 
33
- specify "String#sql_expr should wrap the object in a StringExpression" do
34
- @ds.literal("".sql_expr).should == "''"
35
- @ds.literal("".sql_expr + :a).should == "('' || a)"
33
+ it "String#sql_expr should wrap the object in a StringExpression" do
34
+ @ds.literal("".sql_expr).must_equal "''"
35
+ @ds.literal("".sql_expr + :a).must_equal "('' || a)"
36
36
  end
37
37
 
38
- specify "NilClass, TrueClass, and FalseClass#sql_expr should wrap the object in a BooleanExpression" do
38
+ it "NilClass, TrueClass, and FalseClass#sql_expr should wrap the object in a BooleanExpression" do
39
39
  [nil, true, false].each do |o|
40
- @ds.literal(o.sql_expr).should == @ds.literal(o)
41
- @ds.literal(o.sql_expr & :a).should == "(#{@ds.literal(o)} AND a)"
40
+ @ds.literal(o.sql_expr).must_equal @ds.literal(o)
41
+ @ds.literal(o.sql_expr & :a).must_equal "(#{@ds.literal(o)} AND a)"
42
42
  end
43
43
  end
44
44
 
45
- specify "Proc#sql_expr should should treat the object as a virtual row block" do
46
- @ds.literal(proc{a}.sql_expr).should == "a"
47
- @ds.literal(proc{a__b}.sql_expr).should == "a.b"
48
- @ds.literal(proc{a(b)}.sql_expr).should == "a(b)"
45
+ it "Proc#sql_expr should should treat the object as a virtual row block" do
46
+ @ds.literal(proc{a}.sql_expr).must_equal "a"
47
+ @ds.literal(proc{a__b}.sql_expr).must_equal "a.b"
48
+ @ds.literal(proc{a(b)}.sql_expr).must_equal "a(b)"
49
49
  end
50
50
 
51
- specify "Proc#sql_expr should should wrap the object in a GenericComplexExpression if the object is not already an expression" do
52
- @ds.literal(proc{1}.sql_expr).should == "1"
53
- @ds.literal(proc{1}.sql_expr + 2).should == "(1 + 2)"
51
+ it "Proc#sql_expr should should wrap the object in a GenericComplexExpression if the object is not already an expression" do
52
+ @ds.literal(proc{1}.sql_expr).must_equal "1"
53
+ @ds.literal(proc{1}.sql_expr + 2).must_equal "(1 + 2)"
54
54
  end
55
55
 
56
- specify "Proc#sql_expr should should convert a hash or array of two element arrays to a BooleanExpression" do
57
- @ds.literal(proc{{a=>b}}.sql_expr).should == "(a = b)"
58
- @ds.literal(proc{[[a, b]]}.sql_expr & :a).should == "((a = b) AND a)"
56
+ it "Proc#sql_expr should should convert a hash or array of two element arrays to a BooleanExpression" do
57
+ @ds.literal(proc{{a=>b}}.sql_expr).must_equal "(a = b)"
58
+ @ds.literal(proc{[[a, b]]}.sql_expr & :a).must_equal "((a = b) AND a)"
59
59
  end
60
60
  end