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
@@ -11,163 +11,163 @@ describe "Sequel::Plugins::StaticCache" do
11
11
 
12
12
  it "should not attempt to validate objects" do
13
13
  @c.send(:define_method, :validate){errors.add(:name, 'bad')}
14
- proc{@c.plugin(:static_cache)}.should_not raise_error
15
- @c.map{|o| o.valid?}.should == [true, true]
14
+ @c.plugin(:static_cache)
15
+ @c.map{|o| o.valid?}.must_equal [true, true]
16
16
  end
17
17
 
18
- shared_examples_for "Sequel::Plugins::StaticCache" do
18
+ static_cache_specs = shared_description do
19
19
  it "should use a ruby hash as a cache of all model instances" do
20
- @c.cache.should == {1=>@c.load(:id=>1), 2=>@c.load(:id=>2)}
21
- @c.cache[1].should equal(@c1)
22
- @c.cache[2].should equal(@c2)
20
+ @c.cache.must_equal(1=>@c.load(:id=>1), 2=>@c.load(:id=>2))
21
+ @c.cache[1].must_be_same_as(@c1)
22
+ @c.cache[2].must_be_same_as(@c2)
23
23
  end
24
24
 
25
25
  it "should make .[] method with primary key use the cache" do
26
- @c[1].should == @c1
27
- @c[2].should == @c2
28
- @c[3].should be_nil
29
- @c[[1, 2]].should be_nil
30
- @c[nil].should be_nil
31
- @c[].should be_nil
32
- @db.sqls.should == []
26
+ @c[1].must_equal @c1
27
+ @c[2].must_equal @c2
28
+ @c[3].must_equal nil
29
+ @c[[1, 2]].must_equal nil
30
+ @c[nil].must_equal nil
31
+ @c[].must_equal nil
32
+ @db.sqls.must_equal []
33
33
  end
34
34
 
35
35
  it "should have .[] with a hash not use the cache" do
36
36
  @db.fetch = {:id=>2}
37
- @c[:id=>2].should == @c2
38
- @db.sqls.should == ['SELECT * FROM t WHERE (id = 2) LIMIT 1']
37
+ @c[:id=>2].must_equal @c2
38
+ @db.sqls.must_equal ['SELECT * FROM t WHERE (id = 2) LIMIT 1']
39
39
  end
40
40
 
41
41
  it "should support cache_get_pk" do
42
- @c.cache_get_pk(1).should == @c1
43
- @c.cache_get_pk(2).should == @c2
44
- @c.cache_get_pk(3).should be_nil
45
- @db.sqls.should == []
42
+ @c.cache_get_pk(1).must_equal @c1
43
+ @c.cache_get_pk(2).must_equal @c2
44
+ @c.cache_get_pk(3).must_equal nil
45
+ @db.sqls.must_equal []
46
46
  end
47
47
 
48
48
  it "should have each just iterate over the hash's values without sending a query" do
49
49
  a = []
50
50
  @c.each{|o| a << o}
51
51
  a = a.sort_by{|o| o.id}
52
- a.first.should == @c1
53
- a.last.should == @c2
54
- @db.sqls.should == []
52
+ a.first.must_equal @c1
53
+ a.last.must_equal @c2
54
+ @db.sqls.must_equal []
55
55
  end
56
56
 
57
57
  it "should have map just iterate over the hash's values without sending a query if no argument is given" do
58
- @c.map{|v| v.id}.sort.should == [1, 2]
59
- @db.sqls.should == []
58
+ @c.map{|v| v.id}.sort.must_equal [1, 2]
59
+ @db.sqls.must_equal []
60
60
  end
61
61
 
62
62
  it "should have count with no argument or block not issue a query" do
63
- @c.count.should == 2
64
- @db.sqls.should == []
63
+ @c.count.must_equal 2
64
+ @db.sqls.must_equal []
65
65
  end
66
66
 
67
67
  it "should have count with argument or block not issue a query" do
68
68
  @db.fetch = [[{:count=>1}], [{:count=>2}]]
69
- @c.count(:a).should == 1
70
- @c.count{b}.should == 2
71
- @db.sqls.should == ["SELECT count(a) AS count FROM t LIMIT 1", "SELECT count(b) AS count FROM t LIMIT 1"]
69
+ @c.count(:a).must_equal 1
70
+ @c.count{b}.must_equal 2
71
+ @db.sqls.must_equal ["SELECT count(a) AS count FROM t LIMIT 1", "SELECT count(b) AS count FROM t LIMIT 1"]
72
72
  end
73
73
 
