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
@@ -15,12 +15,12 @@ describe "Sequel::Plugins::EagerEach" do
15
15
  ds._fetch = [{:id=>1, :parent_id=>nil}, {:id=>2, :parent_id=>nil}]
16
16
  @c.dataset._fetch = [{:id=>3, :parent_id=>1}, {:id=>4, :parent_id=>1}, {:id=>5, :parent_id=>2}, {:id=>6, :parent_id=>2}]
17
17
  ds.each{|c| a << c}
18
- a.should == [@c.load(:id=>1, :parent_id=>nil), @c.load(:id=>2, :parent_id=>nil)]
19
- a.map{|c| c.associations[:children]}.should == [[@c.load(:id=>3, :parent_id=>1), @c.load(:id=>4, :parent_id=>1)], [@c.load(:id=>5, :parent_id=>2), @c.load(:id=>6, :parent_id=>2)]]
18
+ a.must_equal [@c.load(:id=>1, :parent_id=>nil), @c.load(:id=>2, :parent_id=>nil)]
19
+ a.map{|c| c.associations[:children]}.must_equal [[@c.load(:id=>3, :parent_id=>1), @c.load(:id=>4, :parent_id=>1)], [@c.load(:id=>5, :parent_id=>2), @c.load(:id=>6, :parent_id=>2)]]
20
20
  sqls = @c.db.sqls
21
- sqls.shift.should == 'SELECT * FROM items'
21
+ sqls.shift.must_equal 'SELECT * FROM items'
22
22
  ['SELECT * FROM items WHERE (items.parent_id IN (1, 2))',
23
- 'SELECT * FROM items WHERE (items.parent_id IN (2, 1))'].should include(sqls.pop)
23
+ 'SELECT * FROM items WHERE (items.parent_id IN (2, 1))'].must_include(sqls.pop)
24
24
  end
25
25
 
26
26
  it "should make #each on an eager_graph dataset do eager loading" do
@@ -29,14 +29,14 @@ describe "Sequel::Plugins::EagerEach" do
29
29
  ds._fetch = []
30
30
  ds._fetch = [{:id=>1, :parent_id=>nil, :children_id=>3, :children_parent_id=>1}, {:id=>1, :parent_id=>nil, :children_id=>4, :children_parent_id=>1}, {:id=>2, :parent_id=>nil, :children_id=>5, :children_parent_id=>2}, {:id=>2, :parent_id=>nil, :children_id=>6, :children_parent_id=>2}]
31
31
  ds.each{|c| a << c}
32
- a.should == [@c.load(:id=>1, :parent_id=>nil), @c.load(:id=>2, :parent_id=>nil)]
33
- a.map{|c| c.associations[:children]}.should == [[@c.load(:id=>3, :parent_id=>1), @c.load(:id=>4, :parent_id=>1)], [@c.load(:id=>5, :parent_id=>2), @c.load(:id=>6, :parent_id=>2)]]
34
- @c.db.sqls.should == ['SELECT items.id, items.parent_id, children.id AS children_id, children.parent_id AS children_parent_id FROM items LEFT OUTER JOIN items AS children ON (children.parent_id = items.id)']
32
+ a.must_equal [@c.load(:id=>1, :parent_id=>nil), @c.load(:id=>2, :parent_id=>nil)]
33
+ a.map{|c| c.associations[:children]}.must_equal [[@c.load(:id=>3, :parent_id=>1), @c.load(:id=>4, :parent_id=>1)], [@c.load(:id=>5, :parent_id=>2), @c.load(:id=>6, :parent_id=>2)]]
34
+ @c.db.sqls.must_equal ['SELECT items.id, items.parent_id, children.id AS children_id, children.parent_id AS children_parent_id FROM items LEFT OUTER JOIN items AS children ON (children.parent_id = items.id)']
35
35
  end
36
36
 
37
37
  it "should not attempt to eager load when getting the columns" do
38
38
  ds = @c.eager(:children)
39
39
  def ds.all; raise; end
40
- proc{ds.columns!}.should_not raise_error
40
+ ds.columns!
41
41
  end
42
42
  end
@@ -5,20 +5,20 @@ describe "filter_having extension" do
5
5
  @dataset = Sequel.mock[:test].extension(:empty_array_ignore_nulls)
6
6
  end
7
7
 
