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
@@ -12,15 +12,15 @@ describe Sequel::Inflections do
12
12
 
13
13
  it "should be possible to clear the list of singulars, plurals, and uncountables" do
14
14
  Sequel.inflections.clear(:plurals)
15
- Sequel.inflections.plurals.should == []
15
+ Sequel.inflections.plurals.must_equal []
16
16
  Sequel.inflections.plural('blah', 'blahs')
17
17
  Sequel.inflections.clear
18
- Sequel.inflections.plurals.should == []
19
- Sequel.inflections.singulars.should == []
20
- Sequel.inflections.uncountables.should == []
18
+ Sequel.inflections.plurals.must_equal []
19
+ Sequel.inflections.singulars.must_equal []
20
+ Sequel.inflections.uncountables.must_equal []
21
21
  end
22
22
 
23
23
  it "should be yielded and returned by Sequel.inflections" do
24
- Sequel.inflections{|i| i.should == Sequel::Inflections}.should == Sequel::Inflections
24
+ Sequel.inflections{|i| i.must_equal Sequel::Inflections}.must_equal Sequel::Inflections
25
25
  end
26
26
  end
@@ -8,62 +8,62 @@ describe "Sequel::Model()" do
8
8
  it "should return a model subclass with the given dataset if given a dataset" do
9
9
  ds = @db[:blah]
10
10
  c = Sequel::Model(ds)
11
- c.superclass.should == Sequel::Model
12
- c.dataset.should == ds
11
+ c.superclass.must_equal Sequel::Model
12
+ c.dataset.must_equal ds
13
13
  end
14
14
 
15
15
  it "should return a model subclass with a dataset with the default database and given table name if given a Symbol" do
16
16
  c = Sequel::Model(:blah)
17
- c.superclass.should == Sequel::Model
18
- c.db.should == @db
19
- c.table_name.should == :blah
17
+ c.superclass.must_equal Sequel::Model
18
+ c.db.must_equal @db
19
+ c.table_name.must_equal :blah
20
20
  end
21
21
 
22
22
  it "should return a model subclass with a dataset with the default database and given table name if given a LiteralString" do
23
23
  c = Sequel::Model(Sequel.lit('blah'))
24
- c.superclass.should == Sequel::Model
25
- c.db.should == @db
26
- c.table_name.should == Sequel.lit('blah')
24
+ c.superclass.must_equal Sequel::Model
25
+ c.db.must_equal @db
26
+ c.table_name.must_equal Sequel.lit('blah')
27
27
  end
28
28
 
29
29
  it "should return a model subclass with a dataset with the default database and given table name if given an SQL::Identifier" do
30
30
  c = Sequel::Model(Sequel.identifier(:blah))
31
- c.superclass.should == Sequel::Model
32
- c.db.should == @db
33
- c.table_name.should == Sequel.identifier(:blah)
31
+ c.superclass.must_equal Sequel::Model
32
+ c.db.must_equal @db
33
+ c.table_name.must_equal Sequel.identifier(:blah)
34
34
  end
35
35
 
36
36
  it "should return a model subclass with a dataset with the default database and given table name if given an SQL::QualifiedIdentifier" do
37
37
  c = Sequel::Model(Sequel.qualify(:boo, :blah))
38
- c.superclass.should == Sequel::Model
39
- c.db.should == @db
40
- c.table_name.should == Sequel.qualify(:boo, :blah)
38
+ c.superclass.must_equal Sequel::Model
39
+ c.db.must_equal @db
40
+ c.table_name.must_equal Sequel.qualify(:boo, :blah)
41
41
  end
42
42
 
43
43
  it "should return a model subclass with a dataset with the default database and given table name if given an SQL::AliasedExpression" do
44
44
  c = Sequel::Model(Sequel.as(:blah, :boo))
45
- c.superclass.should == Sequel::Model
46
- c.db.should == @db
47
- c.table_name.should == :boo
45
+ c.superclass.must_equal Sequel::Model
46
+ c.db.must_equal @db
47
+ c.table_name.must_equal :boo
48
48
  end
49
49
 
50
50
  it "should return a model subclass with the given dataset if given a dataset using an SQL::Identifier" do
51
51
  ds = @db[Sequel.identifier(:blah)]
52
52
  c = Sequel::Model(ds)
53
- c.superclass.should == Sequel::Model
54
- c.dataset.should == ds
53
+ c.superclass.must_equal Sequel::Model
54
+ c.dataset.must_equal ds
55
55
  end
56
56
 
57
57
  it "should return a model subclass associated to the given database if given a database" do
58
58
  db = Sequel.mock
59
59
  c = Sequel::Model(db)
60
- c.superclass.should == Sequel::Model
61
- c.db.should == db
62
- proc{c.dataset}.should raise_error(Sequel::Error)
60
+ c.superclass.must_equal Sequel::Model
61
+ c.db.must_equal db
62
+ proc{c.dataset}.must_raise(Sequel::Error)
63
63
  class SmBlahTest < c
64
64
  end
65
- SmBlahTest.db.should == db
66
- SmBlahTest.table_name.should == :sm_blah_tests
65
+ SmBlahTest.db.must_equal db
66
+ SmBlahTest.table_name.must_equal :sm_blah_tests
67
67
  end
68
68
 
69
69
  describe "reloading" do
@@ -76,59 +76,43 @@ describe "Sequel::Model()" do
76
76
  end
77
77
 
78
78
  it "should work without raising an exception with a symbol" do
79
- proc do
80
- class ::Album < Sequel::Model(:table); end
81
- class ::Album < Sequel::Model(:table); end
82
- end.should_not raise_error
79
+ class ::Album < Sequel::Model(:table); end
80
+ class ::Album < Sequel::Model(:table); end
83
81
  end
84
82
 
85
83
  it "should work without raising an exception with an SQL::Identifier " do
86
- proc do
87
- class ::Album < Sequel::Model(Sequel.identifier(:table)); end
88
- class ::Album < Sequel::Model(Sequel.identifier(:table)); end
89
- end.should_not raise_error
84
+ class ::Album < Sequel::Model(Sequel.identifier(:table)); end
85
+ class ::Album < Sequel::Model(Sequel.identifier(:table)); end
90
86
  end
91
87
 
92
88
  it "should work without raising an exception with an SQL::QualifiedIdentifier " do
93
- proc do
94
- class ::Album < Sequel::Model(Sequel.qualify(:schema, :table)); end
95
- class ::Album < Sequel::Model(Sequel.qualify(:schema, :table)); end
96
- end.should_not raise_error
89
+ class ::Album < Sequel::Model(Sequel.qualify(:schema, :table)); end
90
+ class ::Album < Sequel::Model(Sequel.qualify(:schema, :table)); end
97
91
  end
98
92
 
99
93
  it "should work without raising an exception with an SQL::AliasedExpression" do
100
- proc do
101
- class ::Album < Sequel::Model(Sequel.as(:table, :alias)); end
102
- class ::Album < Sequel::Model(Sequel.as(:table, :alias)); end
103
- end.should_not raise_error
94
+ class ::Album < Sequel::Model(Sequel.as(:table, :alias)); end
95
+ class ::Album < Sequel::Model(Sequel.as(:table, :alias)); end
104
96
  end
105
97
 
106
98
  it "should work without raising an exception with an LiteralString" do
107
- proc do
108
- class ::Album < Sequel::Model(Sequel.lit('table')); end
109
- class ::Album < Sequel::Model(Sequel.lit('table')); end
110
- end.should_not raise_error
99
+ class ::Album < Sequel::Model(Sequel.lit('table')); end
100
+ class ::Album < Sequel::Model(Sequel.lit('table')); end
111
101
  end