74
74
  it "should have map not send a query if given an argument" do
75
- @c.map(:id).sort.should == [1, 2]
76
- @db.sqls.should == []
77
- @c.map([:id,:id]).sort.should == [[1,1], [2,2]]
78
- @db.sqls.should == []
75
+ @c.map(:id).sort.must_equal [1, 2]
76
+ @db.sqls.must_equal []
77
+ @c.map([:id,:id]).sort.must_equal [[1,1], [2,2]]
78
+ @db.sqls.must_equal []
79
79
  end
80
80
 
81
81
  it "should have map without a block or argument not raise an exception or issue a query" do
82
- @c.map.to_a.should == @c.all
83
- @db.sqls.should == []
82
+ @c.map.to_a.must_equal @c.all
83
+ @db.sqls.must_equal []
84
84
  end
85
85
 
86
86
  it "should have map without a block not return a frozen object" do
87
- @c.map.frozen?.should == false
87
+ @c.map.frozen?.must_equal false
88
88
  end
89
89
 
90
90
  it "should have map with a block and argument raise" do
91
- proc{@c.map(:id){}}.should raise_error(Sequel::Error)
91
+ proc{@c.map(:id){}}.must_raise(Sequel::Error)
92
92
  end
93
93
 
94
94
  it "should have other enumerable methods work without sending a query" do
95
95
  a = @c.sort_by{|o| o.id}
96
- a.first.should == @c1
97
- a.last.should == @c2
98
- @db.sqls.should == []
96
+ a.first.must_equal @c1
97
+ a.last.must_equal @c2
98
+ @db.sqls.must_equal []
99
99
  end
100
100
 
101
101
  it "should have all return all objects" do
102
102
  a = @c.all.sort_by{|o| o.id}
103
- a.first.should == @c1
104
- a.last.should == @c2
105
- @db.sqls.should == []
103
+ a.first.must_equal @c1
104
+ a.last.must_equal @c2
105
+ @db.sqls.must_equal []
106
106
  end
107
107
 
108
108
  it "should have all not return a frozen object" do
109
- @c.all.frozen?.should == false
109
+ @c.all.frozen?.must_equal false
110
110
  end
111
111
 
112
112
  it "should have all return things in dataset order" do
113
- @c.all.should == [@c1, @c2]
113
+ @c.all.must_equal [@c1, @c2]
114
114
  end
115
115
 
116
116
  it "should have to_hash without arguments run without a query" do
117
117
  a = @c.to_hash
118
- a.should == {1=>@c1, 2=>@c2}
119
- a[1].should == @c1
120
- a[2].should == @c2
121
- @db.sqls.should == []
118
+ a.must_equal(1=>@c1, 2=>@c2)
119
+ a[1].must_equal @c1
120
+ a[2].must_equal @c2
121
+ @db.sqls.must_equal []
122
122
  end
123
123
 
124
124
  it "should have to_hash with arguments return results without a query" do
125
125
  a = @c.to_hash(:id)
126
- a.should == {1=>@c1, 2=>@c2}
127
- a[1].should == @c1
128
- a[2].should == @c2
126
+ a.must_equal(1=>@c1, 2=>@c2)
127
+ a[1].must_equal @c1
128
+ a[2].must_equal @c2
129
129
 
130
130
  a = @c.to_hash([:id])
131
- a.should == {[1]=>@c1, [2]=>@c2}
132
- a[[1]].should == @c1
133
- a[[2]].should == @c2
131
+ a.must_equal([1]=>@c1, [2]=>@c2)
132
+ a[[1]].must_equal @c1
133
+ a[[2]].must_equal @c2
134
134
 
135
- @c.to_hash(:id, :id).should == {1=>1, 2=>2}
136
- @c.to_hash([:id], :id).should == {[1]=>1, [2]=>2}
137
- @c.to_hash(:id, [:id]).should == {1=>[1], 2=>[2]}
138
- @c.to_hash([:id], [:id]).should == {[1]=>[1], [2]=>[2]}
135
+ @c.to_hash(:id, :id).must_equal(1=>1, 2=>2)
136
+ @c.to_hash([:id], :id).must_equal([1]=>1, [2]=>2)
137
+ @c.to_hash(:id, [:id]).must_equal(1=>[1], 2=>[2])
138
+ @c.to_hash([:id], [:id]).must_equal([1]=>[1], [2]=>[2])
139
139
 
140
- @db.sqls.should == []
140
+ @db.sqls.must_equal []
141
141
  end
142
142
 
143
143
  it "should have to_hash not return a frozen object" do