8
- specify "should handle all types of IN/NOT IN queries with empty arrays" do
9
- @dataset.filter(:id => []).sql.should == "SELECT * FROM test WHERE (1 = 0)"
10
- @dataset.filter([:id1, :id2] => []).sql.should == "SELECT * FROM test WHERE (1 = 0)"
11
- @dataset.exclude(:id => []).sql.should == "SELECT * FROM test WHERE (1 = 1)"
12
- @dataset.exclude([:id1, :id2] => []).sql.should == "SELECT * FROM test WHERE (1 = 1)"
8
+ it "should handle all types of IN/NOT IN queries with empty arrays" do
9
+ @dataset.filter(:id => []).sql.must_equal "SELECT * FROM test WHERE (1 = 0)"
10
+ @dataset.filter([:id1, :id2] => []).sql.must_equal "SELECT * FROM test WHERE (1 = 0)"
11
+ @dataset.exclude(:id => []).sql.must_equal "SELECT * FROM test WHERE (1 = 1)"
12
+ @dataset.exclude([:id1, :id2] => []).sql.must_equal "SELECT * FROM test WHERE (1 = 1)"
13
13
  end
14
14
 
15
- specify "should handle IN/NOT IN queries with multiple columns and an empty dataset where the database doesn't support it" do
15
+ it "should handle IN/NOT IN queries with multiple columns and an empty dataset where the database doesn't support it" do
16
16
  @dataset.meta_def(:supports_multiple_column_in?){false}
17
17
  db = Sequel.mock
18
18
  d1 = db[:test].select(:id1, :id2).filter(:region=>'Asia').columns(:id1, :id2)
19
- @dataset.filter([:id1, :id2] => d1).sql.should == "SELECT * FROM test WHERE (1 = 0)"
20
- db.sqls.should == ["SELECT id1, id2 FROM test WHERE (region = 'Asia')"]
21
- @dataset.exclude([:id1, :id2] => d1).sql.should == "SELECT * FROM test WHERE (1 = 1)"
22
- db.sqls.should == ["SELECT id1, id2 FROM test WHERE (region = 'Asia')"]
19
+ @dataset.filter([:id1, :id2] => d1).sql.must_equal "SELECT * FROM test WHERE (1 = 0)"
20
+ db.sqls.must_equal ["SELECT id1, id2 FROM test WHERE (region = 'Asia')"]
21
+ @dataset.exclude([:id1, :id2] => d1).sql.must_equal "SELECT * FROM test WHERE (1 = 1)"
22
+ db.sqls.must_equal ["SELECT id1, id2 FROM test WHERE (region = 'Asia')"]
23
23
  end
24
24
  end
@@ -11,8 +11,8 @@ describe "Sequel::Plugins::ErrorSplitter" do
11
11
  end
12
12
 
13
13
  it "should split errors for multiple columns and assign them to each column" do
14
- @m.valid?.should == false
15
- @m.errors.should == {:a=>['is bad'], :b=>['is bad']}
14
+ @m.valid?.must_equal false
15
+ @m.errors.must_equal(:a=>['is bad'], :b=>['is bad'])
16
16
  end
17
17
  end
18
18
 
@@ -5,16 +5,16 @@ describe "error_sql extension" do
5
5
  @db = Sequel.mock(:fetch=>proc{|sql| @db.log_yield(sql){raise StandardError}}).extension(:error_sql)
6
6
  end
7
7
 
8
- specify "should have Sequel::DatabaseError#sql give the SQL causing the error" do
8
+ it "should have Sequel::DatabaseError#sql give the SQL causing the error" do
9
9
  @db["SELECT"].all rescue (e = $!)
10
- e.sql.should == "SELECT"
10
+ e.sql.must_equal "SELECT"
11
11
  end
12
12
 
13
- specify "should have Sequel::DatabaseError#sql give the SQL causing the error when using a logger" do
13
+ it "should have Sequel::DatabaseError#sql give the SQL causing the error when using a logger" do
14
14
  l = Object.new
15
15
  def l.method_missing(*) end
16
16
  @db.loggers = [l]
17
17
  @db["SELECT"].all rescue (e = $!)
18
- e.sql.should == "SELECT"
18
+ e.sql.must_equal "SELECT"
19
19
  end
20
20
  end