112
102
 
113
103
  it "should work without raising an exception with a database" do
114
- proc do
115
- class ::Album < Sequel::Model(@db); end
116
- class ::Album < Sequel::Model(@db); end
117
- end.should_not raise_error
104
+ class ::Album < Sequel::Model(@db); end
105
+ class ::Album < Sequel::Model(@db); end
118
106
  end
119
107
 
120
108
  it "should work without raising an exception with a dataset" do
121
- proc do
122
- class ::Album < Sequel::Model(@db[:table]); end
123
- class ::Album < Sequel::Model(@db[:table]); end
124
- end.should_not raise_error
109
+ class ::Album < Sequel::Model(@db[:table]); end
110
+ class ::Album < Sequel::Model(@db[:table]); end
125
111
  end
126
112
 
127
113
  it "should work without raising an exception with a dataset with an SQL::Identifier" do
128
- proc do
129
- class ::Album < Sequel::Model(@db[Sequel.identifier(:table)]); end
130
- class ::Album < Sequel::Model(@db[Sequel.identifier(:table)]); end
131
- end.should_not raise_error
114
+ class ::Album < Sequel::Model(@db[Sequel.identifier(:table)]); end
115
+ class ::Album < Sequel::Model(@db[Sequel.identifier(:table)]); end
132
116
  end
133
117
 
134
118
  it "should raise an exception if anonymous model caching is disabled" do
@@ -136,31 +120,31 @@ describe "Sequel::Model()" do
136
120
  proc do
137
121
  class ::Album < Sequel::Model(@db[Sequel.identifier(:table)]); end
138
122
  class ::Album < Sequel::Model(@db[Sequel.identifier(:table)]); end
139
- end.should raise_error
123
+ end.must_raise TypeError
140
124
  end
141
125
  end
142
126
  end
143
127
 
144
128
  describe Sequel::Model do
145
129
  it "should have class method aliased as model" do
146
- Sequel::Model.instance_methods.collect{|x| x.to_s}.should include("model")
130
+ Sequel::Model.instance_methods.collect{|x| x.to_s}.must_include("model")
147
131
 
148
132
  model_a = Class.new(Sequel::Model(:items))
149
- model_a.new.model.should be(model_a)
133
+ model_a.new.model.wont_be_nil
150
134
  end
151
135
 
152
136
  it "should be associated with a dataset" do
153
137
  model_a = Class.new(Sequel::Model) { set_dataset DB[:as] }
154
138
 
155
- model_a.dataset.should be_a_kind_of(Sequel::Mock::Dataset)
156
- model_a.dataset.opts[:from].should == [:as]
139
+ model_a.dataset.must_be_kind_of(Sequel::Mock::Dataset)
140
+ model_a.dataset.opts[:from].must_equal [:as]
157
141
 
158
142
  model_b = Class.new(Sequel::Model) { set_dataset DB[:bs] }
159
143
 
160
- model_b.dataset.should be_a_kind_of(Sequel::Mock::Dataset)
161
- model_b.dataset.opts[:from].should == [:bs]
144
+ model_b.dataset.must_be_kind_of(Sequel::Mock::Dataset)
145
+ model_b.dataset.opts[:from].must_equal [:bs]
162
146
 
163
- model_a.dataset.opts[:from].should == [:as]
147
+ model_a.dataset.opts[:from].must_equal [:as]
164
148
  end
165
149
  end
166
150
 
@@ -170,71 +154,71 @@ describe Sequel::Model do
170
154
  end
171
155
 
172
156
  it "has table_name return name of table" do
173
- @model.table_name.should == :items
157
+ @model.table_name.must_equal :items
174
158
  end
175
159
 
176
160
  it "defaults to primary key of id" do
177
- @model.primary_key.should == :id
161
+ @model.primary_key.must_equal :id
178
162
  end
179
163
 
180
164
  it "allow primary key change" do
181
165
  @model.set_primary_key :ssn
182
- @model.primary_key.should == :ssn
166
+ @model.primary_key.must_equal :ssn
183
167
  end
184
168
 
185
169
  it "allows dataset change" do
186
170
  @model.set_dataset(DB[:foo])
187
- @model.table_name.should == :foo
171
+ @model.table_name.must_equal :foo
188
172
  end
189
173
 
190
174
  it "allows set_dataset to accept a Symbol" do
191
175
  @model.db = DB
192
176
  @model.set_dataset(:foo)
193
- @model.table_name.should == :foo
177
+ @model.table_name.must_equal :foo
194
178
  end
195
179
 
196
180
  it "allows set_dataset to accept a LiteralString" do
197
181
  @model.db = DB
198
182
  @model.set_dataset(Sequel.lit('foo'))
199
- @model.table_name.should == Sequel.lit('foo')
183
+ @model.table_name.must_equal Sequel.lit('foo')
200
184
  end
201
185
 
202
186
  it "allows set_dataset to acceptan SQL::Identifier" do
203
187
  @model.db = DB
204
188
  @model.set_dataset(Sequel.identifier(:foo))
205
- @model.table_name.should == Sequel.identifier(:foo)
189
+ @model.table_name.must_equal Sequel.identifier(:foo)
206
190
  end
207
191
 
208
192
  it "allows set_dataset to acceptan SQL::QualifiedIdentifier" do
209
193
  @model.db = DB
210
194
  @model.set_dataset(Sequel.qualify(:bar, :foo))
211
- @model.table_name.should == Sequel.qualify(:bar, :foo)
195
+ @model.table_name.must_equal Sequel.qualify(:bar, :foo)
212
196
  end
213
197
 
214
198
  it "allows set_dataset to acceptan SQL::AliasedExpression" do
215
199
  @model.db = DB
216
200
  @model.set_dataset(Sequel.as(:foo, :bar))
217
- @model.table_name.should == :bar
201
+ @model.table_name.must_equal :bar
218
202
  end
219
203
 
220
204
  it "table_name should respect table aliases" do
221
205
  @model.set_dataset(:foo___x)
222
- @model.table_name.should == :x
206
+ @model.table_name.must_equal :x
223
207
  end
224
208
 
225
209
  it "set_dataset should raise an error unless given a Symbol or Dataset" do
226
- proc{@model.set_dataset(Object.new)}.should raise_error(Sequel::Error)
210
+ proc{@model.set_dataset(Object.new)}.must_raise(Sequel::Error)
227
211
  end
228
212
 
229
213
  it "set_dataset should add the destroy method to the dataset that destroys each object" do
230
214
  ds = DB[:foo]
231
- ds.should_not respond_to(:destroy)
215
+ ds.wont_respond_to(:destroy)
232
216
  @model.set_dataset(ds)
233
- ds.should respond_to(:destroy)
217
+ ds.must_respond_to(:destroy)
234
218
  DB.sqls
235
219
  ds._fetch = [{:id=>1}, {:id=>2}]
236
- ds.destroy.should == 2
237
- DB.sqls.should == ["SELECT * FROM foo", "DELETE FROM foo WHERE id = 1", "DELETE FROM foo WHERE id = 2"]
220
+ ds.destroy.must_equal 2
221
+ DB.sqls.must_equal ["SELECT * FROM foo", "DELETE FROM foo WHERE id = 1", "DELETE FROM foo WHERE id = 2"]
238
222
  end
239
223
 
240
224
  it "set_dataset should add the destroy method that respects sharding with transactions" do
@@ -243,34 +227,40 @@ describe Sequel::Model do
243
227
  @model.use_transactions = true
244
228
  @model.set_dataset(ds)
245
229
  db.sqls