144
- @c.to_hash.frozen?.should == false
144
+ @c.to_hash.frozen?.must_equal false
145
145
  end
146
146
 
147
147
  it "should have to_hash_groups without arguments return the cached objects without a query" do
148
148
  a = @c.to_hash_groups(:id)
149
- a.should == {1=>[@c1], 2=>[@c2]}
150
- a[1].first.should == @c1
151
- a[2].first.should == @c2
149
+ a.must_equal(1=>[@c1], 2=>[@c2])
150
+ a[1].first.must_equal @c1
151
+ a[2].first.must_equal @c2
152
152
 
153
153
  a = @c.to_hash_groups([:id])
154
- a.should == {[1]=>[@c1], [2]=>[@c2]}
155
- a[[1]].first.should == @c1
156
- a[[2]].first.should == @c2
154
+ a.must_equal([1]=>[@c1], [2]=>[@c2])
155
+ a[[1]].first.must_equal @c1
156
+ a[[2]].first.must_equal @c2
157
157
 
158
- @c.to_hash_groups(:id, :id).should == {1=>[1], 2=>[2]}
159
- @c.to_hash_groups([:id], :id).should == {[1]=>[1], [2]=>[2]}
160
- @c.to_hash_groups(:id, [:id]).should == {1=>[[1]], 2=>[[2]]}
161
- @c.to_hash_groups([:id], [:id]).should == {[1]=>[[1]], [2]=>[[2]]}
158
+ @c.to_hash_groups(:id, :id).must_equal(1=>[1], 2=>[2])
159
+ @c.to_hash_groups([:id], :id).must_equal([1]=>[1], [2]=>[2])
160
+ @c.to_hash_groups(:id, [:id]).must_equal(1=>[[1]], 2=>[[2]])
161
+ @c.to_hash_groups([:id], [:id]).must_equal([1]=>[[1]], [2]=>[[2]])
162
162
 
163
- @db.sqls.should == []
163
+ @db.sqls.must_equal []
164
164
  end
165
165
 
166
166
  it "subclasses should work correctly" do
167
167
  c = Class.new(@c)
168
- c.all.should == [c.load(:id=>1), c.load(:id=>2)]
169
- c.to_hash.should == {1=>c.load(:id=>1), 2=>c.load(:id=>2)}
170
- @db.sqls.should == ['SELECT * FROM t']
168
+ c.all.must_equal [c.load(:id=>1), c.load(:id=>2)]
169
+ c.to_hash.must_equal(1=>c.load(:id=>1), 2=>c.load(:id=>2))
170
+ @db.sqls.must_equal ['SELECT * FROM t']
171
171
  end
172
172
 
173
173
  it "set_dataset should work correctly" do
@@ -175,10 +175,10 @@ describe "Sequel::Plugins::StaticCache" do
175
175
  ds.instance_variable_set(:@columns, [:id])
176
176
  ds._fetch = {:id=>3}
177
177
  @c.dataset = ds
178
- @c.all.should == [@c.load(:id=>3)]
179
- @c.to_hash.should == {3=>@c.load(:id=>3)}
180
- @c.to_hash[3].should == @c.all.first
181
- @db.sqls.should == ['SELECT * FROM t2']
178
+ @c.all.must_equal [@c.load(:id=>3)]
179
+ @c.to_hash.must_equal(3=>@c.load(:id=>3))
180
+ @c.to_hash[3].must_equal @c.all.first
181
+ @db.sqls.must_equal ['SELECT * FROM t2']
182
182
  end
183
183
  end
184
184
 
@@ -190,7 +190,7 @@ describe "Sequel::Plugins::StaticCache" do
190
190
  @db.sqls
191
191
  end
192
192
 
193
- it_should_behave_like "Sequel::Plugins::StaticCache"
193
+ include static_cache_specs
194
194
 
195
195
  it "should work correctly with composite keys" do
196
196
  @db.fetch = [{:id=>1, :id2=>1}, {:id=>2, :id2=>1}]
@@ -201,83 +201,83 @@ describe "Sequel::Plugins::StaticCache" do
201
201
  @db.sqls
202
202
  @c1 = @c.cache[[1, 2]]
203
203
  @c2 = @c.cache[[2, 1]]
204
- @c[[1, 2]].should equal(@c1)
205
- @c[[2, 1]].should equal(@c2)
206
- @db.sqls.should == []
204
+ @c[[1, 2]].must_be_same_as(@c1)
205
+ @c[[2, 1]].must_be_same_as(@c2)
206
+ @db.sqls.must_equal []
207
207
  end