@@ -9,7 +9,7 @@ describe "eval_inspect extension" do
9
9
  @ds.meta_def(:literal_blob_append){|sql, s| sql << "X'#{s}'"}
10
10
  end
11
11
 
12
- specify "should make eval(obj.inspect) == obj for all Sequel::SQL::Expression subclasses" do
12
+ it "should make eval(obj.inspect) == obj for all Sequel::SQL::Expression subclasses" do
13
13
  [
14
14
  # Objects with components where eval(inspect) == self
15
15
  Sequel::SQL::AliasedExpression.new(:b, :a),
@@ -66,8 +66,8 @@ describe "eval_inspect extension" do
66
66
  Sequel::SQL::AliasedExpression.new(Sequel::CURRENT_TIMESTAMP, :a),
67
67
  ].each do |o|
68
68
  v = eval(o.inspect)
69
- v.should == o
70
- @ds.literal(v).should == @ds.literal(o)
69
+ v.must_equal o
70
+ @ds.literal(v).must_equal @ds.literal(o)
71
71
  end
72
72
  end
73
73
  end
@@ -7,34 +7,34 @@ describe "filter_having extension" do
7
7
  end
8
8
 
9
9
  it "should make filter operate on HAVING clause if dataset has a HAVING clause" do
10
- @dsh.filter(:b).sql.should == 'SELECT * FROM t HAVING (a AND b)'
10
+ @dsh.filter(:b).sql.must_equal 'SELECT * FROM t HAVING (a AND b)'
11
11
  end
12
12
 
13
13
  it "should make filter operate on WHERE clause if dataset does not have a HAVING clause" do
14
- @ds.filter(:b).sql.should == 'SELECT * FROM t WHERE b'
14
+ @ds.filter(:b).sql.must_equal 'SELECT * FROM t WHERE b'
15
15
  end
16
16
 
17
17
  it "should make and operate on HAVING clause if dataset has a HAVING clause" do
18
- @dsh.and(:b).sql.should == 'SELECT * FROM t HAVING (a AND b)'
18
+ @dsh.and(:b).sql.must_equal 'SELECT * FROM t HAVING (a AND b)'
19
19
  end
20
20
 
21
21
  it "should make and operate on WHERE clause if dataset does not have a HAVING clause" do
22
- @ds.where(:a).and(:b).sql.should == 'SELECT * FROM t WHERE (a AND b)'
22
+ @ds.where(:a).and(:b).sql.must_equal 'SELECT * FROM t WHERE (a AND b)'
23
23
  end
24
24
 
25
25
  it "should make or operate on HAVING clause if dataset has a HAVING clause" do
26
- @dsh.or(:b).sql.should == 'SELECT * FROM t HAVING (a OR b)'
26
+ @dsh.or(:b).sql.must_equal 'SELECT * FROM t HAVING (a OR b)'
27
27
  end
28
28
 
29
29
  it "should make or operate on WHERE clause if dataset does not have a HAVING clause" do
30
- @ds.where(:a).or(:b).sql.should == 'SELECT * FROM t WHERE (a OR b)'
30
+ @ds.where(:a).or(:b).sql.must_equal 'SELECT * FROM t WHERE (a OR b)'
31
31
  end
32
32
 
33
33
  it "should make exclude operate on HAVING clause if dataset has a HAVING clause" do
34
- @dsh.exclude(:b).sql.should == 'SELECT * FROM t HAVING (a AND NOT b)'
34
+ @dsh.exclude(:b).sql.must_equal 'SELECT * FROM t HAVING (a AND NOT b)'
35
35
  end
36
36
 
37
37
  it "should make exclude operate on WHERE clause if dataset does not have a HAVING clause" do
38
- @ds.exclude(:b).sql.should == 'SELECT * FROM t WHERE NOT b'
38
+ @ds.exclude(:b).sql.must_equal 'SELECT * FROM t WHERE NOT b'
39
39
  end
40
40
  end
@@ -9,79 +9,79 @@ describe "force_encoding plugin" do
9
9
  @e1 = Encoding.find('UTF-8')
10
10
  end
11
11
 
12
- specify "should force encoding to given encoding on load" do
12
+ it "should force encoding to given encoding on load" do
13
13
  s = 'blah'
14
14
  s.force_encoding('US-ASCII')
15
15
  o = @c.load(:id=>1, :x=>s)