246
- ds.destroy.should == 0
247
- db.sqls.should == ["BEGIN -- s1", "SELECT * FROM foo -- s1", "COMMIT -- s1"]
230
+ ds.destroy.must_equal 0
231
+ db.sqls.must_equal ["BEGIN -- s1", "SELECT * FROM foo -- s1", "COMMIT -- s1"]
248
232
  end
249
233
 
250
234
  it "should raise an error on set_dataset if there is an error connecting to the database" do
251
235
  def @model.columns() raise Sequel::DatabaseConnectionError end
252
- proc{@model.set_dataset(Sequel::Database.new[:foo].join(:blah))}.should raise_error
236
+ proc{@model.set_dataset(Sequel::Database.new[:foo].join(:blah))}.must_raise Sequel::DatabaseConnectionError
253
237
  end
254
238
 
255
239
  it "should not raise an error if there is a problem getting the columns for a dataset" do
256
240
  def @model.columns() raise Sequel::Error end
257
- proc{@model.set_dataset(DB[:foo].join(:blah))}.should_not raise_error
241
+ @model.set_dataset(DB[:foo].join(:blah))
258
242
  end
259
243
 
260
244
  it "doesn't raise an error on set_dataset if there is an error raised getting the schema" do
261
245
  def @model.get_db_schema(*) raise Sequel::Error end
262
- proc{@model.set_dataset(DB[:foo])}.should_not raise_error
246
+ @model.set_dataset(DB[:foo])
247
+ end
248
+
249
+ it "reload_db_schema? should be false by default" do
250
+ c = Class.new
251
+ c.extend Sequel::Model::ClassMethods
252
+ c.send(:reload_db_schema?).must_equal false
263
253
  end
264
254
 
265
255
  it "doesn't raise an error on inherited if there is an error setting the dataset" do
266
256
  def @model.set_dataset(*) raise Sequel::Error end
267
- proc{Class.new(@model)}.should_not raise_error
257
+ Class.new(@model)
268
258
  end
269
259
 
270
260
  it "should raise if bad inherited instance variable value is used" do
271
261
  def @model.inherited_instance_variables() super.merge(:@a=>:foo) end
272
262
  @model.instance_eval{@a=1}
273
- proc{Class.new(@model)}.should raise_error(Sequel::Error)
263
+ proc{Class.new(@model)}.must_raise(Sequel::Error)
274
264
  end
275
265
 
276
266
  it "copy inherited instance variables into subclass if set" do
@@ -279,10 +269,10 @@ describe Sequel::Model do
279
269
  m = Class.new(@model)
280
270
  @model.instance_eval{@a=5; @b << 6; @c[3] << 7; @c[8] = [9]; @d=40}
281
271
  m.instance_eval do
282
- @a.should == 1
283
- @b.should == [2]
284
- @c.should == {3=>[4]}
285
- @d.should == 20
272
+ @a.must_equal 1
273
+ @b.must_equal [2]
274
+ @c.must_equal(3=>[4])
275
+ @d.must_equal 20
286
276
  end
287
277
  end
288
278
  end
@@ -295,38 +285,38 @@ describe Sequel::Model, "constructors" do
295
285
 
296
286
  it "should accept a hash" do
297
287
  m = @m.new(:a => 1, :b => 2)
298
- m.values.should == {:a => 1, :b => 2}
299
- m.should be_new
288
+ m.values.must_equal(:a => 1, :b => 2)
289
+ m.must_be :new?
300
290
  end
301
291
 
302
292
  it "should accept a block and yield itself to the block" do
303
293
  block_called = false
304
- m = @m.new {|i| block_called = true; i.should be_a_kind_of(@m); i.values[:a] = 1}
294
+ m = @m.new {|i| block_called = true; i.must_be_kind_of(@m); i.values[:a] = 1}
305
295
 
306
- block_called.should == true
307
- m.values[:a].should == 1
296
+ block_called.must_equal true
297
+ m.values[:a].must_equal 1
308
298
  end
309
299
 
310
300
  it "should have dataset row_proc create an existing object" do
311
301
  @m.dataset = Sequel.mock.dataset
312
302
  o = @m.dataset.row_proc.call(:a=>1)
313
- o.should be_a_kind_of(@m)
314
- o.values.should == {:a=>1}
315
- o.new?.should == false
303
+ o.must_be_kind_of(@m)
304
+ o.values.must_equal(:a=>1)
305
+ o.new?.must_equal false
316
306
  end
317
307
 
318
308
  it "should have .call create an existing object" do
319
309
  o = @m.call(:a=>1)
320
- o.should be_a_kind_of(@m)
321
- o.values.should == {:a=>1}
322
- o.new?.should == false
310
+ o.must_be_kind_of(@m)
311
+ o.values.must_equal(:a=>1)
312
+ o.new?.must_equal false
323
313
  end
324
314
 
325
315
  it "should have .load create an existing object" do
326
316
  o = @m.load(:a=>1)
327
- o.should be_a_kind_of(@m)
328
- o.values.should == {:a=>1}
329
- o.new?.should == false
317
+ o.must_be_kind_of(@m)
318
+ o.values.must_equal(:a=>1)
319
+ o.new?.must_equal false
330
320
  end
331
321
  end
332
322
 
@@ -340,14 +330,14 @@ describe Sequel::Model, "new" do
340
330
 
341
331
  it "should be marked as new?" do
342
332
  o = @m.new
343
- o.should be_new
333
+ o.must_be :new?
344
334
  end
345
335
 
346
336
  it "should not be marked as new? once it is saved" do
347
337
  o = @m.new(:x => 1)
348
- o.should be_new
338
+ o.must_be :new?
349
339
  o.save
350
- o.should_not be_new
340
+ o.wont_be :new?
351
341
  end
352
342
 
353
343
  it "should use the last inserted id as primary key if not in values" do
@@ -356,11 +346,11 @@ describe Sequel::Model, "new" do
356
346
 
357
347
  o = @m.new(:x => 1)
358
348
  o.save
359
- o.id.should == 1234
349
+ o.id.must_equal 1234
360
350
 
361
351
  o = @m.load(:x => 1, :id => 333)
362
352
  o.save
363
- o.id.should == 333
353
+ o.id.must_equal 333
364
354
  end
365
355
  end
366
356
 
@@ -370,27 +360,27 @@ describe Sequel::Model, ".subset" do
370
360
  DB.reset
371
361
  end
372
362
 
373
- specify "should create a filter on the underlying dataset" do
374
- proc {@c.new_only}.should raise_error(NoMethodError)
363
+ it "should create a filter on the underlying dataset" do
364
+ proc {@c.new_only}.must_raise(NoMethodError)
375
365
 
376
366
  @c.subset(:new_only){age < 'new'}
377
367
 
378
- @c.new_only.sql.should == "SELECT * FROM items WHERE (age < 'new')"
379
- @c.dataset.new_only.sql.should == "SELECT * FROM items WHERE (age < 'new')"
368
+ @c.new_only.sql.must_equal "SELECT * FROM items WHERE (age < 'new')"
369
+ @c.dataset.new_only.sql.must_equal "SELECT * FROM items WHERE (age < 'new')"
380
370
 
381
371
  @c.subset(:pricey){price > 100}
382
372
 
383
- @c.pricey.sql.should == "SELECT * FROM items WHERE (price > 100)"
384
- @c.dataset.pricey.sql.should == "SELECT * FROM items WHERE (price > 100)"
373
+ @c.pricey.sql.must_equal "SELECT * FROM items WHERE (price > 100)"
374
+ @c.dataset.pricey.sql.must_equal "SELECT * FROM items WHERE (price > 100)"
385
375
 