208
208
 
209
209
  it "all of the static cache values (model instances) should be frozen" do
210
- @c.all.all?{|o| o.frozen?}.should == true
210
+ @c.all.all?{|o| o.frozen?}.must_equal true
211
211
  end
212
212
 
213
213
  it "should make .[] method with primary key return cached instances" do
214
- @c[1].should equal(@c1)
215
- @c[2].should equal(@c2)
214
+ @c[1].must_be_same_as(@c1)
215
+ @c[2].must_be_same_as(@c2)
216
216
  end
217
217
 
218
218
  it "should have cache_get_pk return cached instances" do
219
- @c.cache_get_pk(1).should equal(@c1)
220
- @c.cache_get_pk(2).should equal(@c2)
219
+ @c.cache_get_pk(1).must_be_same_as(@c1)
220
+ @c.cache_get_pk(2).must_be_same_as(@c2)
221
221
  end
222
222
 
223
223
  it "should have each yield cached objects" do
224
224
  a = []
225
225
  @c.each{|o| a << o}
226
226
  a = a.sort_by{|o| o.id}
227
- a.first.should equal(@c1)
228
- a.last.should equal(@c2)
227
+ a.first.must_be_same_as(@c1)
228
+ a.last.must_be_same_as(@c2)
229
229
  end
230
230
 
231
231
  it "should have other enumerable methods work yield cached objects" do
232
232
  a = @c.sort_by{|o| o.id}
233
- a.first.should equal(@c1)
234
- a.last.should equal(@c2)
233
+ a.first.must_be_same_as(@c1)
234
+ a.last.must_be_same_as(@c2)
235
235
  end
236
236
 
237
237
  it "should have all return cached instances" do
238
238
  a = @c.all.sort_by{|o| o.id}
239
- a.first.should equal(@c1)
240
- a.last.should equal(@c2)
239
+ a.first.must_be_same_as(@c1)
240
+ a.last.must_be_same_as(@c2)
241
241
  end
242
242
 
243
243
  it "should have to_hash without arguments use cached instances" do
244
244
  a = @c.to_hash
245
- a[1].should equal(@c1)
246
- a[2].should equal(@c2)
245
+ a[1].must_be_same_as(@c1)
246
+ a[2].must_be_same_as(@c2)
247
247
  end
248
248
 
249
249
  it "should have to_hash with arguments return cached instances" do
250
250
  a = @c.to_hash(:id)
251
- a[1].should equal(@c1)
252
- a[2].should equal(@c2)
251
+ a[1].must_be_same_as(@c1)
252
+ a[2].must_be_same_as(@c2)
253
253
 
254
254
  a = @c.to_hash([:id])
255
- a[[1]].should equal(@c1)
256
- a[[2]].should equal(@c2)
255
+ a[[1]].must_be_same_as(@c1)
256
+ a[[2]].must_be_same_as(@c2)
257
257
  end
258
258
 
259
259
  it "should have to_hash_groups without single argument return the cached instances" do
260
260
  a = @c.to_hash_groups(:id)
261
- a[1].first.should equal(@c1)
262
- a[2].first.should equal(@c2)
261
+ a[1].first.must_be_same_as(@c1)
262
+ a[2].first.must_be_same_as(@c2)
263
263
 
264
264
  a = @c.to_hash_groups([:id])
265
- a[[1]].first.should equal(@c1)
266
- a[[2]].first.should equal(@c2)
265
+ a[[1]].first.must_be_same_as(@c1)
266
+ a[[2]].first.must_be_same_as(@c2)
267
267
  end
268
268
 
269
269
  it "should not allow the saving of new objects" do
270
- proc{@c.create}.should raise_error(Sequel::HookFailed)
270
+ proc{@c.create}.must_raise(Sequel::HookFailed)
271
271
  end
272
272
 
273
273
  it "should not allow the saving of existing objects" do
274
274
  @db.fetch = {:id=>1}
275
- proc{@c.first(:id=>1).save}.should raise_error(Sequel::HookFailed)
275
+ proc{@c.first(:id=>1).save}.must_raise(Sequel::HookFailed)
276
276
  end
277
277
 
278
278
  it "should not allow the destroying of existing objects" do
279
279
  @db.fetch = {:id=>1}
280
- proc{@c.first(:id=>1).destroy}.should raise_error(Sequel::HookFailed)
280
+ proc{@c.first(:id=>1).destroy}.must_raise(Sequel::HookFailed)
281
281
  end
282
282
  end
283
283
 