16
- o.x.should == 'blah'
17
- o.x.encoding.should == @e1
16
+ o.x.must_equal 'blah'
17
+ o.x.encoding.must_equal @e1
18
18
  end
19
19
 
20
- specify "should force encoding to given encoding when setting column values" do
20
+ it "should force encoding to given encoding when setting column values" do
21
21
  s = 'blah'
22
22
  s.force_encoding('US-ASCII')
23
23
  o = @c.new(:x=>s)
24
- o.x.should == 'blah'
25
- o.x.encoding.should == @e1
24
+ o.x.must_equal 'blah'
25
+ o.x.encoding.must_equal @e1
26
26
  end
27
27
 
28
- specify "should work correctly when given a frozen string" do
28
+ it "should work correctly when given a frozen string" do
29
29
  s = 'blah'
30
30
  s.force_encoding('US-ASCII')
31
31
  s.freeze
32
32
  o = @c.new(:x=>s)
33
- o.x.should == 'blah'
34
- o.x.encoding.should == @e1
33
+ o.x.must_equal 'blah'
34
+ o.x.encoding.must_equal @e1
35
35
  end
36
36
 
37
- specify "should have a forced_encoding class accessor" do
37
+ it "should have a forced_encoding class accessor" do
38
38
  s = 'blah'
39
39
  s.force_encoding('US-ASCII')
40
40
  @c.forced_encoding = 'Windows-1258'
41
41
  o = @c.load(:id=>1, :x=>s)
42
- o.x.should == 'blah'
43
- o.x.encoding.should == Encoding.find('Windows-1258')
42
+ o.x.must_equal 'blah'
43
+ o.x.encoding.must_equal Encoding.find('Windows-1258')
44
44
  end
45
45
 
46
- specify "should not force encoding if forced_encoding is nil" do
46
+ it "should not force encoding if forced_encoding is nil" do
47
47
  s = 'blah'
48
48
  s.force_encoding('US-ASCII')
49
49
  @c.forced_encoding = nil
50
50
  o = @c.load(:id=>1, :x=>s)
51
- o.x.should == 'blah'
52
- o.x.encoding.should == Encoding.find('US-ASCII')
51
+ o.x.must_equal 'blah'
52
+ o.x.encoding.must_equal Encoding.find('US-ASCII')
53
53
  end
54
54
 
55
- specify "should work correctly when subclassing" do
55
+ it "should work correctly when subclassing" do
56
56
  c = Class.new(@c)
57
57
  s = 'blah'
58
58
  s.force_encoding('US-ASCII')
59
59
  o = c.load(:id=>1, :x=>s)
60
- o.x.should == 'blah'
61
- o.x.encoding.should == @e1
60
+ o.x.must_equal 'blah'
61
+ o.x.encoding.must_equal @e1
62
62
 
63
63
  c.plugin :force_encoding, 'UTF-16LE'
64
64
  s = ''
65
65
  s.force_encoding('US-ASCII')
66
66
  o = c.load(:id=>1, :x=>s)
67
- o.x.should == ''
68
- o.x.encoding.should == Encoding.find('UTF-16LE')
67
+ o.x.must_equal ''
68
+ o.x.encoding.must_equal Encoding.find('UTF-16LE')
69
69
 
70
70
  @c.plugin :force_encoding, 'UTF-32LE'
71
71
  s = ''
72
72
  s.force_encoding('US-ASCII')
73
73
  o = @c.load(:id=>1, :x=>s)
74
- o.x.should == ''
75
- o.x.encoding.should == Encoding.find('UTF-32LE')
74
+ o.x.must_equal ''
75
+ o.x.encoding.must_equal Encoding.find('UTF-32LE')
76
76
 
77
77
  s = ''
78
78
  s.force_encoding('US-ASCII')
79
79
  o = c.load(:id=>1, :x=>s)
80
- o.x.should == ''
81
- o.x.encoding.should == Encoding.find('UTF-16LE')
80
+ o.x.must_equal ''
81
+ o.x.encoding.must_equal Encoding.find('UTF-16LE')
82
82
  end
83
83
 
84
- specify "should work when saving new model instances" do
84
+ it "should work when saving new model instances" do
85
85
  o = @c.new
86
86
  ds = DB[:a]
87
87
  def ds.first
@@ -91,11 +91,11 @@ describe "force_encoding plugin" do
91
91
  end