386
- @c.pricey.new_only.sql.should == "SELECT * FROM items WHERE ((price > 100) AND (age < 'new'))"
387
- @c.new_only.pricey.sql.should == "SELECT * FROM items WHERE ((age < 'new') AND (price > 100))"
376
+ @c.pricey.new_only.sql.must_equal "SELECT * FROM items WHERE ((price > 100) AND (age < 'new'))"
377
+ @c.new_only.pricey.sql.must_equal "SELECT * FROM items WHERE ((age < 'new') AND (price > 100))"
388
378
  end
389
379
 
390
- specify "should not override existing model methods" do
380
+ it "should not override existing model methods" do
391
381
  def @c.active() true end
392
382
  @c.subset(:active, :active)
393
- @c.active.should == true
383
+ @c.active.must_equal true
394
384
  end
395
385
  end
396
386
 
@@ -402,19 +392,19 @@ describe Sequel::Model, ".find" do
402
392
  end
403
393
 
404
394
  it "should return the first record matching the given filter" do
405
- @c.find(:name => 'sharon').should be_a_kind_of(@c)
406
- DB.sqls.should == ["SELECT * FROM items WHERE (name = 'sharon') LIMIT 1"]
395
+ @c.find(:name => 'sharon').must_be_kind_of(@c)
396
+ DB.sqls.must_equal ["SELECT * FROM items WHERE (name = 'sharon') LIMIT 1"]
407
397
 
408
- @c.find(Sequel.expr(:name).like('abc%')).should be_a_kind_of(@c)
409
- DB.sqls.should == ["SELECT * FROM items WHERE (name LIKE 'abc%' ESCAPE '\\') LIMIT 1"]
398
+ @c.find(Sequel.expr(:name).like('abc%')).must_be_kind_of(@c)
399
+ DB.sqls.must_equal ["SELECT * FROM items WHERE (name LIKE 'abc%' ESCAPE '\\') LIMIT 1"]
410
400
  end
411
401
 
412
- specify "should accept filter blocks" do
413
- @c.find{id > 1}.should be_a_kind_of(@c)
414
- DB.sqls.should == ["SELECT * FROM items WHERE (id > 1) LIMIT 1"]
402
+ it "should accept filter blocks" do
403
+ @c.find{id > 1}.must_be_kind_of(@c)
404
+ DB.sqls.must_equal ["SELECT * FROM items WHERE (id > 1) LIMIT 1"]
415
405
 
416
- @c.find{(x > 1) & (y < 2)}.should be_a_kind_of(@c)
417
- DB.sqls.should == ["SELECT * FROM items WHERE ((x > 1) AND (y < 2)) LIMIT 1"]
406
+ @c.find{(x > 1) & (y < 2)}.must_be_kind_of(@c)
407
+ DB.sqls.must_equal ["SELECT * FROM items WHERE ((x > 1) AND (y < 2)) LIMIT 1"]
418
408
  end
419
409
  end
420
410
 
@@ -432,71 +422,71 @@ describe Sequel::Model, ".finder" do
432
422
  @db.sqls
433
423
  end
434
424
 
435
- specify "should create a method that calls the method given and returns the first instance" do
425
+ it "should create a method that calls the method given and returns the first instance" do
436
426
  @c.finder :foo
437
- @c.first_foo(1, 2).should == @o
438
- @c.first_foo(3, 4).should == @o
439
- @db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1"]
427
+ @c.first_foo(1, 2).must_equal @o
428
+ @c.first_foo(3, 4).must_equal @o
429
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1"]
440
430
  end
441
431
 
442
- specify "should work correctly when subclassing" do
432
+ it "should work correctly when subclassing" do
443
433
  @c.finder(:foo)
444
434
  @sc = Class.new(@c)
445
435
  @sc.set_dataset :foos
446
436
  @db.sqls
447
- @sc.first_foo(1, 2).should == @sc.load(@h)
448
- @sc.first_foo(3, 4).should == @sc.load(@h)
449
- @db.sqls.should == ["SELECT * FROM foos WHERE (bar = 1) ORDER BY 2 LIMIT 1", "SELECT * FROM foos WHERE (bar = 3) ORDER BY 4 LIMIT 1"]
437
+ @sc.first_foo(1, 2).must_equal @sc.load(@h)
438
+ @sc.first_foo(3, 4).must_equal @sc.load(@h)
439
+ @db.sqls.must_equal ["SELECT * FROM foos WHERE (bar = 1) ORDER BY 2 LIMIT 1", "SELECT * FROM foos WHERE (bar = 3) ORDER BY 4 LIMIT 1"]
450
440
  end
451
441
 
452
- specify "should work correctly when dataset is modified" do
442
+ it "should work correctly when dataset is modified" do
453
443
  @c.finder(:foo)
454
- @c.first_foo(1, 2).should == @o
444
+ @c.first_foo(1, 2).must_equal @o
455
445
  @c.set_dataset :foos
456
- @c.first_foo(3, 4).should == @o
457
- @db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1", "SELECT * FROM foos LIMIT 1", "SELECT * FROM foos WHERE (bar = 3) ORDER BY 4 LIMIT 1"]
446
+ @c.first_foo(3, 4).must_equal @o
447
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1", "SELECT * FROM foos LIMIT 1", "SELECT * FROM foos WHERE (bar = 3) ORDER BY 4 LIMIT 1"]
458
448
  end
459
449
 
460
- specify "should create a method based on the given block if no method symbol provided" do
450
+ it "should create a method based on the given block if no method symbol provided" do
461
451
  @c.finder(:name=>:first_foo){|pl, ds| ds.where(pl.arg).limit(1)}
462
- @c.first_foo(:id=>1).should == @o
463
- @db.sqls.should == ["SELECT * FROM items WHERE (id = 1) LIMIT 1"]
452
+ @c.first_foo(:id=>1).must_equal @o
453
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (id = 1) LIMIT 1"]
464
454
  end
465
455
 
466
- specify "should raise an error if both a block and method symbol given" do
467
- proc{@c.finder(:foo, :name=>:first_foo){|pl, ds| ds.where(pl.arg)}}.should raise_error(Sequel::Error)
456
+ it "should raise an error if both a block and method symbol given" do
457
+ proc{@c.finder(:foo, :name=>:first_foo){|pl, ds| ds.where(pl.arg)}}.must_raise(Sequel::Error)
468
458
  end
469
459
 
470
- specify "should raise an error if two option hashes are provided" do
471
- proc{@c.finder({:name2=>:foo}, :name=>:first_foo){|pl, ds| ds.where(pl.arg)}}.should raise_error(Sequel::Error)
460
+ it "should raise an error if two option hashes are provided" do
461
+ proc{@c.finder({:name2=>:foo}, :name=>:first_foo){|pl, ds| ds.where(pl.arg)}}.must_raise(Sequel::Error)
472
462
  end
473
463
 
474
- specify "should support :type option" do
464
+ it "should support :type option" do
475
465
  @c.finder :foo, :type=>:all
476
466
  @c.finder :foo, :type=>:each
477
467
  @c.finder :foo, :type=>:get
478
468
 
479
469
  a = []
480
- @c.all_foo(1, 2){|r| a << r}.should == [@o]
481
- a.should == [@o]
470
+ @c.all_foo(1, 2){|r| a << r}.must_equal [@o]
471
+ a.must_equal [@o]
482
472
 
483
473
  a = []
484
474
  @c.each_foo(3, 4){|r| a << r}
485
- a.should == [@o]
475
+ a.must_equal [@o]
486
476
 
487
- @c.get_foo(5, 6).should == [:id, 1]
477
+ @c.get_foo(5, 6).must_equal [:id, 1]
488
478
 