@@ -289,50 +289,50 @@ describe "Sequel::Plugins::StaticCache" do
289
289
  @db.sqls
290
290
  end
291
291
 
292
- it_should_behave_like "Sequel::Plugins::StaticCache"
292
+ include static_cache_specs
293
293
 
294
294
  it "record retrieved by primary key should not be frozen" do
295
- @c[1].frozen?.should == false
296
- @c.cache_get_pk(1).frozen?.should == false
295
+ @c[1].frozen?.must_equal false
296
+ @c.cache_get_pk(1).frozen?.must_equal false
297
297
  end
298
298
 
299
299
  it "none of values returned in #all should be frozen" do
300
- @c.all.all?{|o| !o.frozen?}.should == true
300
+ @c.all.all?{|o| !o.frozen?}.must_equal true
301
301
  end
302
302
 
303
303
  it "none of values yielded by each should be frozen" do
304
304
  a = []
305
305
  @c.each{|o| a << o}
306
- a.all?{|o| !o.frozen?}.should == true
306
+ a.all?{|o| !o.frozen?}.must_equal true
307
307
  end
308
308
 
309
309
  it "none of values yielded by Enumerable method should be frozen" do
310
- @c.sort_by{|o| o.id}.all?{|o| !o.frozen?}.should == true
310
+ @c.sort_by{|o| o.id}.all?{|o| !o.frozen?}.must_equal true
311
311
  end
312
312
 
313
313
  it "none of values returned by map without an argument or block should be frozen" do
314
- @c.map{|o| o}.all?{|o| !o.frozen?}.should == true
315
- @c.map.all?{|o| !o.frozen?}.should == true
314
+ @c.map{|o| o}.all?{|o| !o.frozen?}.must_equal true
315
+ @c.map.all?{|o| !o.frozen?}.must_equal true
316
316
  end
317
317
 
318
318
  it "none of values in the hash returned by to_hash without an argument should be frozen" do
319
- @c.to_hash.values.all?{|o| !o.frozen?}.should == true
319
+ @c.to_hash.values.all?{|o| !o.frozen?}.must_equal true
320
320
  end
321
321
 
322
322
  it "none of values in the hash returned by to_hash with a single argument should be frozen" do
323
- @c.to_hash(:id).values.all?{|o| !o.frozen?}.should == true
323
+ @c.to_hash(:id).values.all?{|o| !o.frozen?}.must_equal true
324
324
  end
325
325
 
326
326
  it "none of values in the hash returned by to_hash with a single array argument should be frozen" do
327
- @c.to_hash([:id, :id]).values.all?{|o| !o.frozen?}.should == true
327
+ @c.to_hash([:id, :id]).values.all?{|o| !o.frozen?}.must_equal true
328
328
  end
329
329
 
330
330
  it "none of values in the hash returned by to_hash_groups with a single argument should be frozen" do
331
- @c.to_hash_groups(:id).values.flatten.all?{|o| !o.frozen?}.should == true
331
+ @c.to_hash_groups(:id).values.flatten.all?{|o| !o.frozen?}.must_equal true
332
332
  end
333
333
 
334
334
  it "none of values in the hash returned by to_hash_groups with a single array argument should be frozen" do
335
- @c.to_hash_groups([:id, :id]).values.flatten.all?{|o| !o.frozen?}.should == true
335
+ @c.to_hash_groups([:id, :id]).values.flatten.all?{|o| !o.frozen?}.must_equal true
336
336
  end
337
337
 
338
338
  it "should not automatically update the cache when creating new model objects" do
@@ -341,21 +341,21 @@ describe "Sequel::Plugins::StaticCache" do
341
341
  @db.autoid = 3
342
342
  @db.fetch = [[{:id=>1}, {:id=>2}, {:id=>3}], [{:id=>3}]]
343
343
  o.save
344
- @c[3].should == nil
344
+ @c[3].must_equal nil
345
345
  end
346
346
 
347
347
  it "should not automatically update the cache when updating model objects" do
348
348
  o = @c[2]
349
349
  @db.fetch = [[{:id=>1}, {:id=>2, :name=>'a'}]]
350
350
  o.update(:name=>'a')
351
- @c[2].values.should == {:id=>2}
351
+ @c[2].values.must_equal(:id=>2)
352
352
  end
353
353
 
354
354
  it "should not automatically update the cache when updating model objects" do
355
355
  o = @c[2]
356
356
  @db.fetch = [[{:id=>1}]]
357
357
  o.destroy
358
- @c[2].should == @c2
358
+ @c[2].must_equal @c2
359
359
  end
360
360
  end
361
361
  end