92
92
  @c.dataset = ds
93
93
  o.save
94
- o.x.should == 'blah'
95
- o.x.encoding.should == @e1
94
+ o.x.must_equal 'blah'
95
+ o.x.encoding.must_equal @e1
96
96
  end
97
97
 
98
- specify "should work when refreshing model instances" do
98
+ it "should work when refreshing model instances" do
99
99
  o = @c.load(:id=>1, :x=>'as')
100
100
  ds = DB[:a]
101
101
  def ds.first
@@ -105,8 +105,8 @@ describe "force_encoding plugin" do
105
105
  end
106
106
  @c.dataset = ds
107
107
  o.refresh
108
- o.x.should == 'blah'
109
- o.x.encoding.should == @e1
108
+ o.x.must_equal 'blah'
109
+ o.x.encoding.must_equal @e1
110
110
  end
111
111
  end
112
112
  else
@@ -6,16 +6,16 @@ describe "from_block extension" do
6
6
  @db.extension(:from_block)
7
7
  end
8
8
 
9
- specify "should make Database#from blocks apply to FROM" do
10
- @db.from{f}.sql.should == 'SELECT * FROM f'
11
- @db.from{[f, g(f)]}.sql.should == 'SELECT * FROM f, g(f)'
9
+ it "should make Database#from blocks apply to FROM" do
10
+ @db.from{f}.sql.must_equal 'SELECT * FROM f'
11
+ @db.from{[f, g(f)]}.sql.must_equal 'SELECT * FROM f, g(f)'
12
12
  end
13
13
 
14
- specify "should handle from blocks with method arguments" do
15
- @db.from(:f){g(f)}.sql.should == 'SELECT * FROM f, g(f)'
14
+ it "should handle from blocks with method arguments" do
15
+ @db.from(:f){g(f)}.sql.must_equal 'SELECT * FROM f, g(f)'
16
16
  end
17
17
 
18
- specify "should handle from without block" do
19
- @db.from(:f).sql.should == 'SELECT * FROM f'
18
+ it "should handle from without block" do
19
+ @db.from(:f).sql.must_equal 'SELECT * FROM f'
20
20
  end
21
21
  end
@@ -22,23 +22,23 @@ describe Sequel::Dataset, " graphing" do
22
22
  it "#graph_each should handle graph using currently selected columns as the basis for the selected columns in a new graph" do
23
23
  ds = @ds1.select(:id).graph(@ds2, :x=>:id)
24
24
  ds._fetch = {:id=>1, :lines_id=>2, :x=>3, :y=>4, :graph_id=>5}