489
- @db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4", "SELECT * FROM items WHERE (bar = 5) ORDER BY 6 LIMIT 1"]
479
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4", "SELECT * FROM items WHERE (bar = 5) ORDER BY 6 LIMIT 1"]
490
480
  end
491
481
 
492
- specify "should support :name option" do
482
+ it "should support :name option" do
493
483
  @c.finder :foo, :name=>:find_foo
494
- @c.find_foo(1, 2).should == @o
495
- @c.find_foo(3, 4).should == @o
496
- @db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1"]
484
+ @c.find_foo(1, 2).must_equal @o
485
+ @c.find_foo(3, 4).must_equal @o
486
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1"]
497
487
  end
498
488
 
499
- specify "should support :arity option" do
489
+ it "should support :arity option" do
500
490
  def @c.foobar(*b)
501
491
  ds = dataset
502
492
  b.each_with_index do |a, i|
@@ -508,23 +498,23 @@ describe Sequel::Model, ".finder" do
508
498
  @c.finder :foobar, :arity=>2, :name=>:find_foobar_2
509
499
  @c.find_foobar_1(:a)
510
500
  @c.find_foobar_2(:a, :b)
511
- @db.sqls.should == ["SELECT * FROM items WHERE (0 = a) LIMIT 1", "SELECT * FROM items WHERE ((0 = a) AND (1 = b)) LIMIT 1"]
501
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (0 = a) LIMIT 1", "SELECT * FROM items WHERE ((0 = a) AND (1 = b)) LIMIT 1"]
512
502
  end
513
503
 
514
- specify "should support :mod option" do
504
+ it "should support :mod option" do
515
505
  m = Module.new
516
506
  @c.finder :foo, :mod=>m
517
- proc{@c.first_foo}.should raise_error
507
+ proc{@c.first_foo}.must_raise NoMethodError
518
508
  @c.extend m
519
- @c.first_foo(1, 2).should == @o
520
- @c.first_foo(3, 4).should == @o
521
- @db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1"]
509
+ @c.first_foo(1, 2).must_equal @o
510
+ @c.first_foo(3, 4).must_equal @o
511
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1"]
522
512
  end
523
513
 
524
- specify "should raise error when calling with the wrong arity" do
514
+ it "should raise error when calling with the wrong arity" do
525
515
  @c.finder :foo
526
- proc{@c.first_foo(1)}.should raise_error
527
- proc{@c.first_foo(1,2,3)}.should raise_error
516
+ proc{@c.first_foo(1)}.must_raise Sequel::Error
517
+ proc{@c.first_foo(1,2,3)}.must_raise Sequel::Error
528
518
  end
529
519
  end
530
520
 
@@ -549,68 +539,68 @@ describe Sequel::Model, ".prepared_finder" do
549
539
  @db.sqls
550
540
  end
551
541
 
552
- specify "should create a method that calls the method given and returns the first instance" do
542
+ it "should create a method that calls the method given and returns the first instance" do
553
543
  @c.prepared_finder :foo
554
- @c.first_foo(1, 2).should == @o
555
- @c.first_foo(3, 4).should == @o
556
- @db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
544
+ @c.first_foo(1, 2).must_equal @o
545
+ @c.first_foo(3, 4).must_equal @o
546
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
557
547
  end
558
548
 
559
- specify "should work correctly when subclassing" do
549
+ it "should work correctly when subclassing" do
560
550
  @c.prepared_finder(:foo)
561
551
  @sc = Class.new(@c)
562
552
  @sc.set_dataset :foos
563
553
  @db.sqls
564
- @sc.first_foo(1, 2).should == @sc.load(@h)
565
- @sc.first_foo(3, 4).should == @sc.load(@h)
566
- @db.sqls.should == ["SELECT * FROM foos WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM foos WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
554
+ @sc.first_foo(1, 2).must_equal @sc.load(@h)
555
+ @sc.first_foo(3, 4).must_equal @sc.load(@h)
556
+ @db.sqls.must_equal ["SELECT * FROM foos WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM foos WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
567
557
  end
568
558
 
569
- specify "should work correctly when dataset is modified" do
559
+ it "should work correctly when dataset is modified" do
570
560
  @c.prepared_finder(:foo)
571
- @c.first_foo(1, 2).should == @o
561
+ @c.first_foo(1, 2).must_equal @o
572
562
  @c.set_dataset :foos
573
- @c.first_foo(3, 4).should == @o
574
- @db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM foos LIMIT 1", "SELECT * FROM foos WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
563
+ @c.first_foo(3, 4).must_equal @o
564
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM foos LIMIT 1", "SELECT * FROM foos WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
575
565
  end
576
566
 
577
- specify "should create a method based on the given block if no method symbol provided" do
567
+ it "should create a method based on the given block if no method symbol provided" do
578
568
  @c.prepared_finder(:name=>:first_foo){|a1| where(:id=>a1).limit(1)}
579
- @c.first_foo(1).should == @o
580
- @db.sqls.should == ["SELECT * FROM items WHERE (id = 1) LIMIT 1 -- prepared"]
569
+ @c.first_foo(1).must_equal @o
570
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (id = 1) LIMIT 1 -- prepared"]
581
571
  end
582
572
 
583
- specify "should raise an error if both a block and method symbol given" do
584
- proc{@c.prepared_finder(:foo, :name=>:first_foo){|pl, ds| ds.where(pl.arg)}}.should raise_error(Sequel::Error)
573
+ it "should raise an error if both a block and method symbol given" do
574
+ proc{@c.prepared_finder(:foo, :name=>:first_foo){|pl, ds| ds.where(pl.arg)}}.must_raise(Sequel::Error)
585
575
  end
586
576
 
587
- specify "should raise an error if two option hashes are provided" do
588
- proc{@c.prepared_finder({:name2=>:foo}, :name=>:first_foo){|pl, ds| ds.where(pl.arg)}}.should raise_error(Sequel::Error)
577
+ it "should raise an error if two option hashes are provided" do
578
+ proc{@c.prepared_finder({:name2=>:foo}, :name=>:first_foo){|pl, ds| ds.where(pl.arg)}}.must_raise(Sequel::Error)
589
579
  end
590
580
 
591
- specify "should support :type option" do
581
+ it "should support :type option" do
592
582
  @c.prepared_finder :foo, :type=>:all
593
583
  @c.prepared_finder :foo, :type=>:each
594
584
 
595
585
  a = []
596
- @c.all_foo(1, 2){|r| a << r}.should == [@o]
597
- a.should == [@o]
586
+ @c.all_foo(1, 2){|r| a << r}.must_equal [@o]
587
+ a.must_equal [@o]
598
588
 
599
589
  a = []
600
590
  @c.each_foo(3, 4){|r| a << r}
601
- a.should == [@o]
591
+ a.must_equal [@o]
602
592
 
603
- @db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 -- prepared", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 -- prepared"]
593
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 -- prepared", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 -- prepared"]
604
594
  end
605
595
 
606
- specify "should support :name option" do
596
+ it "should support :name option" do
607
597
  @c.prepared_finder :foo, :name=>:find_foo
608
- @c.find_foo(1, 2).should == @o
609
- @c.find_foo(3, 4).should == @o
610
- @db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
598
+ @c.find_foo(1, 2).must_equal @o
599
+ @c.find_foo(3, 4).must_equal @o
600
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
611
601
  end
612
602
 
613
- specify "should support :arity option" do
603
+ it "should support :arity option" do
614
604
  def @c.foobar(*b)
615
605
  ds = dataset
616
606
  b.each_with_index do |a, i|
@@ -622,24 +612,24 @@ describe Sequel::Model, ".prepared_finder" do
622
612
  @c.prepared_finder :foobar, :arity=>2, :name=>:find_foobar_2
623
613
  @c.find_foobar_1(:a)
624
614
  @c.find_foobar_2(:a, :b)
625
- @db.sqls.should == ["SELECT * FROM items WHERE (0 = a) LIMIT 1 -- prepared", "SELECT * FROM items WHERE ((0 = a) AND (1 = b)) LIMIT 1 -- prepared"]
615
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (0 = a) LIMIT 1 -- prepared", "SELECT * FROM items WHERE ((0 = a) AND (1 = b)) LIMIT 1 -- prepared"]
626
616
  end
627
617
 
628
- specify "should support :mod option" do
618
+ it "should support :mod option" do
629
619
  m = Module.new
630
620
  @c.prepared_finder :foo, :mod=>m
631
- proc{@c.first_foo}.should raise_error
621
+ proc{@c.first_foo}.must_raise NoMethodError
632
622
  @c.extend m
633
- @c.first_foo(1, 2).should == @o
634
- @c.first_foo(3, 4).should == @o
635
- @db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
623
+ @c.first_foo(1, 2).must_equal @o
624
+ @c.first_foo(3, 4).must_equal @o
625
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared", "SELECT * FROM items WHERE (bar = 3) ORDER BY 4 LIMIT 1 -- prepared"]
636
626
  end
637
627
 
638
- specify "should handle models with names" do
628
+ it "should handle models with names" do
639
629
  def @c.name; 'foobar' end
640
630
  @c.prepared_finder :foo
641
- @c.first_foo(1, 2).should == @o
642
- @db.sqls.should == ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared"]
631
+ @c.first_foo(1, 2).must_equal @o
632
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (bar = 1) ORDER BY 2 LIMIT 1 -- prepared"]
643
633
  end
644
634
  end
645
635
 
@@ -650,13 +640,13 @@ describe Sequel::Model, ".fetch" do
650
640
  end
651
641
 
652
642
  it "should return instances of Model" do
653
- @c.fetch("SELECT * FROM items").first.should be_a_kind_of(@c)
643
+ @c.fetch("SELECT * FROM items").first.must_be_kind_of(@c)
654
644
  end
655
645
 
656
646
  it "should return true for .empty? and not raise an error on empty selection" do
657
647
  rows = @c.fetch("SELECT * FROM items WHERE FALSE")
658
648
  @c.send(:define_method, :fetch_rows){|sql| yield({:count => 0})}
659
- proc {rows.empty?}.should_not raise_error
649
+ rows.empty?
660
650
  end
661
651
  end
662
652
 
@@ -673,15 +663,15 @@ describe Sequel::Model, ".find_or_create" do
673
663
  it "should find the record" do
674
664
  @db.fetch = [{:x=>1, :id=>1}]
675
665
  @db.autoid = 1
676
- @c.find_or_create(:x => 1).should == @c.load(:x=>1, :id=>1)
677
- @db.sqls.should == ["SELECT * FROM items WHERE (x = 1) LIMIT 1"]
666
+ @c.find_or_create(:x => 1).must_equal @c.load(:x=>1, :id=>1)
667
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (x = 1) LIMIT 1"]
678
668
  end
679
669
 
680
670
  it "should create the record if not found" do
681
671
  @db.fetch = [[], {:x=>1, :id=>1}]
682
672
  @db.autoid = 1