25
- ds.all.should == [{:points=>{:id=>1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
25
+ ds.all.must_equal [{:points=>{:id=>1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
26
26
 
27
27
  ds = @ds1.select(:id, :x).graph(@ds2, :x=>:id)
28
28
  ds._fetch = {:id=>1, :x=>-1, :lines_id=>2, :lines_x=>3, :y=>4, :graph_id=>5}
29
- ds.all.should == [{:points=>{:id=>1, :x=>-1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
29
+ ds.all.must_equal [{:points=>{:id=>1, :x=>-1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
30
30
 
31
31
  ds = @ds1.select(Sequel.identifier(:id), Sequel.qualify(:points, :x)).graph(@ds2, :x=>:id)
32
32
  ds._fetch = {:id=>1, :x=>-1, :lines_id=>2, :lines_x=>3, :y=>4, :graph_id=>5}
33
- ds.all.should == [{:points=>{:id=>1, :x=>-1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
33
+ ds.all.must_equal [{:points=>{:id=>1, :x=>-1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
34
34
 
35
35
  ds = @ds1.select(Sequel.identifier(:id).qualify(:points), Sequel.identifier(:x).as(:y)).graph(@ds2, :x=>:id)
36
36
  ds._fetch = {:id=>1, :y=>-1, :lines_id=>2, :x=>3, :lines_y=>4, :graph_id=>5}
37
- ds.all.should == [{:points=>{:id=>1, :y=>-1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
37
+ ds.all.must_equal [{:points=>{:id=>1, :y=>-1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
38
38
 
39
39
  ds = @ds1.select(:id, Sequel.identifier(:x).qualify(Sequel.identifier(:points)).as(Sequel.identifier(:y))).graph(@ds2, :x=>:id)
40
40
  ds._fetch = {:id=>1, :y=>-1, :lines_id=>2, :x=>3, :lines_y=>4, :graph_id=>5}
41
- ds.all.should == [{:points=>{:id=>1, :y=>-1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
41
+ ds.all.must_equal [{:points=>{:id=>1, :y=>-1}, :lines=>{:id=>2, :x=>3, :y=>4, :graph_id=>5}}]
42
42
  end
43
43
 
44
44
  it "#graph_each should split the result set into component tables" do
@@ -46,9 +46,9 @@ describe Sequel::Dataset, " graphing" do
46
46
  [{:id=>1,:x=>2,:y=>3,:lines_id=>4,:lines_x=>5,:lines_y=>6,:graph_id=>7, :graphs_id=>8, :name=>9, :graphs_x=>10, :graphs_y=>11, :graphs_lines_x=>12}],
47
47
  [{:id=>1,:x=>2,:y=>3,:lines_id=>4,:lines_x=>5,:lines_y=>6,:graph_id=>7, :graph_id_0=>8, :graph_x=>9, :graph_y=>10, :graph_graph_id=>11}]]
48
48
 
49
- @ds1.graph(@ds2, :x=>:id).all.should == [{:points=>{:id=>1, :x=>2, :y=>3}, :lines=>{:id=>4, :x=>5, :y=>6, :graph_id=>7}}]
50
- @ds1.graph(@ds2, :x=>:id).graph(@ds3, :id=>:graph_id).all.should == [{:points=>{:id=>1, :x=>2, :y=>3}, :lines=>{:id=>4, :x=>5, :y=>6, :graph_id=>7}, :graphs=>{:id=>8, :name=>9, :x=>10, :y=>11, :lines_x=>12}}]
51
- @ds1.graph(@ds2, :x=>:id).graph(@ds2, {:y=>:points__id}, :table_alias=>:graph).all.should == [{:points=>{:id=>1, :x=>2, :y=>3}, :lines=>{:id=>4, :x=>5, :y=>6, :graph_id=>7}, :graph=>{:id=>8, :x=>9, :y=>10, :graph_id=>11}}]
49
+ @ds1.graph(@ds2, :x=>:id).all.must_equal [{:points=>{:id=>1, :x=>2, :y=>3}, :lines=>{:id=>4, :x=>5, :y=>6, :graph_id=>7}}]
50
+ @ds1.graph(@ds2, :x=>:id).graph(@ds3, :id=>:graph_id).all.must_equal [{:points=>{:id=>1, :x=>2, :y=>3}, :lines=>{:id=>4, :x=>5, :y=>6, :graph_id=>7}, :graphs=>{:id=>8, :name=>9, :x=>10, :y=>11, :lines_x=>12}}]
51
+ @ds1.graph(@ds2, :x=>:id).graph(@ds2, {:y=>:points__id}, :table_alias=>:graph).all.must_equal [{:points=>{:id=>1, :x=>2, :y=>3}, :lines=>{:id=>4, :x=>5, :y=>6, :graph_id=>7}, :graph=>{:id=>8, :x=>9, :y=>10, :graph_id=>11}}]
52
52
  end
53
53
 
54
54
  it "#graph_each should give a nil value instead of a hash when all values for a table are nil" do
@@ -58,8 +58,8 @@ describe Sequel::Dataset, " graphing" do
58
58
  {:id=>3,:x=>5,:y=>6,:lines_id=>4,:lines_x=>5,:lines_y=>6,:graph_id=>7, :graphs_id=>7, :name=>8, :graphs_x=>9, :graphs_y=>10, :graphs_lines_x=>11},
59
59
  {:id=>3,:x=>5,:y=>6,:lines_id=>7,:lines_x=>5,:lines_y=>8,:graph_id=>9, :graphs_id=>9, :name=>10, :graphs_x=>10, :graphs_y=>11, :graphs_lines_x=>12}]]
60
60
 
61
- @ds1.graph(@ds2, :x=>:id).all.should == [{:points=>{:id=>1, :x=>2, :y=>3}, :lines=>nil}]
62
- @ds1.graph(@ds2, :x=>:id).graph(@ds3, :id=>:graph_id).all.should == [{:points=>{:id=>1, :x=>2, :y=>3}, :lines=>{:id=>4, :x=>5, :y=>6, :graph_id=>7}, :graphs=>nil},
61
+ @ds1.graph(@ds2, :x=>:id).all.must_equal [{:points=>{:id=>1, :x=>2, :y=>3}, :lines=>nil}]
62
+ @ds1.graph(@ds2, :x=>:id).graph(@ds3, :id=>:graph_id).all.must_equal [{:points=>{:id=>1, :x=>2, :y=>3}, :lines=>{:id=>4, :x=>5, :y=>6, :graph_id=>7}, :graphs=>nil},
63
63
  {:points=>{:id=>2, :x=>4, :y=>5}, :lines=>nil, :graphs=>nil},
64
64
  {:points=>{:id=>3, :x=>5, :y=>6}, :lines=>{:id=>4, :x=>5, :y=>6, :graph_id=>7}, :graphs=>{:id=>7, :name=>8, :x=>9, :y=>10, :lines_x=>11}},
65
65
  {:points=>{:id=>3, :x=>5, :y=>6}, :lines=>{:id=>7, :x=>5, :y=>8, :graph_id=>9}, :graphs=>{:id=>9, :name=>10, :x=>10, :y=>11, :lines_x=>12}}]
@@ -67,43 +67,43 @@ describe Sequel::Dataset, " graphing" do
67
67
 
68
68
  it "#graph_each should not give a nil value instead of a hash when any value for a table is false" do
69
69
  @db.fetch = {:id=>1,:x=>2,:y=>3,:lines_id=>nil,:lines_x=>false,:lines_y=>nil,:graph_id=>nil}
70
- @ds1.graph(@ds2, :x=>:id).all.should == [{:points=>{:id=>1, :x=>2, :y=>3}, :lines=>{:id=>nil, :x=>false, :y=>nil, :graph_id=>nil}}]
70
+ @ds1.graph(@ds2, :x=>:id).all.must_equal [{:points=>{:id=>1, :x=>2, :y=>3}, :lines=>{:id=>nil, :x=>false, :y=>nil, :graph_id=>nil}}]
71
71
  end
72
72
 
73
73
  it "#graph_each should not included tables graphed with the :select => false option in the result set" do
74
74
  @db.fetch = {:id=>1,:x=>2,:y=>3,:graphs_id=>8, :name=>9, :graphs_x=>10, :graphs_y=>11, :lines_x=>12}
75
- @ds1.graph(:lines, {:x=>:id}, :select=>false).graph(:graphs, :id=>:graph_id).all.should == [{:points=>{:id=>1, :x=>2, :y=>3}, :graphs=>{:id=>8, :name=>9, :x=>10, :y=>11, :lines_x=>12}}]
75
+ @ds1.graph(:lines, {:x=>:id}, :select=>false).graph(:graphs, :id=>:graph_id).all.must_equal [{:points=>{:id=>1, :x=>2, :y=>3}, :graphs=>{:id=>8, :name=>9, :x=>10, :y=>11, :lines_x=>12}}]
76
76
  end
77
77
 
78
78
  it "#graph_each should only include the columns selected with #set_graph_aliases and #add_graph_aliases, if called" do
79
79
  @db.fetch = [nil, [{:x=>2,:y=>3}], nil, [{:x=>2}], [{:x=>2, :q=>18}]]
80
80
 
81
- @ds1.graph(:lines, :x=>:id).set_graph_aliases(:x=>[:points, :x], :y=>[:lines, :y]).all.should == [{:points=>{:x=>2}, :lines=>{:y=>3}}]
81
+ @ds1.graph(:lines, :x=>:id).set_graph_aliases(:x=>[:points, :x], :y=>[:lines, :y]).all.must_equal [{:points=>{:x=>2}, :lines=>{:y=>3}}]
82
82
  ds = @ds1.graph(:lines, :x=>:id).set_graph_aliases(:x=>[:points, :x])
83
- ds.all.should == [{:points=>{:x=>2}, :lines=>nil}]
83
+ ds.all.must_equal [{:points=>{:x=>2}, :lines=>nil}]
84
84
  ds = ds.add_graph_aliases(:q=>[:points, :r, 18])
85
- ds.all.should == [{:points=>{:x=>2, :r=>18}, :lines=>nil}]
85
+ ds.all.must_equal [{:points=>{:x=>2, :r=>18}, :lines=>nil}]
86
86
  end
87
87
 
88
88
  it "#graph_each should correctly map values when #set_graph_aliases is used with a third argument for each entry" do
89
89
  @db.fetch = [nil, {:x=>2,:y=>3}]
90
- @ds1.graph(:lines, :x=>:id).set_graph_aliases(:x=>[:points, :z1, 2], :y=>[:lines, :z2, Sequel.function(:random)]).all.should == [{:points=>{:z1=>2}, :lines=>{:z2=>3}}]
90
+ @ds1.graph(:lines, :x=>:id).set_graph_aliases(:x=>[:points, :z1, 2], :y=>[:lines, :z2, Sequel.function(:random)]).all.must_equal [{:points=>{:z1=>2}, :lines=>{:z2=>3}}]
91
91
  end
92
92
 
93
93
  it "#graph_each should correctly map values when #set_graph_aliases is used with a single argument for each entry" do
94
94
  @db.fetch = [nil, {:x=>2,:y=>3}]
95
- @ds1.graph(:lines, :x=>:id).set_graph_aliases(:x=>[:points], :y=>[:lines]).all.should == [{:points=>{:x=>2}, :lines=>{:y=>3}}]
95
+ @ds1.graph(:lines, :x=>:id).set_graph_aliases(:x=>[:points], :y=>[:lines]).all.must_equal [{:points=>{:x=>2}, :lines=>{:y=>3}}]
96
96
  end
97
97
 
98
98
  it "#graph_each should correctly map values when #set_graph_aliases is used with a symbol for each entry" do
99
99
  @db.fetch = [nil, {:x=>2,:y=>3}]
100
- @ds1.graph(:lines, :x=>:id).set_graph_aliases(:x=>:points, :y=>:lines).all.should == [{:points=>{:x=>2}, :lines=>{:y=>3}}]
100
+ @ds1.graph(:lines, :x=>:id).set_graph_aliases(:x=>:points, :y=>:lines).all.must_equal [{:points=>{:x=>2}, :lines=>{:y=>3}}]
101
101
  end
102
102
 
103
103
  it "#graph_each should run the row_proc for graphed datasets" do
104
104
  @ds1.row_proc = proc{|h| h.keys.each{|k| h[k] *= 2}; h}
105
105
  @ds2.row_proc = proc{|h| h.keys.each{|k| h[k] *= 3}; h}
106
106
  @db.fetch = {:id=>1,:x=>2,:y=>3,:lines_id=>4,:lines_x=>5,:lines_y=>6,:graph_id=>7}
107
- @ds1.graph(@ds2, :x=>:id).all.should == [{:points=>{:id=>2, :x=>4, :y=>6}, :lines=>{:id=>12, :x=>15, :y=>18, :graph_id=>21}}]
107
+ @ds1.graph(@ds2, :x=>:id).all.must_equal [{:points=>{:id=>2, :x=>4, :y=>6}, :lines=>{:id=>12, :x=>15, :y=>18, :graph_id=>21}}]
108
108
  end
109
109
  end
@@ -6,19 +6,19 @@ describe "hash_aliases extension" do
6
6
  end
7
7
 
8
8
  it "should make from treat hash arguments as alias specifiers" do
9
- @ds.from(:a=>:b).sql.should == "SELECT * FROM a AS b"
9
+ @ds.from(:a=>:b).sql.must_equal "SELECT * FROM a AS b"
10
10
  end
11
11
 
12
12
  it "should not affect other arguments to from" do
13
- @ds.from(:a, :b).sql.should == "SELECT * FROM a, b"
13
+ @ds.from(:a, :b).sql.must_equal "SELECT * FROM a, b"
14
14
  end
15
15
 
16
16
  it "should make select treat hash arguments as alias specifiers" do
17
- @ds.select(:a=>:b).sql.should == "SELECT a AS b"
18
- @ds.select{{:a=>:b}}.sql.should == "SELECT a AS b"
17
+ @ds.select(:a=>:b).sql.must_equal "SELECT a AS b"
18
+ @ds.select{{:a=>:b}}.sql.must_equal "SELECT a AS b"
19
19
  end
20
20
 
21
21
  it "should not affect other arguments to select" do
22
- @ds.select(:a, :b).sql.should == "SELECT a, b"
22
+ @ds.select(:a, :b).sql.must_equal "SELECT a, b"
23
23
  end
24
24
  end