683
- @c.find_or_create(:x => 1).should == @c.load(:x=>1, :id=>1)
684
- @db.sqls.should == ["SELECT * FROM items WHERE (x = 1) LIMIT 1",
673
+ @c.find_or_create(:x => 1).must_equal @c.load(:x=>1, :id=>1)
674
+ @db.sqls.must_equal ["SELECT * FROM items WHERE (x = 1) LIMIT 1",
685
675
  "INSERT INTO items (x) VALUES (1)",
686
676
  "SELECT * FROM items WHERE (id = 1) LIMIT 1"]
687
677
  end
@@ -689,18 +679,18 @@ describe Sequel::Model, ".find_or_create" do
689
679
  it "should pass the new record to be created to the block if no record is found" do
690
680
  @db.fetch = [[], {:x=>1, :id=>1}]
691
681
  @db.autoid = 1
692
- @c.find_or_create(:x => 1){|x| x[:y] = 2}.should == @c.load(:x=>1, :id=>1)
682
+ @c.find_or_create(:x => 1){|x| x[:y] = 2}.must_equal @c.load(:x=>1, :id=>1)
693
683
  sqls = @db.sqls
694
- sqls.first.should == "SELECT * FROM items WHERE (x = 1) LIMIT 1"
695
- ["INSERT INTO items (x, y) VALUES (1, 2)", "INSERT INTO items (y, x) VALUES (2, 1)"].should include(sqls[1])
696
- sqls.last.should == "SELECT * FROM items WHERE (id = 1) LIMIT 1"
684
+ sqls.first.must_equal "SELECT * FROM items WHERE (x = 1) LIMIT 1"
685
+ ["INSERT INTO items (x, y) VALUES (1, 2)", "INSERT INTO items (y, x) VALUES (2, 1)"].must_include(sqls[1])
686
+ sqls.last.must_equal "SELECT * FROM items WHERE (id = 1) LIMIT 1"
697
687
  end
698
688
  end
699
689
 
700
690
  describe Sequel::Model, ".all" do
701
691
  it "should return all records in the dataset" do
702
692
  c = Class.new(Sequel::Model(:items))
703
- c.all.should == [c.load(:x=>1, :id=>1)]
693
+ c.all.must_equal [c.load(:x=>1, :id=>1)]
704
694
  end
705
695
  end
706
696
 
@@ -715,26 +705,26 @@ describe Sequel::Model, "A model class without a primary key" do
715
705
 
716
706
  it "should be able to insert records without selecting them back" do
717
707
  i = nil
718
- proc {i = @c.create(:x => 1)}.should_not raise_error
719
- i.class.should be(@c)
720
- i.values.to_hash.should == {:x => 1}
708
+ i = @c.create(:x => 1)
709
+ i.class.wont_be_nil
710
+ i.values.to_hash.must_equal(:x => 1)
721
711
 
722
- DB.sqls.should == ['INSERT INTO items (x) VALUES (1)']
712
+ DB.sqls.must_equal ['INSERT INTO items (x) VALUES (1)']
723
713
  end
724
714
 
725
715
  it "should raise when deleting" do
726
- proc{@c.load(:x=>1).delete}.should raise_error
716
+ proc{@c.load(:x=>1).delete}.must_raise Sequel::Error
727
717
  end
728
718
 
729
719
  it "should raise when updating" do
730
- proc{@c.load(:x=>1).update(:x=>2)}.should raise_error
720
+ proc{@c.load(:x=>1).update(:x=>2)}.must_raise Sequel::Error
731
721
  end
732
722
 
733
723
  it "should insert a record when saving" do
734
724
  o = @c.new(:x => 2)
735
- o.should be_new
725
+ o.must_be :new?
736
726
  o.save
737
- DB.sqls.should == ['INSERT INTO items (x) VALUES (2)']
727
+ DB.sqls.must_equal ['INSERT INTO items (x) VALUES (2)']
738
728
  end
739
729
  end
740
730
 
@@ -752,20 +742,20 @@ describe Sequel::Model, "attribute accessors" do
752
742
 
753
743
  it "should be created on set_dataset" do
754
744
  %w'x z x= z='.each do |x|
755
- @c.instance_methods.collect{|z| z.to_s}.should_not include(x)
745
+ @c.instance_methods.collect{|z| z.to_s}.wont_include(x)
756
746
  end
757
747
  @c.set_dataset(@dataset)
758
748
  %w'x z x= z='.each do |x|
759
- @c.instance_methods.collect{|z| z.to_s}.should include(x)
749
+ @c.instance_methods.collect{|z| z.to_s}.must_include(x)
760
750
  end
761
751
  o = @c.new
762
752
  %w'x z x= z='.each do |x|
763
- o.methods.collect{|z| z.to_s}.should include(x)
753
+ o.methods.collect{|z| z.to_s}.must_include(x)
764
754
  end
765
755
 
766
- o.x.should be_nil
756
+ o.x.must_equal nil
767
757
  o.x = 34
768
- o.x.should == 34
758
+ o.x.must_equal 34
769
759
  end
770
760
 
771
761
  it "should be only accept one argument for the write accessor" do
@@ -773,9 +763,9 @@ describe Sequel::Model, "attribute accessors" do
773
763
  o = @c.new
774
764
 
775
765
  o.x = 34
776
- o.x.should == 34
777
- proc{o.send(:x=)}.should raise_error
778
- proc{o.send(:x=, 3, 4)}.should raise_error
766
+ o.x.must_equal 34
767
+ proc{o.send(:x=)}.must_raise ArgumentError
768
+ proc{o.send(:x=, 3, 4)}.must_raise ArgumentError
779
769
  end
780
770
 
781
771
  it "should have a working typecasting setter even if the column is not selected" do
@@ -783,7 +773,7 @@ describe Sequel::Model, "attribute accessors" do
783
773
  o = @c.new
784
774
 
785
775
  o.x = '34'
786
- o.x.should == 34
776
+ o.x.must_equal 34
787
777
  end
788
778
 
789
779
  it "should typecast if the new value is the same as the existing but has a different class" do
@@ -792,9 +782,9 @@ describe Sequel::Model, "attribute accessors" do
792
782
 
793
783
  o.x = 34
794
784
  o.x = 34.0
795
- o.x.should == 34.0
785
+ o.x.must_equal 34.0
796
786
  o.x = 34
797
- o.x.should == 34
787
+ o.x.must_equal 34
798
788
  end
799
789
  end
800
790
 
@@ -806,42 +796,42 @@ describe Sequel::Model, ".[]" do
806
796
  end
807
797
 
808
798
  it "should return the first record for the given pk" do
809
- @c[1].should == @c.load(:name => 'sharon', :id => 1)
810
- DB.sqls.should == ["SELECT * FROM items WHERE id = 1"]
811
- @c[9999].should == @c.load(:name => 'sharon', :id => 1)
812
- DB.sqls.should == ["SELECT * FROM items WHERE id = 9999"]
799
+ @c[1].must_equal @c.load(:name => 'sharon', :id => 1)
800
+ DB.sqls.must_equal ["SELECT * FROM items WHERE id = 1"]
801
+ @c[9999].must_equal @c.load(:name => 'sharon', :id => 1)
802
+ DB.sqls.must_equal ["SELECT * FROM items WHERE id = 9999"]
813
803
  end
814
804
 
815
805
  it "should have #[] return nil if no rows match" do
816
806
  @c.dataset._fetch = []
817
- @c[1].should == nil
818
- DB.sqls.should == ["SELECT * FROM items WHERE id = 1"]
807
+ @c[1].must_equal nil
808
+ DB.sqls.must_equal ["SELECT * FROM items WHERE id = 1"]
819
809
  end
820
810
 
821
811
  it "should work correctly for custom primary key" do
822
812
  @c.set_primary_key :name
823
- @c['sharon'].should == @c.load(:name => 'sharon', :id => 1)
824
- DB.sqls.should == ["SELECT * FROM items WHERE name = 'sharon'"]
813
+ @c['sharon'].must_equal @c.load(:name => 'sharon', :id => 1)
814
+ DB.sqls.must_equal ["SELECT * FROM items WHERE name = 'sharon'"]
825
815
  end
826
816
 
827
817
  it "should use a qualified primary key if the dataset is joined" do
828
818
  @c.dataset = @c.dataset.cross_join(:a)
829
- @c[1].should == @c.load(:name => 'sharon', :id => 1)
830
- DB.sqls.should == ["SELECT * FROM items CROSS JOIN a WHERE (items.id = 1) LIMIT 1"]
819
+ @c[1].must_equal @c.load(:name => 'sharon', :id => 1)
820
+ DB.sqls.must_equal ["SELECT * FROM items CROSS JOIN a WHERE (items.id = 1) LIMIT 1"]
831
821
  end
832
822
 
833
823
  it "should work correctly for composite primary key specified as array" do
834
824
  @c.set_primary_key [:node_id, :kind]
835
- @c[3921, 201].should be_a_kind_of(@c)
825
+ @c[3921, 201].must_be_kind_of(@c)
836
826
  sqls = DB.sqls
837
- sqls.length.should == 1
838
- sqls.first.should =~ /^SELECT \* FROM items WHERE \((\(node_id = 3921\) AND \(kind = 201\))|(\(kind = 201\) AND \(node_id = 3921\))\) LIMIT 1$/
827
+ sqls.length.must_equal 1
828
+ sqls.first.must_match(/^SELECT \* FROM items WHERE \((\(node_id = 3921\) AND \(kind = 201\))|(\(kind = 201\) AND \(node_id = 3921\))\) LIMIT 1$/)
839
829
  end
840
830
  end
841
831
 
842
832
  describe "Model#inspect" do
843
- specify "should include the class name and the values" do
844
- Sequel::Model.load(:x => 333).inspect.should == '#<Sequel::Model @values={:x=>333}>'
833
+ it "should include the class name and the values" do
834
+ Sequel::Model.load(:x => 333).inspect.must_equal '#<Sequel::Model @values={:x=>333}>'
845
835
  end
846
836
  end
847
837
 
@@ -855,7 +845,7 @@ describe "Model.db_schema" do
855
845
  @dataset = @db[:items]
856
846
  end
857
847
 
858
- specify "should not call database's schema if it isn't supported" do
848
+ it "should not call database's schema if it isn't supported" do
859
849
  def @db.supports_schema_parsing?() false end
860
850
  def @db.schema(table, opts = {})
861
851
  raise Sequel::Error
@@ -863,105 +853,105 @@ describe "Model.db_schema" do
863
853
  @dataset.instance_variable_set(:@columns, [:x, :y])
864
854
 
865
855
  @c.dataset = @dataset
866
- @c.db_schema.should == {:x=>{}, :y=>{}}
867
- @c.columns.should == [:x, :y]
868
- @c.dataset.instance_variable_get(:@columns).should == [:x, :y]
856
+ @c.db_schema.must_equal(:x=>{}, :y=>{})
857
+ @c.columns.must_equal [:x, :y]
858
+ @c.dataset.instance_variable_get(:@columns).must_equal [:x, :y]
869
859
  end
870
860
 
871
- specify "should use the database's schema and set the columns and dataset columns" do
861
+ it "should use the database's schema and set the columns and dataset columns" do
872
862
  def @db.schema(table, opts = {})
873
863
  [[:x, {:type=>:integer}], [:y, {:type=>:string}]]
874
864
  end
875
865
  @c.dataset = @dataset
876
- @c.db_schema.should == {:x=>{:type=>:integer}, :y=>{:type=>:string}}
877
- @c.columns.should == [:x, :y]
878
- @c.dataset.instance_variable_get(:@columns).should == [:x, :y]
866
+ @c.db_schema.must_equal(:x=>{:type=>:integer}, :y=>{:type=>:string})
867
+ @c.columns.must_equal [:x, :y]
868
+ @c.dataset.instance_variable_get(:@columns).must_equal [:x, :y]
879
869
  end
880
870
 
881
- specify "should not restrict the schema for datasets with a :select option" do
871
+ it "should not restrict the schema for datasets with a :select option" do
882
872
  def @c.columns; [:x, :z]; end
883
873
  def @db.schema(table, opts = {})
884
874
  [[:x, {:type=>:integer}], [:y, {:type=>:string}]]
885
875
  end
886
876
  @c.dataset = @dataset.select(:x, :y___z)
887
- @c.db_schema.should == {:x=>{:type=>:integer}, :z=>{}, :y=>{:type=>:string}}
877
+ @c.db_schema.must_equal(:x=>{:type=>:integer}, :z=>{}, :y=>{:type=>:string})
888
878
  end
889
879
 
890
- specify "should fallback to fetching records if schema raises an error" do
880
+ it "should fallback to fetching records if schema raises an error" do
891
881
  def @db.schema(table, opts={})
892
882
  raise Sequel::Error
893
883
  end
894
884
  @c.dataset = @dataset.join(:x, :id).columns(:id, :x)
895
- @c.db_schema.should == {:x=>{}, :id=>{}}
885
+ @c.db_schema.must_equal(:x=>{}, :id=>{})
896
886
  end
897
887
 
898
- specify "should automatically set a singular primary key based on the schema" do
888
+ it "should automatically set a singular primary key based on the schema" do
899
889
  ds = @dataset
900
890
  d = ds.db
901
891
  def d.schema(table, *opts) [[:x, {:primary_key=>true}]] end
902
- @c.primary_key.should == :id
892
+ @c.primary_key.must_equal :id
903
893
  @c.dataset = ds
904
- @c.db_schema.should == {:x=>{:primary_key=>true}}
905
- @c.primary_key.should == :x
894
+ @c.db_schema.must_equal(:x=>{:primary_key=>true})
895
+ @c.primary_key.must_equal :x
906
896
  end
907
897
 
908
- specify "should automatically set a singular primary key even if there are specific columns selected" do
898
+ it "should automatically set a singular primary key even if there are specific columns selected" do
909
899
  ds = @dataset.select(:a, :b, :x)
910
900
  d = ds.db
911
901
  def d.schema(table, *opts) [[:a, {:primary_key=>false}], [:b, {:primary_key=>false}], [:x, {:primary_key=>true}]] end
912
- @c.primary_key.should == :id
902
+ @c.primary_key.must_equal :id
913
903
  @c.dataset = ds
914
- @c.db_schema.should == {:a=>{:primary_key=>false}, :b=>{:primary_key=>false}, :x=>{:primary_key=>true}}
915
- @c.primary_key.should == :x
904
+ @c.db_schema.must_equal(:a=>{:primary_key=>false}, :b=>{:primary_key=>false}, :x=>{:primary_key=>true})
905
+ @c.primary_key.must_equal :x
916
906
  end
917
907
 
918
- specify "should automatically set the composite primary key based on the schema" do
908
+ it "should automatically set the composite primary key based on the schema" do
919
909
  ds = @dataset
920
910
  d = ds.db
921
911
  def d.schema(table, *opts) [[:x, {:primary_key=>true}], [:y, {:primary_key=>true}]] end
922
- @c.primary_key.should == :id
912
+ @c.primary_key.must_equal :id
923
913
  @c.dataset = ds
924
- @c.db_schema.should == {:x=>{:primary_key=>true}, :y=>{:primary_key=>true}}
925
- @c.primary_key.should == [:x, :y]
914
+ @c.db_schema.must_equal(:x=>{:primary_key=>true}, :y=>{:primary_key=>true})
915
+ @c.primary_key.must_equal [:x, :y]
926
916
  end
927
917
 
928
- specify "should set an immutable composite primary key based on the schema" do
918
+ it "should set an immutable composite primary key based on the schema" do
929
919
  ds = @dataset
930
920
  d = ds.db
931
921
  def d.schema(table, *opts) [[:x, {:primary_key=>true}], [:y, {:primary_key=>true}]] end
932
922
  @c.dataset = ds
933
- @c.primary_key.should == [:x, :y]
934
- proc{@c.primary_key.pop}.should raise_error
923
+ @c.primary_key.must_equal [:x, :y]
924
+ proc{@c.primary_key.pop}.must_raise
935
925
  end
936
926
 
937
- specify "should automatically set no primary key based on the schema" do
927
+ it "should automatically set no primary key based on the schema" do
938
928
  ds = @dataset
939
929
  d = ds.db
940
930
  def d.schema(table, *opts) [[:x, {:primary_key=>false}], [:y, {:primary_key=>false}]] end
941
- @c.primary_key.should == :id
931
+ @c.primary_key.must_equal :id
942
932
  @c.dataset = ds
943
- @c.db_schema.should == {:x=>{:primary_key=>false}, :y=>{:primary_key=>false}}
944
- @c.primary_key.should == nil
933
+ @c.db_schema.must_equal(:x=>{:primary_key=>false}, :y=>{:primary_key=>false})
934
+ @c.primary_key.must_equal nil
945
935
  end
946
936
 
947
- specify "should automatically set primary key for dataset selecting table.*" do
937
+ it "should automatically set primary key for dataset selecting table.*" do
948
938
  ds = @dataset.select_all(:items)
949
939
  d = ds.db
950
940
  def d.schema(table, *opts) [[:x, {:primary_key=>true}]] end
951
- @c.primary_key.should == :id
941
+ @c.primary_key.must_equal :id
952
942
  @c.dataset = ds
953
- @c.db_schema.should == {:x=>{:primary_key=>true}}
954
- @c.primary_key.should == :x
943
+ @c.db_schema.must_equal(:x=>{:primary_key=>true})
944
+ @c.primary_key.must_equal :x
955
945
  end
956
946
 
957
- specify "should not modify the primary key unless all column schema hashes have a :primary_key entry" do
947
+ it "should not modify the primary key unless all column schema hashes have a :primary_key entry" do
958
948
  ds = @dataset
959
949
  d = ds.db
960
950
  def d.schema(table, *opts) [[:x, {:primary_key=>false}], [:y, {}]] end
961
- @c.primary_key.should == :id
951
+ @c.primary_key.must_equal :id
962
952
  @c.dataset = ds
963
- @c.db_schema.should == {:x=>{:primary_key=>false}, :y=>{}}
964
- @c.primary_key.should == :id
953
+ @c.db_schema.must_equal(:x=>{:primary_key=>false}, :y=>{})
954
+ @c.primary_key.must_equal :id
965
955
  end
966
956
  end
967
957
 
@@ -970,23 +960,23 @@ describe "Model#use_transactions" do
970
960
  @c = Class.new(Sequel::Model(:items))
971
961
  end
972
962
 
973
- specify "should return class value by default" do
963
+ it "should return class value by default" do
974
964
  @c.use_transactions = true
975
- @c.new.use_transactions.should == true
965
+ @c.new.use_transactions.must_equal true
976
966
  @c.use_transactions = false
977
- @c.new.use_transactions.should == false
967
+ @c.new.use_transactions.must_equal false
978
968
  end
979
969
 
980
- specify "should return set value if manually set" do
970
+ it "should return set value if manually set" do
981
971
  instance = @c.new
982
972
  instance.use_transactions = false
983
- instance.use_transactions.should == false
973
+ instance.use_transactions.must_equal false
984
974
  @c.use_transactions = true
985
- instance.use_transactions.should == false
975
+ instance.use_transactions.must_equal false
986
976
 
987
977
  instance.use_transactions = true
988
- instance.use_transactions.should == true
978
+ instance.use_transactions.must_equal true
989
979
  @c.use_transactions = false
990
- instance.use_transactions.should == true
980
+ instance.use_transactions.must_equal true
991
981
  end
992
982
  end