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
@@ -10,230 +10,235 @@ describe "A new Database" do
10
10
  Sequel.identifier_output_method = nil
11
11
  end
12
12
 
13
- specify "should receive options" do
14
- @db.opts[1].should == 2
15
- @db.opts[:logger].should == 3
13
+ it "should receive options" do
14
+ @db.opts[1].must_equal 2
15
+ @db.opts[:logger].must_equal 3
16
16
  end
17
17
 
18
- specify "should set the logger from opts[:logger] and opts[:loggers]" do
19
- @db.loggers.should == [3]
20
- Sequel::Database.new(1 => 2, :loggers => 3).loggers.should == [3]
21
- Sequel::Database.new(1 => 2, :loggers => [3]).loggers.should == [3]
22
- Sequel::Database.new(1 => 2, :logger => 4, :loggers => 3).loggers.should == [4,3]
23
- Sequel::Database.new(1 => 2, :logger => [4], :loggers => [3]).loggers.should == [4,3]
18
+ it "should set the logger from opts[:logger] and opts[:loggers]" do
19
+ @db.loggers.must_equal [3]
20
+ Sequel::Database.new(1 => 2, :loggers => 3).loggers.must_equal [3]
21
+ Sequel::Database.new(1 => 2, :loggers => [3]).loggers.must_equal [3]
22
+ Sequel::Database.new(1 => 2, :logger => 4, :loggers => 3).loggers.must_equal [4,3]
23
+ Sequel::Database.new(1 => 2, :logger => [4], :loggers => [3]).loggers.must_equal [4,3]
24
24
  end
25
25
 
26
- specify "should support :preconnect option to preconnect to database" do
27
- @db.pool.size.should == 0
26
+ it "should support :preconnect option to preconnect to database" do
27
+ @db.pool.size.must_equal 0
28
28
  c = Class.new(Sequel::Database) do
29
29
  def connect(_)
30
30
  :connect
31
31
  end
32
32
  end
33
33
  db = c.new(1 => 2, :logger => 3, :preconnect=>true)
34
- db.pool.size.should == db.pool.max_size
34
+ db.pool.size.must_equal db.pool.max_size
35
35
  end
36
36
 
37
- specify "should handle the default string column size" do
38
- @db.default_string_column_size.should == 255
37
+ it "should handle the default string column size" do
38
+ @db.default_string_column_size.must_equal 255
39
39
  db = Sequel::Database.new(:default_string_column_size=>50)
40
- db.default_string_column_size.should == 50
40
+ db.default_string_column_size.must_equal 50
41
41
  db.default_string_column_size = 2
42
- db.default_string_column_size.should == 2
42
+ db.default_string_column_size.must_equal 2
43
43
  end
44
44
 
45
- specify "should set the sql_log_level from opts[:sql_log_level]" do
46
- Sequel::Database.new(1 => 2, :sql_log_level=>:debug).sql_log_level.should == :debug
47
- Sequel::Database.new(1 => 2, :sql_log_level=>'debug').sql_log_level.should == :debug
45
+ it "should set the sql_log_level from opts[:sql_log_level]" do
46
+ Sequel::Database.new(1 => 2, :sql_log_level=>:debug).sql_log_level.must_equal :debug
47
+ Sequel::Database.new(1 => 2, :sql_log_level=>'debug').sql_log_level.must_equal :debug
48
48
  end
49
49
 
50
- specify "should create a connection pool" do
51
- @db.pool.should be_a_kind_of(Sequel::ConnectionPool)
52
- @db.pool.max_size.should == 4
50
+ it "should create a connection pool" do
51
+ @db.pool.must_be_kind_of(Sequel::ConnectionPool)
52
+ @db.pool.max_size.must_equal 4
53
53
 
54
- Sequel::Database.new(:max_connections => 10).pool.max_size.should == 10
54
+ Sequel::Database.new(:max_connections => 10).pool.max_size.must_equal 10
55
55
  end
56
56
 
57
- specify "should have the connection pool use the connect method to get connections" do
57
+ it "should have the connection pool use the connect method to get connections" do
58
58
  cc = nil
59
59
  d = Sequel::Database.new
60
60
  meta_def(d, :connect){|c| 1234}
61
61
  d.synchronize {|c| cc = c}
62
- cc.should == 1234
62
+ cc.must_equal 1234
63
63
  end
64
64
 
65
- specify "should respect the :single_threaded option" do
65
+ it "should respect the :single_threaded option" do
66
66
  db = Sequel::Database.new(:single_threaded=>true){123}
67
- db.pool.should be_a_kind_of(Sequel::SingleConnectionPool)
67
+ db.pool.must_be_kind_of(Sequel::SingleConnectionPool)
68
68
  db = Sequel::Database.new(:single_threaded=>'t'){123}
69
- db.pool.should be_a_kind_of(Sequel::SingleConnectionPool)
69
+ db.pool.must_be_kind_of(Sequel::SingleConnectionPool)
70
70
  db = Sequel::Database.new(:single_threaded=>'1'){123}
71
- db.pool.should be_a_kind_of(Sequel::SingleConnectionPool)
71
+ db.pool.must_be_kind_of(Sequel::SingleConnectionPool)
72
72
  db = Sequel::Database.new(:single_threaded=>false){123}
73
- db.pool.should be_a_kind_of(Sequel::ConnectionPool)
73
+ db.pool.must_be_kind_of(Sequel::ConnectionPool)
74
74
  db = Sequel::Database.new(:single_threaded=>'f'){123}
75
- db.pool.should be_a_kind_of(Sequel::ConnectionPool)
75
+ db.pool.must_be_kind_of(Sequel::ConnectionPool)
76
76
  db = Sequel::Database.new(:single_threaded=>'0'){123}
77
- db.pool.should be_a_kind_of(Sequel::ConnectionPool)
77
+ db.pool.must_be_kind_of(Sequel::ConnectionPool)
78
78
  end
79
79
 
80
- specify "should respect the :quote_identifiers option" do
80
+ it "should respect the :quote_identifiers option" do
81
81
  db = Sequel::Database.new(:quote_identifiers=>false)
82
- db.quote_identifiers?.should == false
82
+ db.quote_identifiers?.must_equal false
83
83
  db = Sequel::Database.new(:quote_identifiers=>true)
84
- db.quote_identifiers?.should == true
84
+ db.quote_identifiers?.must_equal true
85
85
  end
86
86
 
87
- specify "should upcase on input and downcase on output by default" do
87
+ it "should upcase on input and downcase on output by default" do
88
88
  db = Sequel::Database.new
89
- db.send(:identifier_input_method_default).should == :upcase
90
- db.send(:identifier_output_method_default).should == :downcase
89
+ db.send(:identifier_input_method_default).must_equal :upcase
90
+ db.send(:identifier_output_method_default).must_equal :downcase
91
91
  end
92
92
 
93
- specify "should respect the :identifier_input_method option" do
93
+ it "should respect the :identifier_input_method option" do
94
94
  Sequel.identifier_input_method = nil
95
- Sequel::Database.identifier_input_method.should == false
95
+ Sequel::Database.identifier_input_method.must_equal false
96
96
  db = Sequel::Database.new(:identifier_input_method=>nil)
97
- db.identifier_input_method.should be_nil
97
+ db.identifier_input_method.must_equal nil
98
98
  db.identifier_input_method = :downcase
99
- db.identifier_input_method.should == :downcase
99
+ db.identifier_input_method.must_equal :downcase
100
100
  db = Sequel::Database.new(:identifier_input_method=>:upcase)
101
- db.identifier_input_method.should == :upcase
101
+ db.identifier_input_method.must_equal :upcase
102
102
  db.identifier_input_method = nil
103
- db.identifier_input_method.should be_nil
103
+ db.identifier_input_method.must_equal nil
104
104
  Sequel.identifier_input_method = :downcase
105
- Sequel::Database.identifier_input_method.should == :downcase
105
+ Sequel::Database.identifier_input_method.must_equal :downcase
106
106
  db = Sequel::Database.new(:identifier_input_method=>nil)
107
- db.identifier_input_method.should be_nil
107
+ db.identifier_input_method.must_equal nil
108
108
  db.identifier_input_method = :upcase
109
- db.identifier_input_method.should == :upcase
109
+ db.identifier_input_method.must_equal :upcase
110
110
  db = Sequel::Database.new(:identifier_input_method=>:upcase)
111
- db.identifier_input_method.should == :upcase
111
+ db.identifier_input_method.must_equal :upcase
112
112
  db.identifier_input_method = nil
113
- db.identifier_input_method.should be_nil
113
+ db.identifier_input_method.must_equal nil
114
114
  end
115
115
 
116
- specify "should respect the :identifier_output_method option" do
116
+ it "should respect the :identifier_output_method option" do
117
117
  Sequel.identifier_output_method = nil
118
- Sequel::Database.identifier_output_method.should == false
118
+ Sequel::Database.identifier_output_method.must_equal false
119
119
  db = Sequel::Database.new(:identifier_output_method=>nil)
120
- db.identifier_output_method.should be_nil
120
+ db.identifier_output_method.must_equal nil
121
121
  db.identifier_output_method = :downcase
122
- db.identifier_output_method.should == :downcase
122
+ db.identifier_output_method.must_equal :downcase
123
123
  db = Sequel::Database.new(:identifier_output_method=>:upcase)
124
- db.identifier_output_method.should == :upcase
124
+ db.identifier_output_method.must_equal :upcase
125
125
  db.identifier_output_method = nil
126
- db.identifier_output_method.should be_nil
126
+ db.identifier_output_method.must_equal nil
127
127
  Sequel.identifier_output_method = :downcase
128
- Sequel::Database.identifier_output_method.should == :downcase
128
+ Sequel::Database.identifier_output_method.must_equal :downcase
129
129
  db = Sequel::Database.new(:identifier_output_method=>nil)
130
- db.identifier_output_method.should be_nil
130
+ db.identifier_output_method.must_equal nil
131
131
  db.identifier_output_method = :upcase
132
- db.identifier_output_method.should == :upcase
132
+ db.identifier_output_method.must_equal :upcase
133
133
  db = Sequel::Database.new(:identifier_output_method=>:upcase)
134
- db.identifier_output_method.should == :upcase
134
+ db.identifier_output_method.must_equal :upcase
135
135
  db.identifier_output_method = nil
136
- db.identifier_output_method.should be_nil
136
+ db.identifier_output_method.must_equal nil
137
137
  end
138
138
 
139
- specify "should use the default Sequel.quote_identifiers value" do
139
+ it "should use the default Sequel.quote_identifiers value" do
140
140
  Sequel.quote_identifiers = true
141
- Sequel::Database.new({}).quote_identifiers?.should == true
141
+ Sequel::Database.new({}).quote_identifiers?.must_equal true
142
142
  Sequel.quote_identifiers = false
143
- Sequel::Database.new({}).quote_identifiers?.should == false
143
+ Sequel::Database.new({}).quote_identifiers?.must_equal false
144
144
  Sequel::Database.quote_identifiers = true
145
- Sequel::Database.new({}).quote_identifiers?.should == true
145
+ Sequel::Database.new({}).quote_identifiers?.must_equal true
146
146
  Sequel::Database.quote_identifiers = false
147
- Sequel::Database.new({}).quote_identifiers?.should == false
147
+ Sequel::Database.new({}).quote_identifiers?.must_equal false
148
148
  end
149
149
 
150
- specify "should use the default Sequel.identifier_input_method value" do
150
+ it "should use the default Sequel.identifier_input_method value" do
151
151
  Sequel.identifier_input_method = :downcase
152
- Sequel::Database.new({}).identifier_input_method.should == :downcase
152
+ Sequel::Database.new({}).identifier_input_method.must_equal :downcase
153
153
  Sequel.identifier_input_method = :upcase
154
- Sequel::Database.new({}).identifier_input_method.should == :upcase
154
+ Sequel::Database.new({}).identifier_input_method.must_equal :upcase
155
155
  Sequel::Database.identifier_input_method = :downcase
156
- Sequel::Database.new({}).identifier_input_method.should == :downcase
156
+ Sequel::Database.new({}).identifier_input_method.must_equal :downcase
157
157
  Sequel::Database.identifier_input_method = :upcase
158
- Sequel::Database.new({}).identifier_input_method.should == :upcase
158
+ Sequel::Database.new({}).identifier_input_method.must_equal :upcase
159
159
  end
160
160
 
161
- specify "should use the default Sequel.identifier_output_method value" do
161
+ it "should use the default Sequel.identifier_output_method value" do
162
162
  Sequel.identifier_output_method = :downcase
163
- Sequel::Database.new({}).identifier_output_method.should == :downcase
163
+ Sequel::Database.new({}).identifier_output_method.must_equal :downcase
164
164
  Sequel.identifier_output_method = :upcase
165
- Sequel::Database.new({}).identifier_output_method.should == :upcase
165
+ Sequel::Database.new({}).identifier_output_method.must_equal :upcase
166
166
  Sequel::Database.identifier_output_method = :downcase
167
- Sequel::Database.new({}).identifier_output_method.should == :downcase
167
+ Sequel::Database.new({}).identifier_output_method.must_equal :downcase
168
168
  Sequel::Database.identifier_output_method = :upcase
169
- Sequel::Database.new({}).identifier_output_method.should == :upcase
169
+ Sequel::Database.new({}).identifier_output_method.must_equal :upcase
170
170
  end
171
171
 
172
- specify "should respect the quote_indentifiers_default method if Sequel.quote_identifiers = nil" do
172
+ it "should respect the quote_indentifiers_default method if Sequel.quote_identifiers = nil" do
173
173
  Sequel.quote_identifiers = nil
174
- Sequel::Database.new({}).quote_identifiers?.should == true
174
+ Sequel::Database.new({}).quote_identifiers?.must_equal true
175
175
  x = Class.new(Sequel::Database){def quote_identifiers_default; false end}
176
- x.new({}).quote_identifiers?.should == false
176
+ x.new({}).quote_identifiers?.must_equal false
177
177
  y = Class.new(Sequel::Database){def quote_identifiers_default; true end}
178
- y.new({}).quote_identifiers?.should == true
178
+ y.new({}).quote_identifiers?.must_equal true
179
179
  end
180
180
 
181
- specify "should respect the identifier_input_method_default method" do
181
+ it "should respect the identifier_input_method_default method" do
182
182
  class Sequel::Database
183
183
  @identifier_input_method = nil
184
184
  end
185
185
  x = Class.new(Sequel::Database){def identifier_input_method_default; :downcase end}
186
- x.new({}).identifier_input_method.should == :downcase
186
+ x.new({}).identifier_input_method.must_equal :downcase
187
187
  y = Class.new(Sequel::Database){def identifier_input_method_default; :camelize end}
188
- y.new({}).identifier_input_method.should == :camelize
188
+ y.new({}).identifier_input_method.must_equal :camelize
189
189
  end
190
190
 
191
- specify "should respect the identifier_output_method_default method if Sequel.identifier_output_method is not called" do
191
+ it "should respect the identifier_output_method_default method if Sequel.identifier_output_method is not called" do
192
192
  class Sequel::Database
193
193
  @identifier_output_method = nil
194
194
  end
195
195
  x = Class.new(Sequel::Database){def identifier_output_method_default; :upcase end}
196
- x.new({}).identifier_output_method.should == :upcase
196
+ x.new({}).identifier_output_method.must_equal :upcase
197
197
  y = Class.new(Sequel::Database){def identifier_output_method_default; :underscore end}
198
- y.new({}).identifier_output_method.should == :underscore
198
+ y.new({}).identifier_output_method.must_equal :underscore
199
199
  end
200
200
 
201
- specify "should just use a :uri option for jdbc with the full connection string" do
202
- Sequel::Database.should_receive(:adapter_class).once.with(:jdbc).and_return(Sequel::Database)
203
- db = Sequel.connect('jdbc:test://host/db_name')
204
- db.should be_a_kind_of(Sequel::Database)
205
- db.opts[:uri].should == 'jdbc:test://host/db_name'
201
+ it "should just use a :uri option for jdbc with the full connection string" do
202
+ db = Sequel::Database.stub(:adapter_class, Sequel::Database) do
203
+ Sequel.connect('jdbc:test://host/db_name')
204
+ end
205
+ db.must_be_kind_of(Sequel::Database)
206
+ db.opts[:uri].must_equal 'jdbc:test://host/db_name'
206
207
  end
207
208
 
208
- specify "should just use a :uri option for do with the full connection string" do
209
- Sequel::Database.should_receive(:adapter_class).once.with(:do).and_return(Sequel::Database)
210
- db = Sequel.connect('do:test://host/db_name')
211
- db.should be_a_kind_of(Sequel::Database)
212
- db.opts[:uri].should == 'do:test://host/db_name'
209
+ it "should just use a :uri option for do with the full connection string" do
210
+ db = Sequel::Database.stub(:adapter_class, Sequel::Database) do
211
+ Sequel.connect('do:test://host/db_name')
212
+ end
213
+ db.must_be_kind_of(Sequel::Database)
214
+ db.opts[:uri].must_equal 'do:test://host/db_name'
213
215
  end
214
216
 
215
- specify "should populate :adapter option when using connection string" do
216
- Sequel.connect('mock:/').opts[:adapter].should == "mock"
217
+ it "should populate :adapter option when using connection string" do
218
+ Sequel.connect('mock:/').opts[:adapter].must_equal "mock"
217
219
  end
218
220
 
219
- specify "should respect the :keep_reference option for not keeping a reference in Sequel::DATABASES" do
221
+ it "should respect the :keep_reference option for not keeping a reference in Sequel::DATABASES" do
220
222
  db = Sequel.connect('mock:///?keep_reference=f')
221
- Sequel::DATABASES.should_not include(db)
223
+ Sequel::DATABASES.wont_include(db)
222
224
  end
223
225
  end
224
226
 
225
227
  describe "Database#disconnect" do
226
- specify "should call pool.disconnect" do
228
+ it "should call pool.disconnect" do
227
229
  d = Sequel::Database.new
228
230
  p = d.pool
229
- p.should_receive(:disconnect).once.with({}).and_return(2)
230
- d.disconnect.should == 2
231
+ def p.disconnect(h)
232
+ raise unless h == {}
233
+ 2
234
+ end
235
+ d.disconnect.must_equal 2
231
236
  end
232
237
  end
233
238
 
234
239
  describe "Sequel.extension" do
235
- specify "should attempt to load the given extension" do
236
- proc{Sequel.extension :blah}.should raise_error(LoadError)
240
+ it "should attempt to load the given extension" do
241
+ proc{Sequel.extension :blah}.must_raise(LoadError)
237
242
  end
238
243
  end
239
244
 
@@ -246,14 +251,14 @@ describe "Database#log_info" do
246
251
  @db = Sequel::Database.new(:logger=>@o)
247
252
  end
248
253
 
249
- specify "should log message at info level to all loggers" do
254
+ it "should log message at info level to all loggers" do
250
255
  @db.log_info('blah')
251
- @o.logs.should == [[:info, 'blah']]
256
+ @o.logs.must_equal [[:info, 'blah']]
252
257
  end
253
258
 
254
- specify "should log message with args at info level to all loggers" do
259
+ it "should log message with args at info level to all loggers" do
255
260
  @db.log_info('blah', [1, 2])
256
- @o.logs.should == [[:info, 'blah; [1, 2]']]
261
+ @o.logs.must_equal [[:info, 'blah; [1, 2]']]
257
262
  end
258
263
  end
259
264
 
@@ -267,66 +272,66 @@ describe "Database#log_yield" do
267
272
  @db = Sequel::Database.new(:logger=>@o)
268
273
  end
269
274
 
270
- specify "should yield to the passed block" do
275
+ it "should yield to the passed block" do
271
276
  a = nil
272
277
  @db.log_yield('blah'){a = 1}
273
- a.should == 1
278
+ a.must_equal 1
274
279
  end
275
280
 
276
- specify "should raise an exception if a block is not passed" do
277
- proc{@db.log_yield('blah')}.should raise_error
281
+ it "should raise an exception if a block is not passed" do
282
+ proc{@db.log_yield('blah')}.must_raise LocalJumpError
278
283
  end
279
284
 
280
- specify "should log message with duration at info level to all loggers" do
285
+ it "should log message with duration at info level to all loggers" do
281
286
  @db.log_yield('blah'){}
282
- @o.logs.length.should == 1
283
- @o.logs.first.length.should == 2
284
- @o.logs.first.first.should == :info
285
- @o.logs.first.last.should =~ /\A\(\d\.\d{6}s\) blah\z/
287
+ @o.logs.length.must_equal 1
288
+ @o.logs.first.length.must_equal 2
289
+ @o.logs.first.first.must_equal :info
290
+ @o.logs.first.last.must_match(/\A\(\d\.\d{6}s\) blah\z/)
286
291
  end
287
292
 
288
- specify "should respect sql_log_level setting" do
293
+ it "should respect sql_log_level setting" do
289
294
  @db.sql_log_level = :debug
290
295
  @db.log_yield('blah'){}
291
- @o.logs.length.should == 1
292
- @o.logs.first.length.should == 2
293
- @o.logs.first.first.should == :debug
294
- @o.logs.first.last.should =~ /\A\(\d\.\d{6}s\) blah\z/
296
+ @o.logs.length.must_equal 1
297
+ @o.logs.first.length.must_equal 2
298
+ @o.logs.first.first.must_equal :debug
299
+ @o.logs.first.last.must_match(/\A\(\d\.\d{6}s\) blah\z/)
295
300
  end
296
301
 
297
- specify "should log message with duration at warn level if duration greater than log_warn_duration" do
302
+ it "should log message with duration at warn level if duration greater than log_warn_duration" do
298
303
  @db.log_warn_duration = 0
299
304
  @db.log_yield('blah'){}
300
- @o.logs.length.should == 1
301
- @o.logs.first.length.should == 2
302
- @o.logs.first.first.should == :warn
303
- @o.logs.first.last.should =~ /\A\(\d\.\d{6}s\) blah\z/
305
+ @o.logs.length.must_equal 1
306
+ @o.logs.first.length.must_equal 2
307
+ @o.logs.first.first.must_equal :warn
308
+ @o.logs.first.last.must_match(/\A\(\d\.\d{6}s\) blah\z/)
304
309
  end
305
310
 
306
- specify "should log message with duration at info level if duration less than log_warn_duration" do
311
+ it "should log message with duration at info level if duration less than log_warn_duration" do
307
312
  @db.log_warn_duration = 1000
308
313
  @db.log_yield('blah'){}
309
- @o.logs.length.should == 1
310
- @o.logs.first.length.should == 2
311
- @o.logs.first.first.should == :info
312
- @o.logs.first.last.should =~ /\A\(\d\.\d{6}s\) blah\z/
314
+ @o.logs.length.must_equal 1
315
+ @o.logs.first.length.must_equal 2
316
+ @o.logs.first.first.must_equal :info
317
+ @o.logs.first.last.must_match(/\A\(\d\.\d{6}s\) blah\z/)
313
318
  end
314
319
 
315
- specify "should log message at error level if block raises an error" do
320
+ it "should log message at error level if block raises an error" do
316
321
  @db.log_warn_duration = 0
317
- proc{@db.log_yield('blah'){raise Sequel::Error, 'adsf'}}.should raise_error
318
- @o.logs.length.should == 1
319
- @o.logs.first.length.should == 2
320
- @o.logs.first.first.should == :error
321
- @o.logs.first.last.should =~ /\ASequel::Error: adsf: blah\z/
322
+ proc{@db.log_yield('blah'){raise Sequel::Error, 'adsf'}}.must_raise Sequel::Error
323
+ @o.logs.length.must_equal 1
324
+ @o.logs.first.length.must_equal 2
325
+ @o.logs.first.first.must_equal :error
326
+ @o.logs.first.last.must_match(/\ASequel::Error: adsf: blah\z/)
322
327
  end
323
328
 
324
- specify "should include args with message if args passed" do
329
+ it "should include args with message if args passed" do
325
330
  @db.log_yield('blah', [1, 2]){}
326
- @o.logs.length.should == 1
327
- @o.logs.first.length.should == 2
328
- @o.logs.first.first.should == :info
329
- @o.logs.first.last.should =~ /\A\(\d\.\d{6}s\) blah; \[1, 2\]\z/
331
+ @o.logs.length.must_equal 1
332
+ @o.logs.first.length.must_equal 2
333
+ @o.logs.first.first.must_equal :info
334
+ @o.logs.first.last.must_match(/\A\(\d\.\d{6}s\) blah; \[1, 2\]\z/)
330
335
  end
331
336
  end
332
337
 
@@ -339,29 +344,29 @@ describe "Database#uri" do
339
344
  @db = Sequel.connect('mau://user:pass@localhost:9876/maumau')
340
345
  end
341
346
 
342
- specify "should return the connection URI for the database" do
343
- @db.uri.should == 'mau://user:pass@localhost:9876/maumau'
347
+ it "should return the connection URI for the database" do
348
+ @db.uri.must_equal 'mau://user:pass@localhost:9876/maumau'
344
349
  end
345
350
 
346
- specify "should return nil if a connection uri was not used" do
347
- Sequel.mock.uri.should be_nil
351
+ it "should return nil if a connection uri was not used" do
352
+ Sequel.mock.uri.must_equal nil
348
353
  end
349
354
 
350
- specify "should be aliased as #url" do
351
- @db.url.should == 'mau://user:pass@localhost:9876/maumau'
355
+ it "should be aliased as #url" do
356
+ @db.url.must_equal 'mau://user:pass@localhost:9876/maumau'
352
357
  end
353
358
  end
354
359
 
355
360
  describe "Database.adapter_scheme and #adapter_scheme" do
356
- specify "should return the database scheme" do
357
- Sequel::Database.adapter_scheme.should be_nil
361
+ it "should return the database scheme" do
362
+ Sequel::Database.adapter_scheme.must_equal nil
358
363
 
359
364
  @c = Class.new(Sequel::Database) do
360
365
  set_adapter_scheme :mau
361
366
  end
362
367
 
363
- @c.adapter_scheme.should == :mau
364
- @c.new({}).adapter_scheme.should == :mau
368
+ @c.adapter_scheme.must_equal :mau
369
+ @c.new({}).adapter_scheme.must_equal :mau
365
370
  end
366
371
  end
367
372
 
@@ -371,38 +376,38 @@ describe "Database#dataset" do
371
376
  @ds = @db.dataset
372
377
  end
373
378
 
374
- specify "should provide a blank dataset through #dataset" do
375
- @ds.should be_a_kind_of(Sequel::Dataset)
376
- @ds.opts.should == {}
377
- @ds.db.should be(@db)
379
+ it "should provide a blank dataset through #dataset" do
380
+ @ds.must_be_kind_of(Sequel::Dataset)
381
+ @ds.opts.must_equal({})
382
+ @ds.db.must_be_same_as(@db)
378
383
  end
379
384
 
380
- specify "should provide a #from dataset" do
385
+ it "should provide a #from dataset" do
381
386
  d = @db.from(:mau)
382
- d.should be_a_kind_of(Sequel::Dataset)
383
- d.sql.should == 'SELECT * FROM mau'
387
+ d.must_be_kind_of(Sequel::Dataset)
388
+ d.sql.must_equal 'SELECT * FROM mau'
384
389
 
385
390
  e = @db[:miu]
386
- e.should be_a_kind_of(Sequel::Dataset)
387
- e.sql.should == 'SELECT * FROM miu'
391
+ e.must_be_kind_of(Sequel::Dataset)
392
+ e.sql.must_equal 'SELECT * FROM miu'
388
393
  end
389
394
 
390
- specify "should provide a filtered #from dataset if a block is given" do
395
+ it "should provide a filtered #from dataset if a block is given" do
391
396
  d = @db.from(:mau){x.sql_number > 100}
392
- d.should be_a_kind_of(Sequel::Dataset)
393
- d.sql.should == 'SELECT * FROM mau WHERE (x > 100)'
397
+ d.must_be_kind_of(Sequel::Dataset)
398
+ d.sql.must_equal 'SELECT * FROM mau WHERE (x > 100)'
394
399
  end
395
400
 
396
- specify "should provide a #select dataset" do
401
+ it "should provide a #select dataset" do
397
402
  d = @db.select(:a, :b, :c).from(:mau)
398
- d.should be_a_kind_of(Sequel::Dataset)
399
- d.sql.should == 'SELECT a, b, c FROM mau'
403
+ d.must_be_kind_of(Sequel::Dataset)
404
+ d.sql.must_equal 'SELECT a, b, c FROM mau'
400
405
  end
401
406
 
402
- specify "should allow #select to take a block" do
407
+ it "should allow #select to take a block" do
403
408
  d = @db.select(:a, :b){c}.from(:mau)
404
- d.should be_a_kind_of(Sequel::Dataset)
405
- d.sql.should == 'SELECT a, b, c FROM mau'
409
+ d.must_be_kind_of(Sequel::Dataset)
410
+ d.sql.must_equal 'SELECT a, b, c FROM mau'
406
411
  end
407
412
  end
408
413
 
@@ -412,18 +417,18 @@ describe "Database#dataset_class" do
412
417
  @dsc = Class.new(Sequel::Dataset)
413
418
  end
414
419
 
415
- specify "should have setter set the class to use to create datasets" do
420
+ it "should have setter set the class to use to create datasets" do
416
421
  @db.dataset_class = @dsc
417
422
  ds = @db.dataset
418
- ds.should be_a_kind_of(@dsc)
419
- ds.opts.should == {}
420
- ds.db.should be(@db)
423
+ ds.must_be_kind_of(@dsc)
424
+ ds.opts.must_equal({})
425
+ ds.db.must_be_same_as(@db)
421
426
  end
422
427
 
423
- specify "should have getter return the class to use to create datasets" do
424
- [@db.dataset_class, @db.dataset_class.superclass].should include(Sequel::Dataset)
428
+ it "should have getter return the class to use to create datasets" do
429
+ [@db.dataset_class, @db.dataset_class.superclass].must_include(Sequel::Dataset)
425
430
  @db.dataset_class = @dsc
426
- [@db.dataset_class, @db.dataset_class.superclass].should include(@dsc)
431
+ [@db.dataset_class, @db.dataset_class.superclass].must_include(@dsc)
427
432
  end
428
433
  end
429
434
 
@@ -435,77 +440,77 @@ describe "Database#extend_datasets" do
435
440
  @db.extend_datasets(@m)
436
441
  end
437
442
 
438
- specify "should clear a cached dataset" do
443
+ it "should clear a cached dataset" do
439
444
  @db = Sequel::Database.new
440
- @db.literal(1).should == '1'
445
+ @db.literal(1).must_equal '1'
441
446
  @db.extend_datasets{def literal(v) '2' end}
442
- @db.literal(1).should == '2'
447
+ @db.literal(1).must_equal '2'
443
448
  end
444
449
 
445
- specify "should change the dataset class to a subclass the first time it is called" do
446
- @db.dataset_class.superclass.should == Sequel::Dataset
450
+ it "should change the dataset class to a subclass the first time it is called" do
451
+ @db.dataset_class.superclass.must_equal Sequel::Dataset
447
452
  end
448
453
 
449
- specify "should not create a subclass of the dataset class if called more than once" do
454
+ it "should not create a subclass of the dataset class if called more than once" do
450
455
  @db.extend_datasets(@m2)
451
- @db.dataset_class.superclass.should == Sequel::Dataset
456
+ @db.dataset_class.superclass.must_equal Sequel::Dataset
452
457
  end
453
458
 
454
- specify "should make the dataset class include the module" do
455
- @db.dataset_class.ancestors.should include(@m)
456
- @db.dataset_class.ancestors.should_not include(@m2)
459
+ it "should make the dataset class include the module" do
460
+ @db.dataset_class.ancestors.must_include(@m)
461
+ @db.dataset_class.ancestors.wont_include(@m2)
457
462
  @db.extend_datasets(@m2)
458
- @db.dataset_class.ancestors.should include(@m)
459
- @db.dataset_class.ancestors.should include(@m2)
463
+ @db.dataset_class.ancestors.must_include(@m)
464
+ @db.dataset_class.ancestors.must_include(@m2)
460
465
  end
461
466
 
462
- specify "should have datasets respond to the module's methods" do
463
- @db.dataset.foo.should == [3]
467
+ it "should have datasets respond to the module's methods" do
468
+ @db.dataset.foo.must_equal [3]
464
469
  @db.extend_datasets(@m2)
465
- @db.dataset.foo.should == [4, 3]
470
+ @db.dataset.foo.must_equal [4, 3]
466
471
  end
467
472
 
468
- specify "should take a block and create a module from it to use" do
469
- @db.dataset.foo.should == [3]
473
+ it "should take a block and create a module from it to use" do
474
+ @db.dataset.foo.must_equal [3]
470
475
  @db.extend_datasets{def foo() [5] + super end}
471
- @db.dataset.foo.should == [5, 3]
476
+ @db.dataset.foo.must_equal [5, 3]
472
477
  end
473
478
 
474
- specify "should raise an error if both a module and a block are provided" do
475
- proc{@db.extend_datasets(@m2){def foo() [5] + super end}}.should raise_error(Sequel::Error)
479
+ it "should raise an error if both a module and a block are provided" do
480
+ proc{@db.extend_datasets(@m2){def foo() [5] + super end}}.must_raise(Sequel::Error)
476
481
  end
477
482
 
478
- specify "should be able to override methods defined in the original Dataset class" do
483
+ it "should be able to override methods defined in the original Dataset class" do
479
484
  @db.extend_datasets(Module.new{def select(*a, &block) super.order(*a, &block) end})
480
- @db[:t].select(:a, :b).sql.should == 'SELECT a, b FROM t ORDER BY a, b'
485
+ @db[:t].select(:a, :b).sql.must_equal 'SELECT a, b FROM t ORDER BY a, b'
481
486
  end
482
487
 
483
- specify "should reapply settings if dataset_class is changed" do
488
+ it "should reapply settings if dataset_class is changed" do
484
489
  c = Class.new(Sequel::Dataset)
485
490
  @db.dataset_class = c
486
- @db.dataset_class.superclass.should == c
487
- @db.dataset_class.ancestors.should include(@m)
488
- @db.dataset.foo.should == [3]
491
+ @db.dataset_class.superclass.must_equal c
492
+ @db.dataset_class.ancestors.must_include(@m)
493
+ @db.dataset.foo.must_equal [3]
489
494
  end
490
495
  end
491
496
 
492
497
  describe "Database#disconnect_connection" do
493
- specify "should call close on the connection" do
498
+ it "should call close on the connection" do
494
499
  o = Object.new
495
500
  def o.close() @closed=true end
496
501
  Sequel::Database.new.disconnect_connection(o)
497
- o.instance_variable_get(:@closed).should == true
502
+ o.instance_variable_get(:@closed).must_equal true
498
503
  end
499
504
  end
500
505
 
501
506
  describe "Database#valid_connection?" do
502
- specify "should issue a query to validate the connection" do
507
+ it "should issue a query to validate the connection" do
503
508
  db = Sequel.mock
504
- db.synchronize{|c| db.valid_connection?(c)}.should == true
509
+ db.synchronize{|c| db.valid_connection?(c)}.must_equal true
505
510
  db.synchronize do |c|
506
511
  def c.execute(*) raise Sequel::DatabaseError, "error" end
507
512
  db.valid_connection?(c)
508
- end.should == false
513
+ end.must_equal false
509
514
  end
510
515
  end
511
516
 
@@ -514,23 +519,23 @@ describe "Database#run" do
514
519
  @db = Sequel.mock(:servers=>{:s1=>{}})
515
520
  end
516
521
 
517
- specify "should execute the code on the database" do
522
+ it "should execute the code on the database" do
518
523
  @db.run("DELETE FROM items")
519
- @db.sqls.should == ["DELETE FROM items"]
524
+ @db.sqls.must_equal ["DELETE FROM items"]
520
525
  end
521
526
 
522
- specify "should handle placeholder literal strings" do
527
+ it "should handle placeholder literal strings" do
523
528
  @db.run(Sequel.lit("DELETE FROM ?", :items))
524
- @db.sqls.should == ["DELETE FROM items"]
529
+ @db.sqls.must_equal ["DELETE FROM items"]
525
530
  end
526
531
 
527
- specify "should return nil" do
528
- @db.run("DELETE FROM items").should be_nil
532
+ it "should return nil" do
533
+ @db.run("DELETE FROM items").must_equal nil
529
534
  end
530
535
 
531
- specify "should accept options passed to execute_ddl" do
536
+ it "should accept options passed to execute_ddl" do
532
537
  @db.run("DELETE FROM items", :server=>:s1)
533
- @db.sqls.should == ["DELETE FROM items -- s1"]
538
+ @db.sqls.must_equal ["DELETE FROM items -- s1"]
534
539
  end
535
540
  end
536
541
 
@@ -539,19 +544,19 @@ describe "Database#<<" do
539
544
  @db = Sequel.mock
540
545
  end
541
546
 
542
- specify "should execute the code on the database" do
547
+ it "should execute the code on the database" do
543
548
  @db << "DELETE FROM items"
544
- @db.sqls.should == ["DELETE FROM items"]
549
+ @db.sqls.must_equal ["DELETE FROM items"]
545
550
  end
546
551
 
547
- specify "should handle placeholder literal strings" do
552
+ it "should handle placeholder literal strings" do
548
553
  @db << Sequel.lit("DELETE FROM ?", :items)
549
- @db.sqls.should == ["DELETE FROM items"]
554
+ @db.sqls.must_equal ["DELETE FROM items"]
550
555
  end
551
556
 
552
- specify "should be chainable" do
557
+ it "should be chainable" do
553
558
  @db << "DELETE FROM items" << "DELETE FROM items2"
554
- @db.sqls.should == ["DELETE FROM items", "DELETE FROM items2"]
559
+ @db.sqls.must_equal ["DELETE FROM items", "DELETE FROM items2"]
555
560
  end
556
561
  end
557
562
 
@@ -561,19 +566,19 @@ describe "Database#synchronize" do
561
566
  meta_def(@db, :connect){|c| 12345}
562
567
  end
563
568
 
564
- specify "should wrap the supplied block in pool.hold" do
569
+ it "should wrap the supplied block in pool.hold" do
565
570
  q, q1, q2 = Queue.new, Queue.new, Queue.new
566
571
  c1, c2 = nil
567
572
  t1 = Thread.new{@db.synchronize{|c| c1 = c; q.push nil; q1.pop}; q.push nil}
568
573
  q.pop
569
- c1.should == 12345
574
+ c1.must_equal 12345
570
575
  t2 = Thread.new{@db.synchronize{|c| c2 = c; q2.push nil}}
571
- @db.pool.available_connections.should be_empty
572
- c2.should be_nil
576
+ @db.pool.available_connections.must_be :empty?
577
+ c2.must_equal nil
573
578
  q1.push nil
574
579
  q.pop
575
580
  q2.pop
576
- c2.should == 12345
581
+ c2.must_equal 12345
577
582
  t1.join
578
583
  t2.join
579
584
  end
@@ -586,65 +591,65 @@ describe "Database#test_connection" do
586
591
  meta_def(@db, :connect){|c| pr.call}
587
592
  end
588
593
 
589
- specify "should attempt to get a connection" do
594
+ it "should attempt to get a connection" do
590
595
  @db.test_connection
591
- @test.should_not be_nil
596
+ @test.wont_equal nil
592
597
  end
593
598
 
594
- specify "should return true if successful" do
595
- @db.test_connection.should == true
599
+ it "should return true if successful" do
600
+ @db.test_connection.must_equal true
596
601
  end
597
602
 
598
- specify "should raise an error if the attempting to connect raises an error" do
603
+ it "should raise an error if the attempting to connect raises an error" do
599
604
  def @db.connect(*) raise Sequel::Error end
600
- proc{@db.test_connection}.should raise_error(Sequel::Error)
605
+ proc{@db.test_connection}.must_raise(Sequel::DatabaseConnectionError)
601
606
  end
602
607
  end
603
608
 
604
609
  describe "Database#table_exists?" do
605
- specify "should test existence by selecting a row from the table's dataset" do
610
+ it "should test existence by selecting a row from the table's dataset" do
606
611
  db = Sequel.mock(:fetch=>[Sequel::Error, [], [{:a=>1}]])
607
- db.table_exists?(:a).should == false
608
- db.sqls.should == ["SELECT NULL AS nil FROM a LIMIT 1"]
609
- db.table_exists?(:b).should == true
610
- db.table_exists?(:c).should == true
612
+ db.table_exists?(:a).must_equal false
613
+ db.sqls.must_equal ["SELECT NULL AS nil FROM a LIMIT 1"]
614
+ db.table_exists?(:b).must_equal true
615
+ db.table_exists?(:c).must_equal true
611
616
  end
612
617
  end
613
618
 
614
- shared_examples_for "Database#transaction" do
615
- specify "should wrap the supplied block with BEGIN + COMMIT statements" do
619
+ DatabaseTransactionSpecs = shared_description do
620
+ it "should wrap the supplied block with BEGIN + COMMIT statements" do
616
621
  @db.transaction{@db.execute 'DROP TABLE test;'}
617
- @db.sqls.should == ['BEGIN', 'DROP TABLE test;', 'COMMIT']
622
+ @db.sqls.must_equal ['BEGIN', 'DROP TABLE test;', 'COMMIT']
618
623
  end
619
624
 
620
- specify "should support transaction isolation levels" do
625
+ it "should support transaction isolation levels" do
621
626
  meta_def(@db, :supports_transaction_isolation_levels?){true}
622
627
  [:uncommitted, :committed, :repeatable, :serializable].each do |l|
623
628
  @db.transaction(:isolation=>l){@db.run "DROP TABLE #{l}"}
624
629
  end
625
- @db.sqls.should == ['BEGIN', 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', 'DROP TABLE uncommitted', 'COMMIT',
630
+ @db.sqls.must_equal ['BEGIN', 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', 'DROP TABLE uncommitted', 'COMMIT',
626
631
  'BEGIN', 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED', 'DROP TABLE committed', 'COMMIT',
627
632
  'BEGIN', 'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ', 'DROP TABLE repeatable', 'COMMIT',
628
633
  'BEGIN', 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', 'DROP TABLE serializable', 'COMMIT']
629
634
  end
630
635
 
631
- specify "should allow specifying a default transaction isolation level" do
636
+ it "should allow specifying a default transaction isolation level" do
632
637
  meta_def(@db, :supports_transaction_isolation_levels?){true}
633
638
  [:uncommitted, :committed, :repeatable, :serializable].each do |l|
634
639
  @db.transaction_isolation_level = l
635
640
  @db.transaction{@db.run "DROP TABLE #{l}"}
636
641
  end
637
- @db.sqls.should == ['BEGIN', 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', 'DROP TABLE uncommitted', 'COMMIT',
642
+ @db.sqls.must_equal ['BEGIN', 'SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED', 'DROP TABLE uncommitted', 'COMMIT',
638
643
  'BEGIN', 'SET TRANSACTION ISOLATION LEVEL READ COMMITTED', 'DROP TABLE committed', 'COMMIT',
639
644
  'BEGIN', 'SET TRANSACTION ISOLATION LEVEL REPEATABLE READ', 'DROP TABLE repeatable', 'COMMIT',
640
645
  'BEGIN', 'SET TRANSACTION ISOLATION LEVEL SERIALIZABLE', 'DROP TABLE serializable', 'COMMIT']
641
646
  end
642
647
 
643
- specify "should support :retry_on option for automatically retrying transactions" do
648
+ it "should support :retry_on option for automatically retrying transactions" do
644
649
  a = []
645
650
  @db.transaction(:retry_on=>Sequel::DatabaseDisconnectError){a << 1; raise Sequel::DatabaseDisconnectError if a.length < 2}
646
- @db.sqls.should == ['BEGIN', 'ROLLBACK', 'BEGIN', 'COMMIT']
647
- a.should == [1, 1]
651
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK', 'BEGIN', 'COMMIT']
652
+ a.must_equal [1, 1]
648
653
 
649
654
  a = []
650
655
  @db.transaction(:retry_on=>[Sequel::ConstraintViolation, Sequel::SerializationFailure]) do
@@ -652,11 +657,11 @@ shared_examples_for "Database#transaction" do
652
657
  raise Sequel::SerializationFailure if a.length == 1
653
658
  raise Sequel::ConstraintViolation if a.length == 2
654
659
  end
655
- @db.sqls.should == ['BEGIN', 'ROLLBACK', 'BEGIN', 'ROLLBACK', 'BEGIN', 'COMMIT']
656
- a.should == [1, 1, 1]
660
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK', 'BEGIN', 'ROLLBACK', 'BEGIN', 'COMMIT']
661
+ a.must_equal [1, 1, 1]
657
662
  end
658
663
 
659
- specify "should support :num_retries option for limiting the number of retry times" do
664
+ it "should support :num_retries option for limiting the number of retry times" do
660
665
  a = []
661
666
  lambda do
662
667
  @db.transaction(:num_retries=>1, :retry_on=>[Sequel::ConstraintViolation, Sequel::SerializationFailure]) do
@@ -664,12 +669,12 @@ shared_examples_for "Database#transaction" do
664
669
  raise Sequel::SerializationFailure if a.length == 1
665
670
  raise Sequel::ConstraintViolation if a.length == 2
666
671
  end
667
- end.should raise_error(Sequel::ConstraintViolation)
668
- @db.sqls.should == ['BEGIN', 'ROLLBACK', 'BEGIN', 'ROLLBACK']
669
- a.should == [1, 1]
672
+ end.must_raise(Sequel::ConstraintViolation)
673
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK', 'BEGIN', 'ROLLBACK']
674
+ a.must_equal [1, 1]
670
675
  end
671
676
 
672
- specify "should support :num_retries=>nil option to retry indefinitely" do
677
+ it "should support :num_retries=>nil option to retry indefinitely" do
673
678
  a = []
674
679
  lambda do
675
680
  @db.transaction(:num_retries=>nil, :retry_on=>[Sequel::ConstraintViolation]) do
@@ -677,30 +682,30 @@ shared_examples_for "Database#transaction" do
677
682
  raise Sequel::SerializationFailure if a.length >= 100
678
683
  raise Sequel::ConstraintViolation
679
684
  end
680
- end.should raise_error(Sequel::SerializationFailure)
681
- @db.sqls.should == ['BEGIN', 'ROLLBACK'] * 100
682
- a.should == [1] * 100
685
+ end.must_raise(Sequel::SerializationFailure)
686
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK'] * 100
687
+ a.must_equal [1] * 100
683
688
  end
684
689
 
685
- specify "should support :before_retry option for invoking callback before retrying" do
690
+ it "should support :before_retry option for invoking callback before retrying" do
686
691
  a, errs, calls = [], [], []
687
692
  retryer = proc{|n, err| calls << n; errs << err }
688
693
  @db.transaction(:retry_on=>Sequel::DatabaseDisconnectError, :before_retry => retryer) do
689
694
  a << 1; raise Sequel::DatabaseDisconnectError if a.length < 3
690
695
  end
691
- @db.sqls.should == ['BEGIN', 'ROLLBACK', 'BEGIN', 'ROLLBACK', 'BEGIN', 'COMMIT']
692
- a.should == [1, 1, 1]
693
- errs.count.should == 2
694
- errs.each { |e| e.class.should == Sequel::DatabaseDisconnectError }
695
- calls.should == [1, 2]
696
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK', 'BEGIN', 'ROLLBACK', 'BEGIN', 'COMMIT']
697
+ a.must_equal [1, 1, 1]
698
+ errs.count.must_equal 2
699
+ errs.each { |e| e.class.must_equal Sequel::DatabaseDisconnectError }
700
+ calls.must_equal [1, 2]
696
701
  end
697
702
 
698
- specify "should raise an error if attempting to use :retry_on inside another transaction" do
699
- proc{@db.transaction{@db.transaction(:retry_on=>Sequel::ConstraintViolation){}}}.should raise_error(Sequel::Error)
700
- @db.sqls.should == ['BEGIN', 'ROLLBACK']
703
+ it "should raise an error if attempting to use :retry_on inside another transaction" do
704
+ proc{@db.transaction{@db.transaction(:retry_on=>Sequel::ConstraintViolation){}}}.must_raise(Sequel::Error)
705
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK']
701
706
  end
702
707
 
703
- specify "should handle returning inside of the block by committing" do
708
+ it "should handle returning inside of the block by committing" do
704
709
  def @db.ret_commit
705
710
  transaction do
706
711
  execute 'DROP TABLE test;'
@@ -708,17 +713,17 @@ shared_examples_for "Database#transaction" do
708
713
  end
709
714
  end
710
715
  @db.ret_commit
711
- @db.sqls.should == ['BEGIN', 'DROP TABLE test;', 'COMMIT']
716
+ @db.sqls.must_equal ['BEGIN', 'DROP TABLE test;', 'COMMIT']
712
717
  end
713
718
 
714
- specify "should issue ROLLBACK if an exception is raised, and re-raise" do
719
+ it "should issue ROLLBACK if an exception is raised, and re-raise" do
715
720
  @db.transaction {@db.execute 'DROP TABLE test'; raise RuntimeError} rescue nil
716
- @db.sqls.should == ['BEGIN', 'DROP TABLE test', 'ROLLBACK']
721
+ @db.sqls.must_equal ['BEGIN', 'DROP TABLE test', 'ROLLBACK']
717
722
 
718
- proc {@db.transaction {raise RuntimeError}}.should raise_error(RuntimeError)
723
+ proc {@db.transaction {raise RuntimeError}}.must_raise(RuntimeError)
719
724
  end
720
725
 
721
- specify "should handle errors when sending BEGIN" do
726
+ it "should handle errors when sending BEGIN" do
722
727
  ec = Class.new(StandardError)
723
728
  meta_def(@db, :database_error_classes){[ec]}
724
729
  meta_def(@db, :log_connection_execute){|c, sql| sql =~ /BEGIN/ ? raise(ec, 'bad') : super(c, sql)}
@@ -726,12 +731,12 @@ shared_examples_for "Database#transaction" do
726
731
  @db.transaction{@db.execute 'DROP TABLE test;'}
727
732
  rescue Sequel::DatabaseError => e
728
733
  end
729
- e.should_not be_nil
730
- e.wrapped_exception.should be_a_kind_of(ec)
731
- @db.sqls.should == ['ROLLBACK']
734
+ e.wont_equal nil
735
+ e.wrapped_exception.must_be_kind_of(ec)
736
+ @db.sqls.must_equal ['ROLLBACK']
732
737
  end
733
738
 
734
- specify "should handle errors when sending COMMIT" do
739
+ it "should handle errors when sending COMMIT" do
735
740
  ec = Class.new(StandardError)
736
741
  meta_def(@db, :database_error_classes){[ec]}
737
742
  meta_def(@db, :log_connection_execute){|c, sql| sql =~ /COMMIT/ ? raise(ec, 'bad') : super(c, sql)}
@@ -739,12 +744,12 @@ shared_examples_for "Database#transaction" do
739
744
  @db.transaction{@db.execute 'DROP TABLE test;'}
740
745
  rescue Sequel::DatabaseError => e
741
746
  end
742
- e.should_not be_nil
743
- e.wrapped_exception.should be_a_kind_of(ec)
744
- @db.sqls.should == ['BEGIN', 'DROP TABLE test;', 'ROLLBACK']
747
+ e.wont_equal nil
748
+ e.wrapped_exception.must_be_kind_of(ec)
749
+ @db.sqls.must_equal ['BEGIN', 'DROP TABLE test;', 'ROLLBACK']
745
750
  end
746
751
 
747
- specify "should raise original exception if there is an exception raised when rolling back" do
752
+ it "should raise original exception if there is an exception raised when rolling back" do
748
753
  ec = Class.new(StandardError)
749
754
  meta_def(@db, :database_error_classes){[ec]}
750
755
  meta_def(@db, :log_connection_execute){|c, sql| sql =~ /ROLLBACK/ ? raise(ec, 'bad') : super(c, sql)}
@@ -752,72 +757,72 @@ shared_examples_for "Database#transaction" do
752
757
  @db.transaction{raise ArgumentError, 'asdf'}
753
758
  rescue => e
754
759
  end
755
- e.should be_a_kind_of(ArgumentError)
756
- @db.sqls.should == ['BEGIN']
760
+ e.must_be_kind_of(ArgumentError)
761
+ @db.sqls.must_equal ['BEGIN']
757
762
  end
758
763
 
759
- specify "should issue ROLLBACK if Sequel::Rollback is called in the transaction" do
764
+ it "should issue ROLLBACK if Sequel::Rollback is called in the transaction" do
760
765
  @db.transaction do
761
766
  @db.drop_table(:a)
762
767
  raise Sequel::Rollback
763
768
  @db.drop_table(:b)
764
769
  end
765
770
 
766
- @db.sqls.should == ['BEGIN', 'DROP TABLE a', 'ROLLBACK']
771
+ @db.sqls.must_equal ['BEGIN', 'DROP TABLE a', 'ROLLBACK']
767
772
  end
768
773
 
769
- specify "should have in_transaction? return true if inside a transaction" do
774
+ it "should have in_transaction? return true if inside a transaction" do
770
775
  c = nil
771
776
  @db.transaction{c = @db.in_transaction?}
772
- c.should == true
777
+ c.must_equal true
773
778
  end
774
779
 
775
- specify "should have in_transaction? handle sharding correctly" do
780
+ it "should have in_transaction? handle sharding correctly" do
776
781
  c = []
777
782
  @db.transaction(:server=>:test){c << @db.in_transaction?}
778
783
  @db.transaction(:server=>:test){c << @db.in_transaction?(:server=>:test)}
779
- c.should == [false, true]
784
+ c.must_equal [false, true]
780
785
  end
781
786
 
782
- specify "should have in_transaction? return false if not in a transaction" do
783
- @db.in_transaction?.should == false
787
+ it "should have in_transaction? return false if not in a transaction" do
788
+ @db.in_transaction?.must_equal false
784
789
  end
785
790
 
786
- specify "should return nil if Sequel::Rollback is called in the transaction" do
787
- @db.transaction{raise Sequel::Rollback}.should be_nil
791
+ it "should return nil if Sequel::Rollback is called in the transaction" do
792
+ @db.transaction{raise Sequel::Rollback}.must_equal nil
788
793
  end
789
794
 
790
- specify "should reraise Sequel::Rollback errors when using :rollback=>:reraise option is given" do
791
- proc {@db.transaction(:rollback=>:reraise){raise Sequel::Rollback}}.should raise_error(Sequel::Rollback)
792
- @db.sqls.should == ['BEGIN', 'ROLLBACK']
793
- proc {@db.transaction(:rollback=>:reraise){raise ArgumentError}}.should raise_error(ArgumentError)
794
- @db.sqls.should == ['BEGIN', 'ROLLBACK']
795
- @db.transaction(:rollback=>:reraise){1}.should == 1
796
- @db.sqls.should == ['BEGIN', 'COMMIT']
795
+ it "should reraise Sequel::Rollback errors when using :rollback=>:reraise option is given" do
796
+ proc {@db.transaction(:rollback=>:reraise){raise Sequel::Rollback}}.must_raise(Sequel::Rollback)
797
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK']
798
+ proc {@db.transaction(:rollback=>:reraise){raise ArgumentError}}.must_raise(ArgumentError)
799
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK']
800
+ @db.transaction(:rollback=>:reraise){1}.must_equal 1
801
+ @db.sqls.must_equal ['BEGIN', 'COMMIT']
797
802
  end
798
803
 
799
- specify "should always rollback if :rollback=>:always option is given" do
800
- proc {@db.transaction(:rollback=>:always){raise ArgumentError}}.should raise_error(ArgumentError)
801
- @db.sqls.should == ['BEGIN', 'ROLLBACK']
802
- @db.transaction(:rollback=>:always){raise Sequel::Rollback}.should be_nil
803
- @db.sqls.should == ['BEGIN', 'ROLLBACK']
804
- @db.transaction(:rollback=>:always){1}.should be_nil
805
- @db.sqls.should == ['BEGIN', 'ROLLBACK']
804
+ it "should always rollback if :rollback=>:always option is given" do
805
+ proc {@db.transaction(:rollback=>:always){raise ArgumentError}}.must_raise(ArgumentError)
806
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK']
807
+ @db.transaction(:rollback=>:always){raise Sequel::Rollback}.must_equal nil
808
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK']
809
+ @db.transaction(:rollback=>:always){1}.must_equal 1
810
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK']
806
811
  catch(:foo) do
807
812
  @db.transaction(:rollback=>:always){throw :foo}
808
813
  end
809
- @db.sqls.should == ['BEGIN', 'ROLLBACK']
814
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK']
810
815
  end
811
-
812
- specify "should raise database errors when commiting a transaction as Sequel::DatabaseError" do
816
+
817
+ it "should raise database errors when commiting a transaction as Sequel::DatabaseError" do
813
818
  meta_def(@db, :commit_transaction){raise ArgumentError}
814
- lambda{@db.transaction{}}.should raise_error(ArgumentError)
819
+ lambda{@db.transaction{}}.must_raise(ArgumentError)
815
820
 
816
821
  meta_def(@db, :database_error_classes){[ArgumentError]}
817
- lambda{@db.transaction{}}.should raise_error(Sequel::DatabaseError)
822
+ lambda{@db.transaction{}}.must_raise(Sequel::DatabaseError)
818
823
  end
819
824
 
820
- specify "should be re-entrant" do
825
+ it "should be re-entrant" do
821
826
  q, q1 = Queue.new, Queue.new
822
827
  cc = nil
823
828
  t = Thread.new do
@@ -830,26 +835,26 @@ shared_examples_for "Database#transaction" do
830
835
  end
831
836
  q.push nil
832
837
  q1.pop
833
- cc.should be_a_kind_of(Sequel::Mock::Connection)
838
+ cc.must_be_kind_of(Sequel::Mock::Connection)
834
839
  tr = @db.instance_variable_get(:@transactions)
835
- tr.keys.should == [cc]
840
+ tr.keys.must_equal [cc]
836
841
  q.push nil
837
842
  t.join
838
- tr.should be_empty
843
+ tr.must_be :empty?
839
844
  end
840
845
 
841
- specify "should correctly handle nested transacation use with separate shards" do
846
+ it "should correctly handle nested transacation use with separate shards" do
842
847
  @db.transaction do |c1|
843
848
  @db.transaction(:server=>:test) do |c2|
844
- c1.should_not == c2
849
+ c1.wont_equal c2
845
850
  @db.execute 'DROP TABLE test;'
846
851
  end
847
852
  end
848
- @db.sqls.should == ['BEGIN', 'BEGIN -- test', 'DROP TABLE test;', 'COMMIT -- test', 'COMMIT']
853
+ @db.sqls.must_equal ['BEGIN', 'BEGIN -- test', 'DROP TABLE test;', 'COMMIT -- test', 'COMMIT']
849
854
  end
850
855
 
851
- if (!defined?(RUBY_ENGINE) or RUBY_ENGINE == 'ruby' or RUBY_ENGINE == 'rbx') and !RUBY_VERSION.start_with?('1.9')
852
- specify "should handle Thread#kill for transactions inside threads" do
856
+ if (!defined?(RUBY_ENGINE) or RUBY_ENGINE == 'ruby') and !RUBY_VERSION.start_with?('1.9')
857
+ it "should handle Thread#kill for transactions inside threads" do
853
858
  q = Queue.new
854
859
  q1 = Queue.new
855
860
  t = Thread.new do
@@ -863,92 +868,92 @@ shared_examples_for "Database#transaction" do
863
868
  q1.pop
864
869
  t.kill
865
870
  t.join
866
- @db.sqls.should == ['BEGIN', 'DROP TABLE test', 'ROLLBACK']
871
+ @db.sqls.must_equal ['BEGIN', 'DROP TABLE test', 'ROLLBACK']
867
872
  end
868
873
  end
869
874
 
870
- specify "should raise an Error if after_commit or after_rollback is called without a block" do
871
- proc{@db.after_commit}.should raise_error(Sequel::Error)
872
- proc{@db.after_rollback}.should raise_error(Sequel::Error)
875
+ it "should raise an Error if after_commit or after_rollback is called without a block" do
876
+ proc{@db.after_commit}.must_raise(Sequel::Error)
877
+ proc{@db.after_rollback}.must_raise(Sequel::Error)
873
878
  end
874
879
 
875
- specify "should have after_commit and after_rollback respect :server option" do
880
+ it "should have after_commit and after_rollback respect :server option" do
876
881
  @db.transaction(:server=>:test){@db.after_commit(:server=>:test){@db.execute('foo', :server=>:test)}}
877
- @db.sqls.should == ['BEGIN -- test', 'COMMIT -- test', 'foo -- test']
882
+ @db.sqls.must_equal ['BEGIN -- test', 'COMMIT -- test', 'foo -- test']
878
883
  @db.transaction(:server=>:test){@db.after_rollback(:server=>:test){@db.execute('foo', :server=>:test)}; raise Sequel::Rollback}
879
- @db.sqls.should == ['BEGIN -- test', 'ROLLBACK -- test', 'foo -- test']
884
+ @db.sqls.must_equal ['BEGIN -- test', 'ROLLBACK -- test', 'foo -- test']
880
885
  end
881
886
 
882
- specify "should execute after_commit outside transactions" do
887
+ it "should execute after_commit outside transactions" do
883
888
  @db.after_commit{@db.execute('foo')}
884
- @db.sqls.should == ['foo']
889
+ @db.sqls.must_equal ['foo']
885
890
  end
886
891
 
887
- specify "should ignore after_rollback outside transactions" do
892
+ it "should ignore after_rollback outside transactions" do
888
893
  @db.after_rollback{@db.execute('foo')}
889
- @db.sqls.should == []
894
+ @db.sqls.must_equal []
890
895
  end
891
896
 
892
- specify "should support after_commit inside transactions" do
897
+ it "should support after_commit inside transactions" do
893
898
  @db.transaction{@db.after_commit{@db.execute('foo')}}
894
- @db.sqls.should == ['BEGIN', 'COMMIT', 'foo']
899
+ @db.sqls.must_equal ['BEGIN', 'COMMIT', 'foo']
895
900
  end
896
901
 
897
- specify "should support after_rollback inside transactions" do
902
+ it "should support after_rollback inside transactions" do
898
903
  @db.transaction{@db.after_rollback{@db.execute('foo')}}
899
- @db.sqls.should == ['BEGIN', 'COMMIT']
904
+ @db.sqls.must_equal ['BEGIN', 'COMMIT']
900
905
  end
901
906
 
902
- specify "should have transaction inside after_commit work correctly" do
907
+ it "should have transaction inside after_commit work correctly" do
903
908
  @db.transaction{@db.after_commit{@db.transaction{@db.execute('foo')}}}
904
- @db.sqls.should == ['BEGIN', 'COMMIT', 'BEGIN', 'foo', 'COMMIT']
909
+ @db.sqls.must_equal ['BEGIN', 'COMMIT', 'BEGIN', 'foo', 'COMMIT']
905
910
  end
906
911
 
907
- specify "should have transaction inside after_rollback work correctly" do
912
+ it "should have transaction inside after_rollback work correctly" do
908
913
  @db.transaction(:rollback=>:always){@db.after_rollback{@db.transaction{@db.execute('foo')}}}
909
- @db.sqls.should == ['BEGIN', 'ROLLBACK', 'BEGIN', 'foo', 'COMMIT']
914
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK', 'BEGIN', 'foo', 'COMMIT']
910
915
  end
911
916
 
912
- specify "should not call after_commit if the transaction rolls back" do
917
+ it "should not call after_commit if the transaction rolls back" do
913
918
  @db.transaction{@db.after_commit{@db.execute('foo')}; raise Sequel::Rollback}
914
- @db.sqls.should == ['BEGIN', 'ROLLBACK']
919
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK']
915
920
  end
916
921
 
917
- specify "should call after_rollback if the transaction rolls back" do
922
+ it "should call after_rollback if the transaction rolls back" do
918
923
  @db.transaction{@db.after_rollback{@db.execute('foo')}; raise Sequel::Rollback}
919
- @db.sqls.should == ['BEGIN', 'ROLLBACK', 'foo']
924
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK', 'foo']
920
925
  end
921
926
 
922
- specify "should call multiple after_commit blocks in order if called inside transactions" do
927
+ it "should call multiple after_commit blocks in order if called inside transactions" do
923
928
  @db.transaction{@db.after_commit{@db.execute('foo')}; @db.after_commit{@db.execute('bar')}}
924
- @db.sqls.should == ['BEGIN', 'COMMIT', 'foo', 'bar']
929
+ @db.sqls.must_equal ['BEGIN', 'COMMIT', 'foo', 'bar']
925
930
  end
926
931
 
927
- specify "should call multiple after_rollback blocks in order if called inside transactions" do
932
+ it "should call multiple after_rollback blocks in order if called inside transactions" do
928
933
  @db.transaction{@db.after_rollback{@db.execute('foo')}; @db.after_rollback{@db.execute('bar')}; raise Sequel::Rollback}
929
- @db.sqls.should == ['BEGIN', 'ROLLBACK', 'foo', 'bar']
934
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK', 'foo', 'bar']
930
935
  end
931
936
 
932
- specify "should support after_commit inside nested transactions" do
937
+ it "should support after_commit inside nested transactions" do
933
938
  @db.transaction{@db.transaction{@db.after_commit{@db.execute('foo')}}}
934
- @db.sqls.should == ['BEGIN', 'COMMIT', 'foo']
939
+ @db.sqls.must_equal ['BEGIN', 'COMMIT', 'foo']
935
940
  end
936
941
 
937
- specify "should support after_rollback inside nested transactions" do
942
+ it "should support after_rollback inside nested transactions" do
938
943
  @db.transaction{@db.transaction{@db.after_rollback{@db.execute('foo')}}; raise Sequel::Rollback}
939
- @db.sqls.should == ['BEGIN', 'ROLLBACK', 'foo']
944
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK', 'foo']
940
945
  end
941
946
 
942
- specify "should raise an error if you attempt to use after_commit inside a prepared transaction" do
947
+ it "should raise an error if you attempt to use after_commit inside a prepared transaction" do
943
948
  meta_def(@db, :supports_prepared_transactions?){true}
944
- proc{@db.transaction(:prepare=>'XYZ'){@db.after_commit{@db.execute('foo')}}}.should raise_error(Sequel::Error)
945
- @db.sqls.should == ['BEGIN', 'ROLLBACK']
949
+ proc{@db.transaction(:prepare=>'XYZ'){@db.after_commit{@db.execute('foo')}}}.must_raise(Sequel::Error)
950
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK']
946
951
  end
947
952
 
948
- specify "should raise an error if you attempt to use after_rollback inside a prepared transaction" do
953
+ it "should raise an error if you attempt to use after_rollback inside a prepared transaction" do
949
954
  meta_def(@db, :supports_prepared_transactions?){true}
950
- proc{@db.transaction(:prepare=>'XYZ'){@db.after_rollback{@db.execute('foo')}}}.should raise_error(Sequel::Error)
951
- @db.sqls.should == ['BEGIN', 'ROLLBACK']
955
+ proc{@db.transaction(:prepare=>'XYZ'){@db.after_rollback{@db.execute('foo')}}}.must_raise(Sequel::Error)
956
+ @db.sqls.must_equal ['BEGIN', 'ROLLBACK']
952
957
  end
953
958
  end
954
959
 
@@ -957,37 +962,37 @@ describe "Database#transaction with savepoint support" do
957
962
  @db = Sequel.mock(:servers=>{:test=>{}})
958
963
  end
959
964
 
960
- it_should_behave_like "Database#transaction"
965
+ include DatabaseTransactionSpecs
961
966
 
962
- specify "should support after_commit inside savepoints" do
967
+ it "should support after_commit inside savepoints" do
963
968
  @db.transaction do
964
969
  @db.after_commit{@db.execute('foo')}
965
970
  @db.transaction(:savepoint=>true){@db.after_commit{@db.execute('bar')}}
966
971
  @db.after_commit{@db.execute('baz')}
967
972
  end
968
- @db.sqls.should == ['BEGIN', 'SAVEPOINT autopoint_1', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT', 'foo', 'bar', 'baz']
973
+ @db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT', 'foo', 'bar', 'baz']
969
974
  end
970
975
 
971
- specify "should support after_rollback inside savepoints" do
976
+ it "should support after_rollback inside savepoints" do
972
977
  @db.transaction do
973
978
  @db.after_rollback{@db.execute('foo')}
974
979
  @db.transaction(:savepoint=>true){@db.after_rollback{@db.execute('bar')}}
975
980
  @db.after_rollback{@db.execute('baz')}
976
981
  raise Sequel::Rollback
977
982
  end
978
- @db.sqls.should == ['BEGIN', 'SAVEPOINT autopoint_1', 'RELEASE SAVEPOINT autopoint_1', 'ROLLBACK', 'foo', 'bar', 'baz']
983
+ @db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1', 'RELEASE SAVEPOINT autopoint_1', 'ROLLBACK', 'foo', 'bar', 'baz']
979
984
  end
980
985
 
981
- specify "should raise an error if you attempt to use after_commit inside a savepoint in a prepared transaction" do
986
+ it "should raise an error if you attempt to use after_commit inside a savepoint in a prepared transaction" do
982
987
  meta_def(@db, :supports_prepared_transactions?){true}
983
- proc{@db.transaction(:prepare=>'XYZ'){@db.transaction(:savepoint=>true){@db.after_commit{@db.execute('foo')}}}}.should raise_error(Sequel::Error)
984
- @db.sqls.should == ['BEGIN', 'SAVEPOINT autopoint_1','ROLLBACK TO SAVEPOINT autopoint_1', 'ROLLBACK']
988
+ proc{@db.transaction(:prepare=>'XYZ'){@db.transaction(:savepoint=>true){@db.after_commit{@db.execute('foo')}}}}.must_raise(Sequel::Error)
989
+ @db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1','ROLLBACK TO SAVEPOINT autopoint_1', 'ROLLBACK']
985
990
  end
986
991
 
987
- specify "should raise an error if you attempt to use after_rollback inside a savepoint in a prepared transaction" do
992
+ it "should raise an error if you attempt to use after_rollback inside a savepoint in a prepared transaction" do
988
993
  meta_def(@db, :supports_prepared_transactions?){true}
989
- proc{@db.transaction(:prepare=>'XYZ'){@db.transaction(:savepoint=>true){@db.after_rollback{@db.execute('foo')}}}}.should raise_error(Sequel::Error)
990
- @db.sqls.should == ['BEGIN', 'SAVEPOINT autopoint_1','ROLLBACK TO SAVEPOINT autopoint_1', 'ROLLBACK']
994
+ proc{@db.transaction(:prepare=>'XYZ'){@db.transaction(:savepoint=>true){@db.after_rollback{@db.execute('foo')}}}}.must_raise(Sequel::Error)
995
+ @db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1','ROLLBACK TO SAVEPOINT autopoint_1', 'ROLLBACK']
991
996
  end
992
997
  end
993
998
 
@@ -997,7 +1002,7 @@ describe "Database#transaction without savepoint support" do
997
1002
  meta_def(@db, :supports_savepoints?){false}
998
1003
  end
999
1004
 
1000
- it_should_behave_like "Database#transaction"
1005
+ include DatabaseTransactionSpecs
1001
1006
  end
1002
1007
 
1003
1008
  describe "Sequel.transaction" do
@@ -1008,29 +1013,29 @@ describe "Sequel.transaction" do
1008
1013
  @db3 = Sequel.mock(:append=>'3', :sqls=>@sqls)
1009
1014
  end
1010
1015
 
1011
- specify "should run the block inside transacitons on all three databases" do
1012
- Sequel.transaction([@db1, @db2, @db3]){1}.should == 1
1013
- @sqls.should == ['BEGIN -- 1', 'BEGIN -- 2', 'BEGIN -- 3', 'COMMIT -- 3', 'COMMIT -- 2', 'COMMIT -- 1']
1016
+ it "should run the block inside transacitons on all three databases" do
1017
+ Sequel.transaction([@db1, @db2, @db3]){1}.must_equal 1
1018
+ @sqls.must_equal ['BEGIN -- 1', 'BEGIN -- 2', 'BEGIN -- 3', 'COMMIT -- 3', 'COMMIT -- 2', 'COMMIT -- 1']
1014
1019
  end
1015
1020
 
1016
- specify "should pass options to all the blocks" do
1017
- Sequel.transaction([@db1, @db2, @db3], :rollback=>:always){1}.should be_nil
1018
- @sqls.should == ['BEGIN -- 1', 'BEGIN -- 2', 'BEGIN -- 3', 'ROLLBACK -- 3', 'ROLLBACK -- 2', 'ROLLBACK -- 1']
1021
+ it "should pass options to all the blocks" do
1022
+ Sequel.transaction([@db1, @db2, @db3], :rollback=>:always){1}.must_equal 1
1023
+ @sqls.must_equal ['BEGIN -- 1', 'BEGIN -- 2', 'BEGIN -- 3', 'ROLLBACK -- 3', 'ROLLBACK -- 2', 'ROLLBACK -- 1']
1019
1024
  end
1020
1025
 
1021
- specify "should handle Sequel::Rollback exceptions raised by the block to rollback on all databases" do
1022
- Sequel.transaction([@db1, @db2, @db3]){raise Sequel::Rollback}.should be_nil
1023
- @sqls.should == ['BEGIN -- 1', 'BEGIN -- 2', 'BEGIN -- 3', 'ROLLBACK -- 3', 'ROLLBACK -- 2', 'ROLLBACK -- 1']
1026
+ it "should handle Sequel::Rollback exceptions raised by the block to rollback on all databases" do
1027
+ Sequel.transaction([@db1, @db2, @db3]){raise Sequel::Rollback}.must_equal nil
1028
+ @sqls.must_equal ['BEGIN -- 1', 'BEGIN -- 2', 'BEGIN -- 3', 'ROLLBACK -- 3', 'ROLLBACK -- 2', 'ROLLBACK -- 1']
1024
1029
  end
1025
1030
 
1026
- specify "should handle nested transactions" do
1027
- Sequel.transaction([@db1, @db2, @db3]){Sequel.transaction([@db1, @db2, @db3]){1}}.should == 1
1028
- @sqls.should == ['BEGIN -- 1', 'BEGIN -- 2', 'BEGIN -- 3', 'COMMIT -- 3', 'COMMIT -- 2', 'COMMIT -- 1']
1031
+ it "should handle nested transactions" do
1032
+ Sequel.transaction([@db1, @db2, @db3]){Sequel.transaction([@db1, @db2, @db3]){1}}.must_equal 1
1033
+ @sqls.must_equal ['BEGIN -- 1', 'BEGIN -- 2', 'BEGIN -- 3', 'COMMIT -- 3', 'COMMIT -- 2', 'COMMIT -- 1']
1029
1034
  end
1030
1035
 
1031
- specify "should handle savepoints" do
1032
- Sequel.transaction([@db1, @db2, @db3]){Sequel.transaction([@db1, @db2, @db3], :savepoint=>true){1}}.should == 1
1033
- @sqls.should == ['BEGIN -- 1', 'BEGIN -- 2', 'BEGIN -- 3',
1036
+ it "should handle savepoints" do
1037
+ Sequel.transaction([@db1, @db2, @db3]){Sequel.transaction([@db1, @db2, @db3], :savepoint=>true){1}}.must_equal 1
1038
+ @sqls.must_equal ['BEGIN -- 1', 'BEGIN -- 2', 'BEGIN -- 3',
1034
1039
  'SAVEPOINT autopoint_1 -- 1', 'SAVEPOINT autopoint_1 -- 2', 'SAVEPOINT autopoint_1 -- 3',
1035
1040
  'RELEASE SAVEPOINT autopoint_1 -- 3', 'RELEASE SAVEPOINT autopoint_1 -- 2', 'RELEASE SAVEPOINT autopoint_1 -- 1',
1036
1041
  'COMMIT -- 3', 'COMMIT -- 2', 'COMMIT -- 1']
@@ -1042,46 +1047,46 @@ describe "Database#transaction with savepoints" do
1042
1047
  @db = Sequel.mock
1043
1048
  end
1044
1049
 
1045
- specify "should wrap the supplied block with BEGIN + COMMIT statements" do
1050
+ it "should wrap the supplied block with BEGIN + COMMIT statements" do
1046
1051
  @db.transaction {@db.execute 'DROP TABLE test;'}
1047
- @db.sqls.should == ['BEGIN', 'DROP TABLE test;', 'COMMIT']
1052
+ @db.sqls.must_equal ['BEGIN', 'DROP TABLE test;', 'COMMIT']
1048
1053
  end
1049
1054
 
1050
- specify "should use savepoints if given the :savepoint option" do
1055
+ it "should use savepoints if given the :savepoint option" do
1051
1056
  @db.transaction{@db.transaction(:savepoint=>true){@db.execute 'DROP TABLE test;'}}
1052
- @db.sqls.should == ['BEGIN', 'SAVEPOINT autopoint_1', 'DROP TABLE test;', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT']
1057
+ @db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1', 'DROP TABLE test;', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT']
1053
1058
  end
1054
1059
 
1055
- specify "should use savepoints if surrounding transaction uses :auto_savepoint option" do
1060
+ it "should use savepoints if surrounding transaction uses :auto_savepoint option" do
1056
1061
  @db.transaction(:auto_savepoint=>true){@db.transaction{@db.execute 'DROP TABLE test;'}}
1057
- @db.sqls.should == ['BEGIN', 'SAVEPOINT autopoint_1', 'DROP TABLE test;', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT']
1062
+ @db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1', 'DROP TABLE test;', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT']
1058
1063
 
1059
1064
  @db.transaction(:auto_savepoint=>true){@db.transaction{@db.transaction{@db.execute 'DROP TABLE test;'}}}
1060
- @db.sqls.should == ['BEGIN', 'SAVEPOINT autopoint_1', 'DROP TABLE test;', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT']
1065
+ @db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1', 'DROP TABLE test;', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT']
1061
1066
 
1062
1067
  @db.transaction(:auto_savepoint=>true){@db.transaction(:auto_savepoint=>true){@db.transaction{@db.execute 'DROP TABLE test;'}}}
1063
- @db.sqls.should == ['BEGIN', 'SAVEPOINT autopoint_1', 'SAVEPOINT autopoint_2', 'DROP TABLE test;', 'RELEASE SAVEPOINT autopoint_2', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT']
1068
+ @db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1', 'SAVEPOINT autopoint_2', 'DROP TABLE test;', 'RELEASE SAVEPOINT autopoint_2', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT']
1064
1069
 
1065
1070
  @db.transaction{@db.transaction(:auto_savepoint=>true, :savepoint=>true){@db.transaction{@db.execute 'DROP TABLE test;'}}}
1066
- @db.sqls.should == ['BEGIN', 'SAVEPOINT autopoint_1', 'SAVEPOINT autopoint_2', 'DROP TABLE test;', 'RELEASE SAVEPOINT autopoint_2', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT']
1071
+ @db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1', 'SAVEPOINT autopoint_2', 'DROP TABLE test;', 'RELEASE SAVEPOINT autopoint_2', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT']
1067
1072
  end
1068
1073
 
1069
- specify "should not use savepoints if surrounding transaction uses :auto_savepoint and current transaction uses :savepoint=>false option" do
1074
+ it "should not use savepoints if surrounding transaction uses :auto_savepoint and current transaction uses :savepoint=>false option" do
1070
1075
  @db.transaction(:auto_savepoint=>true){@db.transaction(:savepoint=>false){@db.execute 'DROP TABLE test;'}}
1071
- @db.sqls.should == ['BEGIN', 'DROP TABLE test;', 'COMMIT']
1076
+ @db.sqls.must_equal ['BEGIN', 'DROP TABLE test;', 'COMMIT']
1072
1077
  end
1073
1078
 
1074
- specify "should not use a savepoint if no transaction is in progress" do
1079
+ it "should not use a savepoint if no transaction is in progress" do
1075
1080
  @db.transaction(:savepoint=>true){@db.execute 'DROP TABLE test;'}
1076
- @db.sqls.should == ['BEGIN', 'DROP TABLE test;', 'COMMIT']
1081
+ @db.sqls.must_equal ['BEGIN', 'DROP TABLE test;', 'COMMIT']
1077
1082
  end
1078
1083
 
1079
- specify "should reuse the current transaction if no :savepoint option is given" do
1084
+ it "should reuse the current transaction if no :savepoint option is given" do
1080
1085
  @db.transaction{@db.transaction{@db.execute 'DROP TABLE test;'}}
1081
- @db.sqls.should == ['BEGIN', 'DROP TABLE test;', 'COMMIT']
1086
+ @db.sqls.must_equal ['BEGIN', 'DROP TABLE test;', 'COMMIT']
1082
1087
  end
1083
1088
 
1084
- specify "should handle returning inside of the block by committing" do
1089
+ it "should handle returning inside of the block by committing" do
1085
1090
  def @db.ret_commit
1086
1091
  transaction do
1087
1092
  execute 'DROP TABLE test;'
@@ -1089,10 +1094,10 @@ describe "Database#transaction with savepoints" do
1089
1094
  end
1090
1095
  end
1091
1096
  @db.ret_commit
1092
- @db.sqls.should == ['BEGIN', 'DROP TABLE test;', 'COMMIT']
1097
+ @db.sqls.must_equal ['BEGIN', 'DROP TABLE test;', 'COMMIT']
1093
1098
  end
1094
1099
 
1095
- specify "should handle returning inside of a savepoint by committing" do
1100
+ it "should handle returning inside of a savepoint by committing" do
1096
1101
  def @db.ret_commit
1097
1102
  transaction do
1098
1103
  transaction(:savepoint=>true) do
@@ -1102,34 +1107,34 @@ describe "Database#transaction with savepoints" do
1102
1107
  end
1103
1108
  end
1104
1109
  @db.ret_commit
1105
- @db.sqls.should == ['BEGIN', 'SAVEPOINT autopoint_1', 'DROP TABLE test;', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT']
1110
+ @db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1', 'DROP TABLE test;', 'RELEASE SAVEPOINT autopoint_1', 'COMMIT']
1106
1111
  end
1107
1112
 
1108
- specify "should issue ROLLBACK if an exception is raised, and re-raise" do
1113
+ it "should issue ROLLBACK if an exception is raised, and re-raise" do
1109
1114
  @db.transaction {@db.execute 'DROP TABLE test'; raise RuntimeError} rescue nil
1110
- @db.sqls.should == ['BEGIN', 'DROP TABLE test', 'ROLLBACK']
1115
+ @db.sqls.must_equal ['BEGIN', 'DROP TABLE test', 'ROLLBACK']
1111
1116
 
1112
- proc {@db.transaction {raise RuntimeError}}.should raise_error(RuntimeError)
1117
+ proc {@db.transaction {raise RuntimeError}}.must_raise(RuntimeError)
1113
1118
  end
1114
1119
 
1115
- specify "should issue ROLLBACK SAVEPOINT if an exception is raised inside a savepoint, and re-raise" do
1120
+ it "should issue ROLLBACK SAVEPOINT if an exception is raised inside a savepoint, and re-raise" do
1116
1121
  @db.transaction{@db.transaction(:savepoint=>true){@db.execute 'DROP TABLE test'; raise RuntimeError}} rescue nil
1117
- @db.sqls.should == ['BEGIN', 'SAVEPOINT autopoint_1', 'DROP TABLE test', 'ROLLBACK TO SAVEPOINT autopoint_1', 'ROLLBACK']
1122
+ @db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1', 'DROP TABLE test', 'ROLLBACK TO SAVEPOINT autopoint_1', 'ROLLBACK']
1118
1123
 
1119
- proc {@db.transaction {raise RuntimeError}}.should raise_error(RuntimeError)
1124
+ proc {@db.transaction {raise RuntimeError}}.must_raise(RuntimeError)
1120
1125
  end
1121
1126
 
1122
- specify "should issue ROLLBACK if Sequel::Rollback is raised in the transaction" do
1127
+ it "should issue ROLLBACK if Sequel::Rollback is raised in the transaction" do
1123
1128
  @db.transaction do
1124
1129
  @db.drop_table(:a)
1125
1130
  raise Sequel::Rollback
1126
1131
  @db.drop_table(:b)
1127
1132
  end
1128
1133
 
1129
- @db.sqls.should == ['BEGIN', 'DROP TABLE a', 'ROLLBACK']
1134
+ @db.sqls.must_equal ['BEGIN', 'DROP TABLE a', 'ROLLBACK']
1130
1135
  end
1131
1136
 
1132
- specify "should issue ROLLBACK SAVEPOINT if Sequel::Rollback is raised in a savepoint" do
1137
+ it "should issue ROLLBACK SAVEPOINT if Sequel::Rollback is raised in a savepoint" do
1133
1138
  @db.transaction do
1134
1139
  @db.transaction(:savepoint=>true) do
1135
1140
  @db.drop_table(:a)
@@ -1138,58 +1143,59 @@ describe "Database#transaction with savepoints" do
1138
1143
  @db.drop_table(:b)
1139
1144
  end
1140
1145
 
1141
- @db.sqls.should == ['BEGIN', 'SAVEPOINT autopoint_1', 'DROP TABLE a', 'ROLLBACK TO SAVEPOINT autopoint_1', 'DROP TABLE b', 'COMMIT']
1146
+ @db.sqls.must_equal ['BEGIN', 'SAVEPOINT autopoint_1', 'DROP TABLE a', 'ROLLBACK TO SAVEPOINT autopoint_1', 'DROP TABLE b', 'COMMIT']
1142
1147
  end
1143
1148
 
1144
- specify "should raise database errors when commiting a transaction as Sequel::DatabaseError" do
1149
+ it "should raise database errors when commiting a transaction as Sequel::DatabaseError" do
1145
1150
  meta_def(@db, :commit_transaction){raise ArgumentError}
1146
- lambda{@db.transaction{}}.should raise_error(ArgumentError)
1147
- lambda{@db.transaction{@db.transaction(:savepoint=>true){}}}.should raise_error(ArgumentError)
1151
+ lambda{@db.transaction{}}.must_raise(ArgumentError)
1152
+ lambda{@db.transaction{@db.transaction(:savepoint=>true){}}}.must_raise(ArgumentError)
1148
1153
 
1149
1154
  meta_def(@db, :database_error_classes){[ArgumentError]}
1150
- lambda{@db.transaction{}}.should raise_error(Sequel::DatabaseError)
1151
- lambda{@db.transaction{@db.transaction(:savepoint=>true){}}}.should raise_error(Sequel::DatabaseError)
1155
+ lambda{@db.transaction{}}.must_raise(Sequel::DatabaseError)
1156
+ lambda{@db.transaction{@db.transaction(:savepoint=>true){}}}.must_raise(Sequel::DatabaseError)
1152
1157
  end
1153
1158
  end
1154
1159
 
1155
1160
  describe "A Database adapter with a scheme" do
1156
1161
  before do
1162
+ require 'sequel/adapters/mock'
1157
1163
  @ccc = Class.new(Sequel::Mock::Database)
1158
1164
  @ccc.send(:set_adapter_scheme, :ccc)
1159
1165
  end
1160
1166
 
1161
- specify "should be registered in the ADAPTER_MAP" do
1162
- Sequel::ADAPTER_MAP[:ccc].should == @ccc
1167
+ it "should be registered in the ADAPTER_MAP" do
1168
+ Sequel::ADAPTER_MAP[:ccc].must_equal @ccc
1163
1169
  end
1164
1170
 
1165
- specify "should give the database_type as the adapter scheme by default" do
1166
- @ccc.new.database_type.should == :ccc
1171
+ it "should give the database_type as the adapter scheme by default" do
1172
+ @ccc.new.database_type.must_equal :ccc
1167
1173
  end
1168
1174
 
1169
- specify "should be instantiated when its scheme is specified" do
1175
+ it "should be instantiated when its scheme is specified" do
1170
1176
  c = Sequel::Database.connect('ccc://localhost/db')
1171
- c.should be_a_kind_of(@ccc)
1172
- c.opts[:host].should == 'localhost'
1173
- c.opts[:database].should == 'db'
1177
+ c.must_be_kind_of(@ccc)
1178
+ c.opts[:host].must_equal 'localhost'
1179
+ c.opts[:database].must_equal 'db'
1174
1180
  end
1175
1181
 
1176
- specify "should be accessible through Sequel.connect" do
1182
+ it "should be accessible through Sequel.connect" do
1177
1183
  c = Sequel.connect 'ccc://localhost/db'
1178
- c.should be_a_kind_of(@ccc)
1179
- c.opts[:host].should == 'localhost'
1180
- c.opts[:database].should == 'db'
1184
+ c.must_be_kind_of(@ccc)
1185
+ c.opts[:host].must_equal 'localhost'
1186
+ c.opts[:database].must_equal 'db'
1181
1187
  end
1182
1188
 
1183
- specify "should be accessible through Sequel.connect via a block" do
1189
+ it "should be accessible through Sequel.connect via a block" do
1184
1190
  x = nil
1185
1191
  y = nil
1186
1192
  z = nil
1187
1193
  returnValue = 'anything'
1188
1194
 
1189
1195
  p = proc do |c|
1190
- c.should be_a_kind_of(@ccc)
1191
- c.opts[:host].should == 'localhost'
1192
- c.opts[:database].should == 'db'
1196
+ c.must_be_kind_of(@ccc)
1197
+ c.opts[:host].must_equal 'localhost'
1198
+ c.opts[:database].must_equal 'db'
1193
1199
  z = y
1194
1200
  y = x
1195
1201
  x = c
@@ -1202,109 +1208,109 @@ describe "A Database adapter with a scheme" do
1202
1208
  self.class::DISCONNECTS << self
1203
1209
  end
1204
1210
  end
1205
- Sequel::Database.connect('ccc://localhost/db', &p).should == returnValue
1206
- @ccc::DISCONNECTS.should == [x]
1211
+ Sequel::Database.connect('ccc://localhost/db', &p).must_equal returnValue
1212
+ @ccc::DISCONNECTS.must_equal [x]
1207
1213
 
1208
- Sequel.connect('ccc://localhost/db', &p).should == returnValue
1209
- @ccc::DISCONNECTS.should == [y, x]
1214
+ Sequel.connect('ccc://localhost/db', &p).must_equal returnValue
1215
+ @ccc::DISCONNECTS.must_equal [y, x]
1210
1216
 
1211
1217
  Sequel.send(:def_adapter_method, :ccc)
1212
- Sequel.ccc('db', :host=>'localhost', &p).should == returnValue
1213
- @ccc::DISCONNECTS.should == [z, y, x]
1218
+ Sequel.ccc('db', :host=>'localhost', &p).must_equal returnValue
1219
+ @ccc::DISCONNECTS.must_equal [z, y, x]
1214
1220
  class << Sequel; remove_method(:ccc) end
1215
1221
  end
1216
1222
 
1217
- specify "should be accessible through Sequel.<adapter>" do
1223
+ it "should be accessible through Sequel.<adapter>" do
1218
1224
  Sequel.send(:def_adapter_method, :ccc)
1219
1225
 
1220
1226
  # invalid parameters
1221
- proc {Sequel.ccc('abc', 'def')}.should raise_error(Sequel::Error)
1222
- proc {Sequel.ccc(1)}.should raise_error(Sequel::Error)
1227
+ proc {Sequel.ccc('abc', 'def')}.must_raise(Sequel::Error)
1228
+ proc {Sequel.ccc(1)}.must_raise(Sequel::Error)
1223
1229
 
1224
1230
  c = Sequel.ccc('mydb')
1225
- c.should be_a_kind_of(@ccc)
1226
- c.opts.values_at(:adapter, :database, :adapter_class).should == [:ccc, 'mydb', @ccc]
1231
+ c.must_be_kind_of(@ccc)
1232
+ c.opts.values_at(:adapter, :database, :adapter_class).must_equal [:ccc, 'mydb', @ccc]
1227
1233
 
1228
1234
  c = Sequel.ccc('mydb', :host => 'localhost')
1229
- c.should be_a_kind_of(@ccc)
1230
- c.opts.values_at(:adapter, :database, :host, :adapter_class).should == [:ccc, 'mydb', 'localhost', @ccc]
1235
+ c.must_be_kind_of(@ccc)
1236
+ c.opts.values_at(:adapter, :database, :host, :adapter_class).must_equal [:ccc, 'mydb', 'localhost', @ccc]
1231
1237
 
1232
1238
  c = Sequel.ccc
1233
- c.should be_a_kind_of(@ccc)
1234
- c.opts.values_at(:adapter, :adapter_class).should == [:ccc, @ccc]
1239
+ c.must_be_kind_of(@ccc)
1240
+ c.opts.values_at(:adapter, :adapter_class).must_equal [:ccc, @ccc]
1235
1241
 
1236
1242
  c = Sequel.ccc(:database => 'mydb', :host => 'localhost')
1237
- c.should be_a_kind_of(@ccc)
1238
- c.opts.values_at(:adapter, :database, :host, :adapter_class).should == [:ccc, 'mydb', 'localhost', @ccc]
1243
+ c.must_be_kind_of(@ccc)
1244
+ c.opts.values_at(:adapter, :database, :host, :adapter_class).must_equal [:ccc, 'mydb', 'localhost', @ccc]
1239
1245
  class << Sequel; remove_method(:ccc) end
1240
1246
  end
1241
1247
 
1242
- specify "should be accessible through Sequel.connect with options" do
1248
+ it "should be accessible through Sequel.connect with options" do
1243
1249
  c = Sequel.connect(:adapter => :ccc, :database => 'mydb')
1244
- c.should be_a_kind_of(@ccc)
1245
- c.opts[:adapter].should == :ccc
1250
+ c.must_be_kind_of(@ccc)
1251
+ c.opts[:adapter].must_equal :ccc
1246
1252
  end
1247
1253
 
1248
- specify "should be accessible through Sequel.connect with URL parameters" do
1254
+ it "should be accessible through Sequel.connect with URL parameters" do
1249
1255
  c = Sequel.connect 'ccc:///db?host=/tmp&user=test'
1250
- c.should be_a_kind_of(@ccc)
1251
- c.opts[:host].should == '/tmp'
1252
- c.opts[:database].should == 'db'
1253
- c.opts[:user].should == 'test'
1256
+ c.must_be_kind_of(@ccc)
1257
+ c.opts[:host].must_equal '/tmp'
1258
+ c.opts[:database].must_equal 'db'
1259
+ c.opts[:user].must_equal 'test'
1254
1260
  end
1255
1261
 
1256
- specify "should have URL parameters take precedence over fixed URL parts" do
1262
+ it "should have URL parameters take precedence over fixed URL parts" do
1257
1263
  c = Sequel.connect 'ccc://localhost/db?host=a&database=b'
1258
- c.should be_a_kind_of(@ccc)
1259
- c.opts[:host].should == 'a'
1260
- c.opts[:database].should == 'b'
1264
+ c.must_be_kind_of(@ccc)
1265
+ c.opts[:host].must_equal 'a'
1266
+ c.opts[:database].must_equal 'b'
1261
1267
  end
1262
1268
 
1263
- specify "should have hash options take predence over URL parameters or parts" do
1269
+ it "should have hash options take predence over URL parameters or parts" do
1264
1270
  c = Sequel.connect 'ccc://localhost/db?host=/tmp', :host=>'a', :database=>'b', :user=>'c'
1265
- c.should be_a_kind_of(@ccc)
1266
- c.opts[:host].should == 'a'
1267
- c.opts[:database].should == 'b'
1268
- c.opts[:user].should == 'c'
1271
+ c.must_be_kind_of(@ccc)
1272
+ c.opts[:host].must_equal 'a'
1273
+ c.opts[:database].must_equal 'b'
1274
+ c.opts[:user].must_equal 'c'
1269
1275
  end
1270
1276
 
1271
- specify "should unescape values of URL parameters and parts" do
1277
+ it "should unescape values of URL parameters and parts" do
1272
1278
  c = Sequel.connect 'ccc:///d%5bb%5d?host=domain%5cinstance'
1273
- c.should be_a_kind_of(@ccc)
1274
- c.opts[:database].should == 'd[b]'
1275
- c.opts[:host].should == 'domain\\instance'
1279
+ c.must_be_kind_of(@ccc)
1280
+ c.opts[:database].must_equal 'd[b]'
1281
+ c.opts[:host].must_equal 'domain\\instance'
1276
1282
  end
1277
1283
 
1278
- specify "should test the connection if test parameter is truthy" do
1284
+ it "should test the connection if test parameter is truthy" do
1279
1285
  @ccc.send(:define_method, :connect){}
1280
- proc{Sequel.connect 'ccc:///d%5bb%5d?test=t'}.should raise_error(Sequel::DatabaseConnectionError)
1281
- proc{Sequel.connect 'ccc:///d%5bb%5d?test=1'}.should raise_error(Sequel::DatabaseConnectionError)
1282
- proc{Sequel.connect 'ccc:///d%5bb%5d', :test=>true}.should raise_error(Sequel::DatabaseConnectionError)
1283
- proc{Sequel.connect 'ccc:///d%5bb%5d', :test=>'t'}.should raise_error(Sequel::DatabaseConnectionError)
1286
+ proc{Sequel.connect 'ccc:///d%5bb%5d?test=t'}.must_raise(Sequel::DatabaseConnectionError)
1287
+ proc{Sequel.connect 'ccc:///d%5bb%5d?test=1'}.must_raise(Sequel::DatabaseConnectionError)
1288
+ proc{Sequel.connect 'ccc:///d%5bb%5d', :test=>true}.must_raise(Sequel::DatabaseConnectionError)
1289
+ proc{Sequel.connect 'ccc:///d%5bb%5d', :test=>'t'}.must_raise(Sequel::DatabaseConnectionError)
1284
1290
  end
1285
1291
 
1286
- specify "should not test the connection if test parameter is not truthy" do
1287
- proc{Sequel.connect 'ccc:///d%5bb%5d?test=f'}.should_not raise_error
1288
- proc{Sequel.connect 'ccc:///d%5bb%5d?test=0'}.should_not raise_error
1289
- proc{Sequel.connect 'ccc:///d%5bb%5d', :test=>false}.should_not raise_error
1290
- proc{Sequel.connect 'ccc:///d%5bb%5d', :test=>'f'}.should_not raise_error
1292
+ it "should not test the connection if test parameter is not truthy" do
1293
+ Sequel.connect 'ccc:///d%5bb%5d?test=f'
1294
+ Sequel.connect 'ccc:///d%5bb%5d?test=0'
1295
+ Sequel.connect 'ccc:///d%5bb%5d', :test=>false
1296
+ Sequel.connect 'ccc:///d%5bb%5d', :test=>'f'
1291
1297
  end
1292
1298
  end
1293
1299
 
1294
1300
  describe "Sequel::Database.connect" do
1295
- specify "should raise an Error if not given a String or Hash" do
1296
- proc{Sequel::Database.connect(nil)}.should raise_error(Sequel::Error)
1297
- proc{Sequel::Database.connect(Object.new)}.should raise_error(Sequel::Error)
1301
+ it "should raise an Error if not given a String or Hash" do
1302
+ proc{Sequel::Database.connect(nil)}.must_raise(Sequel::Error)
1303
+ proc{Sequel::Database.connect(Object.new)}.must_raise(Sequel::Error)
1298
1304
  end
1299
1305
  end
1300
1306
 
1301
1307
  describe "An unknown database scheme" do
1302
- specify "should raise an error in Sequel::Database.connect" do
1303
- proc {Sequel::Database.connect('ddd://localhost/db')}.should raise_error(Sequel::AdapterNotFound)
1308
+ it "should raise an error in Sequel::Database.connect" do
1309
+ proc {Sequel::Database.connect('ddd://localhost/db')}.must_raise(Sequel::AdapterNotFound)
1304
1310
  end
1305
1311
 
1306
- specify "should raise an error in Sequel.connect" do
1307
- proc {Sequel.connect('ddd://localhost/db')}.should raise_error(Sequel::AdapterNotFound)
1312
+ it "should raise an error in Sequel.connect" do
1313
+ proc {Sequel.connect('ddd://localhost/db')}.must_raise(Sequel::AdapterNotFound)
1308
1314
  end
1309
1315
  end
1310
1316
 
@@ -1318,14 +1324,14 @@ describe "A broken adapter (lib is there but the class is not)" do
1318
1324
  File.delete(@fn)
1319
1325
  end
1320
1326
 
1321
- specify "should raise an error" do
1322
- proc {Sequel.connect('blah://blow')}.should raise_error(Sequel::AdapterNotFound)
1327
+ it "should raise an error" do
1328
+ proc {Sequel.connect('blah://blow')}.must_raise(Sequel::AdapterNotFound)
1323
1329
  end
1324
1330
  end
1325
1331
 
1326
1332
  describe "Sequel::Database.load_adapter" do
1327
- specify "should not raise an error if subadapter does not exist" do
1328
- Sequel::Database.load_adapter(:foo, :subdir=>'bar').should == nil
1333
+ it "should not raise an error if subadapter does not exist" do
1334
+ Sequel::Database.load_adapter(:foo, :subdir=>'bar').must_equal nil
1329
1335
  end
1330
1336
  end
1331
1337
 
@@ -1334,26 +1340,26 @@ describe "A single threaded database" do
1334
1340
  Sequel::Database.single_threaded = false
1335
1341
  end
1336
1342
 
1337
- specify "should use a SingleConnectionPool instead of a ConnectionPool" do
1343
+ it "should use a SingleConnectionPool instead of a ConnectionPool" do
1338
1344
  db = Sequel::Database.new(:single_threaded => true){123}
1339
- db.pool.should be_a_kind_of(Sequel::SingleConnectionPool)
1345
+ db.pool.must_be_kind_of(Sequel::SingleConnectionPool)
1340
1346
  end
1341
1347
 
1342
- specify "should be constructable using :single_threaded => true option" do
1348
+ it "should be constructable using :single_threaded => true option" do
1343
1349
  db = Sequel::Database.new(:single_threaded => true){123}
1344
- db.pool.should be_a_kind_of(Sequel::SingleConnectionPool)
1350
+ db.pool.must_be_kind_of(Sequel::SingleConnectionPool)
1345
1351
  end
1346
1352
 
1347
- specify "should be constructable using Database.single_threaded = true" do
1353
+ it "should be constructable using Database.single_threaded = true" do
1348
1354
  Sequel::Database.single_threaded = true
1349
1355
  db = Sequel::Database.new{123}
1350
- db.pool.should be_a_kind_of(Sequel::SingleConnectionPool)
1356
+ db.pool.must_be_kind_of(Sequel::SingleConnectionPool)
1351
1357
  end
1352
1358
 
1353
- specify "should be constructable using Sequel.single_threaded = true" do
1359
+ it "should be constructable using Sequel.single_threaded = true" do
1354
1360
  Sequel.single_threaded = true
1355
1361
  db = Sequel::Database.new{123}
1356
- db.pool.should be_a_kind_of(Sequel::SingleConnectionPool)
1362
+ db.pool.must_be_kind_of(Sequel::SingleConnectionPool)
1357
1363
  end
1358
1364
  end
1359
1365
 
@@ -1366,31 +1372,31 @@ describe "A single threaded database" do
1366
1372
  end
1367
1373
  end
1368
1374
 
1369
- specify "should invoke connection_proc only once" do
1370
- @db.pool.hold {|c| c.should == 1234568}
1371
- @db.pool.hold {|c| c.should == 1234568}
1375
+ it "should invoke connection_proc only once" do
1376
+ @db.pool.hold {|c| c.must_equal 1234568}
1377
+ @db.pool.hold {|c| c.must_equal 1234568}
1372
1378
  end
1373
1379
 
1374
- specify "should disconnect correctly" do
1380
+ it "should disconnect correctly" do
1375
1381
  def @db.disconnect_connection(c); @dc = c end
1376
1382
  def @db.dc; @dc end
1377
1383
  x = nil
1378
1384
  @db.pool.hold{|c| x = c}
1379
- @db.pool.hold{|c| c.should == x}
1380
- proc{@db.disconnect}.should_not raise_error
1381
- @db.dc.should == x
1385
+ @db.pool.hold{|c| c.must_equal x}
1386
+ @db.disconnect
1387
+ @db.dc.must_equal x
1382
1388
  end
1383
1389
 
1384
- specify "should convert an Exception on connection into a DatabaseConnectionError" do
1390
+ it "should convert an Exception on connection into a DatabaseConnectionError" do
1385
1391
  db = Sequel::Database.new(:single_threaded => true, :servers=>{})
1386
1392
  def db.connect(*) raise Exception end
1387
- proc {db.pool.hold {|c|}}.should raise_error(Sequel::DatabaseConnectionError)
1393
+ proc {db.pool.hold {|c|}}.must_raise(Sequel::DatabaseConnectionError)
1388
1394
  end
1389
1395
 
1390
- specify "should raise a DatabaseConnectionError if the connection proc returns nil" do
1396
+ it "should raise a DatabaseConnectionError if the connection proc returns nil" do
1391
1397
  db = Sequel.mock(:single_threaded => true, :servers=>{})
1392
1398
  def db.connect(*) end
1393
- proc {db.pool.hold {|c|}}.should raise_error(Sequel::DatabaseConnectionError)
1399
+ proc {db.pool.hold {|c|}}.must_raise(Sequel::DatabaseConnectionError)
1394
1400
  end
1395
1401
  end
1396
1402
 
@@ -1399,41 +1405,41 @@ describe "A database" do
1399
1405
  Sequel::Database.single_threaded = false
1400
1406
  end
1401
1407
 
1402
- specify "should have single_threaded? respond to true if in single threaded mode" do
1408
+ it "should have single_threaded? respond to true if in single threaded mode" do
1403
1409
  db = Sequel::Database.new(:single_threaded => true){1234}
1404
- db.should be_single_threaded
1410
+ db.must_be :single_threaded?
1405
1411
 
1406
1412
  db = Sequel::Database.new(:max_options => 1)
1407
- db.should_not be_single_threaded
1413
+ db.wont_be :single_threaded?
1408
1414
 
1409
1415
  db = Sequel::Database.new
1410
- db.should_not be_single_threaded
1416
+ db.wont_be :single_threaded?
1411
1417
 
1412
1418
  Sequel::Database.single_threaded = true
1413
1419
 
1414
1420
  db = Sequel::Database.new{123}
1415
- db.should be_single_threaded
1421
+ db.must_be :single_threaded?
1416
1422
 
1417
1423
  db = Sequel::Database.new(:max_options => 4){123}
1418
- db.should be_single_threaded
1424
+ db.must_be :single_threaded?
1419
1425
  end
1420
1426
 
1421
- specify "should be able to set loggers via the logger= and loggers= methods" do
1427
+ it "should be able to set loggers via the logger= and loggers= methods" do
1422
1428
  db = Sequel::Database.new
1423
1429
  s = "I'm a logger"
1424
1430
  db.logger = s
1425
- db.loggers.should == [s]
1431
+ db.loggers.must_equal [s]
1426
1432
  db.logger = nil
1427
- db.loggers.should == []
1433
+ db.loggers.must_equal []
1428
1434
 
1429
1435
  db.loggers = [s]
1430
- db.loggers.should == [s]
1436
+ db.loggers.must_equal [s]
1431
1437
  db.loggers = []
1432
- db.loggers.should == []
1438
+ db.loggers.must_equal []
1433
1439
 
1434
1440
  t = "I'm also a logger"
1435
1441
  db.loggers = [s, t]
1436
- db.loggers.should == [s,t]
1442
+ db.loggers.must_equal [s,t]
1437
1443
  end
1438
1444
  end
1439
1445
 
@@ -1442,44 +1448,44 @@ describe "Database#fetch" do
1442
1448
  @db = Sequel.mock(:fetch=>proc{|sql| {:sql => sql}})
1443
1449
  end
1444
1450
 
1445
- specify "should create a dataset and invoke its fetch_rows method with the given sql" do
1451
+ it "should create a dataset and invoke its fetch_rows method with the given sql" do
1446
1452
  sql = nil
1447
1453
  @db.fetch('select * from xyz') {|r| sql = r[:sql]}
1448
- sql.should == 'select * from xyz'
1454
+ sql.must_equal 'select * from xyz'
1449
1455
  end
1450
1456
 
1451
- specify "should format the given sql with any additional arguments" do
1457
+ it "should format the given sql with any additional arguments" do
1452
1458
  sql = nil
1453
1459
  @db.fetch('select * from xyz where x = ? and y = ?', 15, 'abc') {|r| sql = r[:sql]}
1454
- sql.should == "select * from xyz where x = 15 and y = 'abc'"
1460
+ sql.must_equal "select * from xyz where x = 15 and y = 'abc'"
1455
1461
 
1456
1462
  @db.fetch('select name from table where name = ? or id in ?', 'aman', [3,4,7]) {|r| sql = r[:sql]}
1457
- sql.should == "select name from table where name = 'aman' or id in (3, 4, 7)"
1463
+ sql.must_equal "select name from table where name = 'aman' or id in (3, 4, 7)"
1458
1464
  end
1459
1465
 
1460
- specify "should format the given sql with named arguments" do
1466
+ it "should format the given sql with named arguments" do
1461
1467
  sql = nil
1462
1468
  @db.fetch('select * from xyz where x = :x and y = :y', :x=>15, :y=>'abc') {|r| sql = r[:sql]}
1463
- sql.should == "select * from xyz where x = 15 and y = 'abc'"
1469
+ sql.must_equal "select * from xyz where x = 15 and y = 'abc'"
1464
1470
  end
1465
1471
 
1466
- specify "should return the dataset if no block is given" do
1467
- @db.fetch('select * from xyz').should be_a_kind_of(Sequel::Dataset)
1472
+ it "should return the dataset if no block is given" do
1473
+ @db.fetch('select * from xyz').must_be_kind_of(Sequel::Dataset)
1468
1474
 
1469
- @db.fetch('select a from b').map {|r| r[:sql]}.should == ['select a from b']
1475
+ @db.fetch('select a from b').map {|r| r[:sql]}.must_equal ['select a from b']
1470
1476
 
1471
- @db.fetch('select c from d').inject([]) {|m, r| m << r; m}.should == \
1477
+ @db.fetch('select c from d').inject([]) {|m, r| m << r; m}.must_equal \
1472
1478
  [{:sql => 'select c from d'}]
1473
1479
  end
1474
1480
 
1475
- specify "should return a dataset that always uses the given sql for SELECTs" do
1481
+ it "should return a dataset that always uses the given sql for SELECTs" do
1476
1482
  ds = @db.fetch('select * from xyz')
1477
- ds.select_sql.should == 'select * from xyz'
1478
- ds.sql.should == 'select * from xyz'
1483
+ ds.select_sql.must_equal 'select * from xyz'
1484
+ ds.sql.must_equal 'select * from xyz'
1479
1485
 
1480
1486
  ds.filter!{price.sql_number < 100}
1481
- ds.select_sql.should == 'select * from xyz'
1482
- ds.sql.should == 'select * from xyz'
1487
+ ds.select_sql.must_equal 'select * from xyz'
1488
+ ds.sql.must_equal 'select * from xyz'
1483
1489
  end
1484
1490
  end
1485
1491
 
@@ -1489,31 +1495,31 @@ describe "Database#[]" do
1489
1495
  @db = Sequel.mock
1490
1496
  end
1491
1497
 
1492
- specify "should return a dataset when symbols are given" do
1498
+ it "should return a dataset when symbols are given" do
1493
1499
  ds = @db[:items]
1494
- ds.should be_a_kind_of(Sequel::Dataset)
1495
- ds.opts[:from].should == [:items]
1500
+ ds.must_be_kind_of(Sequel::Dataset)
1501
+ ds.opts[:from].must_equal [:items]
1496
1502
  end
1497
1503
 
1498
- specify "should return a dataset when a string is given" do
1504
+ it "should return a dataset when a string is given" do
1499
1505
  @db.fetch = proc{|sql| {:sql=>sql}}
1500
1506
  sql = nil
1501
1507
  @db['select * from xyz where x = ? and y = ?', 15, 'abc'].each {|r| sql = r[:sql]}
1502
- sql.should == "select * from xyz where x = 15 and y = 'abc'"
1508
+ sql.must_equal "select * from xyz where x = 15 and y = 'abc'"
1503
1509
  end
1504
1510
  end
1505
1511
 
1506
1512
  describe "Database#inspect" do
1507
- specify "should include the class name and the connection url" do
1508
- Sequel.connect('mock://foo/bar').inspect.should == '#<Sequel::Mock::Database: "mock://foo/bar">'
1513
+ it "should include the class name and the connection url" do
1514
+ Sequel.connect('mock://foo/bar').inspect.must_equal '#<Sequel::Mock::Database: "mock://foo/bar">'
1509
1515
  end
1510
1516
 
1511
- specify "should include the class name and the connection options if an options hash was given" do
1512
- Sequel.connect(:adapter=>:mock).inspect.should =~ /#<Sequel::Mock::Database: \{:adapter=>:mock\}>/
1517
+ it "should include the class name and the connection options if an options hash was given" do
1518
+ Sequel.connect(:adapter=>:mock).inspect.must_match(/#<Sequel::Mock::Database: \{:adapter=>:mock\}>/)
1513
1519
  end
1514
1520
 
1515
- specify "should include the class name, uri, and connection options if uri and options hash was given" do
1516
- Sequel.connect('mock://foo', :database=>'bar').inspect.should =~ /#<Sequel::Mock::Database: "mock:\/\/foo" \{:database=>"bar"\}>/
1521
+ it "should include the class name, uri, and connection options if uri and options hash was given" do
1522
+ Sequel.connect('mock://foo', :database=>'bar').inspect.must_match(/#<Sequel::Mock::Database: "mock:\/\/foo" \{:database=>"bar"\}>/)
1517
1523
  end
1518
1524
  end
1519
1525
 
@@ -1522,68 +1528,68 @@ describe "Database#get" do
1522
1528
  @db = Sequel.mock(:fetch=>{:a=>1})
1523
1529
  end
1524
1530
 
1525
- specify "should use Dataset#get to get a single value" do
1526
- @db.get(:a).should == 1
1527
- @db.sqls.should == ['SELECT a LIMIT 1']
1531
+ it "should use Dataset#get to get a single value" do
1532
+ @db.get(:a).must_equal 1
1533
+ @db.sqls.must_equal ['SELECT a LIMIT 1']
1528
1534
 
1529
1535
  @db.get(Sequel.function(:version).as(:version))
1530
- @db.sqls.should == ['SELECT version() AS version LIMIT 1']
1536
+ @db.sqls.must_equal ['SELECT version() AS version LIMIT 1']
1531
1537
  end
1532
1538
 
1533
- specify "should accept a block" do
1539
+ it "should accept a block" do
1534
1540
  @db.get{a}
1535
- @db.sqls.should == ['SELECT a LIMIT 1']
1541
+ @db.sqls.must_equal ['SELECT a LIMIT 1']
1536
1542
 
1537
1543
  @db.get{version(a).as(version)}
1538
- @db.sqls.should == ['SELECT version(a) AS version LIMIT 1']
1544
+ @db.sqls.must_equal ['SELECT version(a) AS version LIMIT 1']
1539
1545
  end
1540
1546
 
1541
- specify "should work when an alias cannot be determined" do
1542
- @db.get(1).should == 1
1543
- @db.sqls.should == ['SELECT 1 AS v LIMIT 1']
1547
+ it "should work when an alias cannot be determined" do
1548
+ @db.get(1).must_equal 1
1549
+ @db.sqls.must_equal ['SELECT 1 AS v LIMIT 1']
1544
1550
  end
1545
1551
  end
1546
1552
 
1547
1553
  describe "Database#call" do
1548
- specify "should call the prepared statement with the given name" do
1554
+ it "should call the prepared statement with the given name" do
1549
1555
  db = Sequel.mock(:fetch=>{:id => 1, :x => 1})
1550
1556
  db[:items].prepare(:select, :select_all)
1551
- db.call(:select_all).should == [{:id => 1, :x => 1}]
1557
+ db.call(:select_all).must_equal [{:id => 1, :x => 1}]
1552
1558
  db[:items].filter(:n=>:$n).prepare(:select, :select_n)
1553
- db.call(:select_n, :n=>1).should == [{:id => 1, :x => 1}]
1554
- db.sqls.should == ['SELECT * FROM items', 'SELECT * FROM items WHERE (n = 1)']
1559
+ db.call(:select_n, :n=>1).must_equal [{:id => 1, :x => 1}]
1560
+ db.sqls.must_equal ['SELECT * FROM items', 'SELECT * FROM items WHERE (n = 1)']
1555
1561
  end
1556
1562
  end
1557
1563
 
1558
1564
  describe "Database#server_opts" do
1559
- specify "should return the general opts if no :servers option is used" do
1565
+ it "should return the general opts if no :servers option is used" do
1560
1566
  opts = {:host=>1, :database=>2}
1561
- Sequel::Database.new(opts).send(:server_opts, :server1)[:host].should == 1
1567
+ Sequel::Database.new(opts).send(:server_opts, :server1)[:host].must_equal 1
1562
1568
  end
1563
1569
 
1564
- specify "should return the general opts if entry for the server is present in the :servers option" do
1570
+ it "should return the general opts if entry for the server is present in the :servers option" do
1565
1571
  opts = {:host=>1, :database=>2, :servers=>{}}
1566
- Sequel::Database.new(opts).send(:server_opts, :server1)[:host].should == 1
1572
+ Sequel::Database.new(opts).send(:server_opts, :server1)[:host].must_equal 1
1567
1573
  end
1568
1574
 
1569
- specify "should return the general opts merged with the specific opts if given as a hash" do
1575
+ it "should return the general opts merged with the specific opts if given as a hash" do
1570
1576
  opts = {:host=>1, :database=>2, :servers=>{:server1=>{:host=>3}}}
1571
- Sequel::Database.new(opts).send(:server_opts, :server1)[:host].should == 3
1577
+ Sequel::Database.new(opts).send(:server_opts, :server1)[:host].must_equal 3
1572
1578
  end
1573
1579
 
1574
- specify "should return the sgeneral opts merged with the specific opts if given as a proc" do
1580
+ it "should return the sgeneral opts merged with the specific opts if given as a proc" do
1575
1581
  opts = {:host=>1, :database=>2, :servers=>{:server1=>proc{|db| {:host=>4}}}}
1576
- Sequel::Database.new(opts).send(:server_opts, :server1)[:host].should == 4
1582
+ Sequel::Database.new(opts).send(:server_opts, :server1)[:host].must_equal 4
1577
1583
  end
1578
1584
 
1579
- specify "should raise an error if the specific opts is not a proc or hash" do
1585
+ it "should raise an error if the specific opts is not a proc or hash" do
1580
1586
  opts = {:host=>1, :database=>2, :servers=>{:server1=>2}}
1581
- proc{Sequel::Database.new(opts).send(:server_opts, :server1)}.should raise_error(Sequel::Error)
1587
+ proc{Sequel::Database.new(opts).send(:server_opts, :server1)}.must_raise(Sequel::Error)
1582
1588
  end
1583
1589
 
1584
- specify "should return the general opts merged with given opts if given opts is a Hash" do
1590
+ it "should return the general opts merged with given opts if given opts is a Hash" do
1585
1591
  opts = {:host=>1, :database=>2}
1586
- Sequel::Database.new(opts).send(:server_opts, :host=>2)[:host].should == 2
1592
+ Sequel::Database.new(opts).send(:server_opts, :host=>2)[:host].must_equal 2
1587
1593
  end
1588
1594
  end
1589
1595
 
@@ -1592,36 +1598,36 @@ describe "Database#add_servers" do
1592
1598
  @db = Sequel.mock(:host=>1, :database=>2, :servers=>{:server1=>{:host=>3}})
1593
1599
  end
1594
1600
 
1595
- specify "should add new servers to the connection pool" do
1596
- @db.synchronize{|c| c.opts[:host].should == 1}
1597
- @db.synchronize(:server1){|c| c.opts[:host].should == 3}
1598
- @db.synchronize(:server2){|c| c.opts[:host].should == 1}
1601
+ it "should add new servers to the connection pool" do
1602
+ @db.synchronize{|c| c.opts[:host].must_equal 1}
1603
+ @db.synchronize(:server1){|c| c.opts[:host].must_equal 3}
1604
+ @db.synchronize(:server2){|c| c.opts[:host].must_equal 1}
1599
1605
 
1600
1606
  @db.add_servers(:server2=>{:host=>6})
1601
- @db.synchronize{|c| c.opts[:host].should == 1}
1602
- @db.synchronize(:server1){|c| c.opts[:host].should == 3}
1603
- @db.synchronize(:server2){|c| c.opts[:host].should == 6}
1607
+ @db.synchronize{|c| c.opts[:host].must_equal 1}
1608
+ @db.synchronize(:server1){|c| c.opts[:host].must_equal 3}
1609
+ @db.synchronize(:server2){|c| c.opts[:host].must_equal 6}
1604
1610
 
1605
1611
  @db.disconnect
1606
- @db.synchronize{|c| c.opts[:host].should == 1}
1607
- @db.synchronize(:server1){|c| c.opts[:host].should == 3}
1608
- @db.synchronize(:server2){|c| c.opts[:host].should == 6}
1612
+ @db.synchronize{|c| c.opts[:host].must_equal 1}
1613
+ @db.synchronize(:server1){|c| c.opts[:host].must_equal 3}
1614
+ @db.synchronize(:server2){|c| c.opts[:host].must_equal 6}
1609
1615
  end
1610
1616
 
1611
- specify "should replace options for future connections to existing servers" do
1612
- @db.synchronize{|c| c.opts[:host].should == 1}
1613
- @db.synchronize(:server1){|c| c.opts[:host].should == 3}
1614
- @db.synchronize(:server2){|c| c.opts[:host].should == 1}
1617
+ it "should replace options for future connections to existing servers" do
1618
+ @db.synchronize{|c| c.opts[:host].must_equal 1}
1619
+ @db.synchronize(:server1){|c| c.opts[:host].must_equal 3}
1620
+ @db.synchronize(:server2){|c| c.opts[:host].must_equal 1}
1615
1621
 
1616
1622
  @db.add_servers(:default=>proc{{:host=>4}}, :server1=>{:host=>8})
1617
- @db.synchronize{|c| c.opts[:host].should == 1}
1618
- @db.synchronize(:server1){|c| c.opts[:host].should == 3}
1619
- @db.synchronize(:server2){|c| c.opts[:host].should == 1}
1623
+ @db.synchronize{|c| c.opts[:host].must_equal 1}
1624
+ @db.synchronize(:server1){|c| c.opts[:host].must_equal 3}
1625
+ @db.synchronize(:server2){|c| c.opts[:host].must_equal 1}
1620
1626
 
1621
1627
  @db.disconnect
1622
- @db.synchronize{|c| c.opts[:host].should == 4}
1623
- @db.synchronize(:server1){|c| c.opts[:host].should == 8}
1624
- @db.synchronize(:server2){|c| c.opts[:host].should == 4}
1628
+ @db.synchronize{|c| c.opts[:host].must_equal 4}
1629
+ @db.synchronize(:server1){|c| c.opts[:host].must_equal 8}
1630
+ @db.synchronize(:server2){|c| c.opts[:host].must_equal 4}
1625
1631
  end
1626
1632
  end
1627
1633
 
@@ -1630,70 +1636,73 @@ describe "Database#remove_servers" do
1630
1636
  @db = Sequel.mock(:host=>1, :database=>2, :servers=>{:server1=>{:host=>3}, :server2=>{:host=>4}})
1631
1637
  end
1632
1638
 
1633
- specify "should remove servers from the connection pool" do
1634
- @db.synchronize{|c| c.opts[:host].should == 1}
1635
- @db.synchronize(:server1){|c| c.opts[:host].should == 3}
1636
- @db.synchronize(:server2){|c| c.opts[:host].should == 4}
1639
+ it "should remove servers from the connection pool" do
1640
+ @db.synchronize{|c| c.opts[:host].must_equal 1}
1641
+ @db.synchronize(:server1){|c| c.opts[:host].must_equal 3}
1642
+ @db.synchronize(:server2){|c| c.opts[:host].must_equal 4}
1637
1643
 
1638
1644
  @db.remove_servers(:server1, :server2)
1639
- @db.synchronize{|c| c.opts[:host].should == 1}
1640
- @db.synchronize(:server1){|c| c.opts[:host].should == 1}
1641
- @db.synchronize(:server2){|c| c.opts[:host].should == 1}
1645
+ @db.synchronize{|c| c.opts[:host].must_equal 1}
1646
+ @db.synchronize(:server1){|c| c.opts[:host].must_equal 1}
1647
+ @db.synchronize(:server2){|c| c.opts[:host].must_equal 1}
1642
1648
  end
1643
1649
 
1644
- specify "should accept arrays of symbols" do
1650
+ it "should accept arrays of symbols" do
1645
1651
  @db.remove_servers([:server1, :server2])
1646
- @db.synchronize{|c| c.opts[:host].should == 1}
1647
- @db.synchronize(:server1){|c| c.opts[:host].should == 1}
1648
- @db.synchronize(:server2){|c| c.opts[:host].should == 1}
1652
+ @db.synchronize{|c| c.opts[:host].must_equal 1}
1653
+ @db.synchronize(:server1){|c| c.opts[:host].must_equal 1}
1654
+ @db.synchronize(:server2){|c| c.opts[:host].must_equal 1}
1649
1655
  end
1650
1656
 
1651
- specify "should allow removal while connections are still open" do
1657
+ it "should allow removal while connections are still open" do
1652
1658
  @db.synchronize do |c1|
1653
- c1.opts[:host].should == 1
1659
+ c1.opts[:host].must_equal 1
1654
1660
  @db.synchronize(:server1) do |c2|
1655
- c2.opts[:host].should == 3
1661
+ c2.opts[:host].must_equal 3
1656
1662
  @db.synchronize(:server2) do |c3|
1657
- c3.opts[:host].should == 4
1663
+ c3.opts[:host].must_equal 4
1658
1664
  @db.remove_servers(:server1, :server2)
1659
1665
  @db.synchronize(:server1) do |c4|
1660
- c4.should_not == c2
1661
- c4.should == c1
1662
- c4.opts[:host].should == 1
1666
+ c4.wont_equal c2
1667
+ c4.must_equal c1
1668
+ c4.opts[:host].must_equal 1
1663
1669
  @db.synchronize(:server2) do |c5|
1664
- c5.should_not == c3
1665
- c5.should == c1
1666
- c5.opts[:host].should == 1
1670
+ c5.wont_equal c3
1671
+ c5.must_equal c1
1672
+ c5.opts[:host].must_equal 1
1667
1673
  end
1668
1674
  end
1669
- c3.opts[:host].should == 4
1675
+ c3.opts[:host].must_equal 4
1670
1676
  end
1671
- c2.opts[:host].should == 3
1677
+ c2.opts[:host].must_equal 3
1672
1678
  end
1673
- c1.opts[:host].should == 1
1679
+ c1.opts[:host].must_equal 1
1674
1680
  end
1675
1681
  end
1676
1682
  end
1677
1683
 
1678
1684
  describe "Database#each_server with do/jdbc adapter connection string without :adapter option" do
1679
- specify "should yield a separate database object for each server" do
1685
+ it "should yield a separate database object for each server" do
1680
1686
  klass = Class.new(Sequel::Database)
1681
- klass.should_receive(:adapter_class).once.with(:jdbc).and_return(Sequel::Mock::Database)
1687
+ def klass.adapter_class(v)
1688
+ raise unless v == :jdbc
1689
+ Sequel::Mock::Database
1690
+ end
1682
1691
  @db = klass.connect('jdbc:blah:', :host=>1, :database=>2, :servers=>{:server1=>{:host=>3}})
1683
1692
 
1684
1693
  hosts = []
1685
1694
  @db.each_server do |db|
1686
- db.should be_a_kind_of(Sequel::Database)
1687
- db.should_not == @db
1688
- db.opts[:adapter_class].should == Sequel::Mock::Database
1689
- db.opts[:database].should == 2
1695
+ db.must_be_kind_of(Sequel::Database)
1696
+ db.wont_equal @db
1697
+ db.opts[:adapter_class].must_equal Sequel::Mock::Database
1698
+ db.opts[:database].must_equal 2
1690
1699
  hosts << db.opts[:host]
1691
1700
  end
1692
- hosts.sort.should == [1, 3]
1701
+ hosts.sort.must_equal [1, 3]
1693
1702
  end
1694
1703
 
1695
- specify "should raise if not given a block" do
1696
- proc{Sequel.mock.each_server}.should raise_error(Sequel::Error)
1704
+ it "should raise if not given a block" do
1705
+ proc{Sequel.mock.each_server}.must_raise(Sequel::Error)
1697
1706
  end
1698
1707
  end
1699
1708
 
@@ -1702,30 +1711,30 @@ describe "Database#each_server" do
1702
1711
  @db = Sequel.mock(:host=>1, :database=>2, :servers=>{:server1=>{:host=>3}, :server2=>{:host=>4}})
1703
1712
  end
1704
1713
 
1705
- specify "should yield a separate database object for each server" do
1714
+ it "should yield a separate database object for each server" do
1706
1715
  hosts = []
1707
1716
  @db.each_server do |db|
1708
- db.should be_a_kind_of(Sequel::Database)
1709
- db.should_not == @db
1710
- db.opts[:adapter].should == :mock
1711
- db.opts[:database].should == 2
1717
+ db.must_be_kind_of(Sequel::Database)
1718
+ db.wont_equal @db
1719
+ db.opts[:adapter].must_equal :mock
1720
+ db.opts[:database].must_equal 2
1712
1721
  hosts << db.opts[:host]
1713
1722
  end
1714
- hosts.sort.should == [1, 3, 4]
1723
+ hosts.sort.must_equal [1, 3, 4]
1715
1724
  end
1716
1725
 
1717
- specify "should disconnect and remove entry from Sequel::DATABASES after use" do
1726
+ it "should disconnect and remove entry from Sequel::DATABASES after use" do
1718
1727
  dbs = []
1719
1728
  dcs = []
1720
1729
  @db.each_server do |db|
1721
1730
  dbs << db
1722
- Sequel::DATABASES.should include(db)
1731
+ Sequel::DATABASES.must_include(db)
1723
1732
  meta_def(db, :disconnect){dcs << db}
1724
1733
  end
1725
1734
  dbs.each do |db|
1726
- Sequel::DATABASES.should_not include(db)
1735
+ Sequel::DATABASES.wont_include(db)
1727
1736
  end
1728
- dbs.should == dcs
1737
+ dbs.must_equal dcs
1729
1738
  end
1730
1739
  end
1731
1740
 
@@ -1734,29 +1743,29 @@ describe "Database#raise_error" do
1734
1743
  @db = Sequel.mock
1735
1744
  end
1736
1745
 
1737
- specify "should reraise if the exception class is not in opts[:classes]" do
1746
+ it "should reraise if the exception class is not in opts[:classes]" do
1738
1747
  e = Class.new(StandardError)
1739
- proc{@db.send(:raise_error, e.new(''), :classes=>[])}.should raise_error(e)
1748
+ proc{@db.send(:raise_error, e.new(''), :classes=>[])}.must_raise(e)
1740
1749
  end
1741
1750
 
1742
- specify "should convert the exception to a DatabaseError if the exception class is in opts[:classes]" do
1743
- proc{@db.send(:raise_error, Interrupt.new(''), :classes=>[Interrupt])}.should raise_error(Sequel::DatabaseError)
1751
+ it "should convert the exception to a DatabaseError if the exception class is in opts[:classes]" do
1752
+ proc{@db.send(:raise_error, Interrupt.new(''), :classes=>[Interrupt])}.must_raise(Sequel::DatabaseError)
1744
1753
  end
1745
1754
 
1746
- specify "should convert the exception to a DatabaseError if opts[:classes] if not present" do
1747
- proc{@db.send(:raise_error, Interrupt.new(''))}.should raise_error(Sequel::DatabaseError)
1755
+ it "should convert the exception to a DatabaseError if opts[:classes] if not present" do
1756
+ proc{@db.send(:raise_error, Interrupt.new(''))}.must_raise(Sequel::DatabaseError)
1748
1757
  end
1749
1758
 
1750
- specify "should convert the exception to a DatabaseDisconnectError if opts[:disconnect] is true" do
1751
- proc{@db.send(:raise_error, Interrupt.new(''), :disconnect=>true)}.should raise_error(Sequel::DatabaseDisconnectError)
1759
+ it "should convert the exception to a DatabaseDisconnectError if opts[:disconnect] is true" do
1760
+ proc{@db.send(:raise_error, Interrupt.new(''), :disconnect=>true)}.must_raise(Sequel::DatabaseDisconnectError)
1752
1761
  end
1753
1762
 
1754
- specify "should convert the exception to an appropriate error if exception message matches regexp" do
1763
+ it "should convert the exception to an appropriate error if exception message matches regexp" do
1755
1764
  def @db.database_error_regexps
1756
1765
  {/foo/ => Sequel::DatabaseDisconnectError, /bar/ => Sequel::ConstraintViolation}
1757
1766
  end
1758
- proc{@db.send(:raise_error, Interrupt.new('foo'))}.should raise_error(Sequel::DatabaseDisconnectError)
1759
- proc{@db.send(:raise_error, Interrupt.new('bar'))}.should raise_error(Sequel::ConstraintViolation)
1767
+ proc{@db.send(:raise_error, Interrupt.new('foo'))}.must_raise(Sequel::DatabaseDisconnectError)
1768
+ proc{@db.send(:raise_error, Interrupt.new('bar'))}.must_raise(Sequel::ConstraintViolation)
1760
1769
  end
1761
1770
  end
1762
1771
 
@@ -1765,58 +1774,58 @@ describe "Database#typecast_value" do
1765
1774
  @db = Sequel::Database.new
1766
1775
  end
1767
1776
 
1768
- specify "should raise an InvalidValue when given an invalid value" do
1769
- proc{@db.typecast_value(:integer, "13a")}.should raise_error(Sequel::InvalidValue)
1770
- proc{@db.typecast_value(:float, "4.e2")}.should raise_error(Sequel::InvalidValue)
1771
- proc{@db.typecast_value(:decimal, :invalid_value)}.should raise_error(Sequel::InvalidValue)
1772
- proc{@db.typecast_value(:date, Object.new)}.should raise_error(Sequel::InvalidValue)
1773
- proc{@db.typecast_value(:date, 'a')}.should raise_error(Sequel::InvalidValue)
1774
- proc{@db.typecast_value(:time, Date.new)}.should raise_error(Sequel::InvalidValue)
1775
- proc{@db.typecast_value(:datetime, 4)}.should raise_error(Sequel::InvalidValue)
1777
+ it "should raise an InvalidValue when given an invalid value" do
1778
+ proc{@db.typecast_value(:integer, "13a")}.must_raise(Sequel::InvalidValue)
1779
+ proc{@db.typecast_value(:float, "4.e2")}.must_raise(Sequel::InvalidValue)
1780
+ proc{@db.typecast_value(:decimal, :invalid_value)}.must_raise(Sequel::InvalidValue)
1781
+ proc{@db.typecast_value(:date, Object.new)}.must_raise(Sequel::InvalidValue)
1782
+ proc{@db.typecast_value(:date, 'a')}.must_raise(Sequel::InvalidValue)
1783
+ proc{@db.typecast_value(:time, Date.new)}.must_raise(Sequel::InvalidValue)
1784
+ proc{@db.typecast_value(:datetime, 4)}.must_raise(Sequel::InvalidValue)
1776
1785
  end
1777
1786
 
1778
- specify "should handle integers with leading 0 as base 10" do
1779
- @db.typecast_value(:integer, "013").should == 13
1780
- @db.typecast_value(:integer, "08").should == 8
1781
- @db.typecast_value(:integer, "000013").should == 13
1782
- @db.typecast_value(:integer, "000008").should == 8
1787
+ it "should handle integers with leading 0 as base 10" do
1788
+ @db.typecast_value(:integer, "013").must_equal 13
1789
+ @db.typecast_value(:integer, "08").must_equal 8
1790
+ @db.typecast_value(:integer, "000013").must_equal 13
1791
+ @db.typecast_value(:integer, "000008").must_equal 8
1783
1792
  end
1784
1793
 
1785
- specify "should handle integers with leading 0x as base 16" do
1786
- @db.typecast_value(:integer, "0x013").should == 19
1787
- @db.typecast_value(:integer, "0x80").should == 128
1794
+ it "should handle integers with leading 0x as base 16" do
1795
+ @db.typecast_value(:integer, "0x013").must_equal 19
1796
+ @db.typecast_value(:integer, "0x80").must_equal 128
1788
1797
  end
1789
1798
 
1790
- specify "should typecast blobs as as Sequel::SQL::Blob" do
1799
+ it "should typecast blobs as as Sequel::SQL::Blob" do
1791
1800
  v = @db.typecast_value(:blob, "0x013")
1792
- v.should be_a_kind_of(Sequel::SQL::Blob)
1793
- v.should == Sequel::SQL::Blob.new("0x013")
1794
- @db.typecast_value(:blob, v).object_id.should == v.object_id
1795
- end
1796
-
1797
- specify "should typecast boolean values to true, false, or nil" do
1798
- @db.typecast_value(:boolean, false).should == false
1799
- @db.typecast_value(:boolean, 0).should == false
1800
- @db.typecast_value(:boolean, "0").should == false
1801
- @db.typecast_value(:boolean, 'f').should == false
1802
- @db.typecast_value(:boolean, 'false').should == false
1803
- @db.typecast_value(:boolean, true).should == true
1804
- @db.typecast_value(:boolean, 1).should == true
1805
- @db.typecast_value(:boolean, '1').should == true
1806
- @db.typecast_value(:boolean, 't').should == true
1807
- @db.typecast_value(:boolean, 'true').should == true
1808
- @db.typecast_value(:boolean, '').should be_nil
1809
- end
1810
-
1811
- specify "should typecast date values to Date" do
1812
- @db.typecast_value(:date, Date.today).should == Date.today
1813
- @db.typecast_value(:date, DateTime.now).should == Date.today
1814
- @db.typecast_value(:date, Time.now).should == Date.today
1815
- @db.typecast_value(:date, Date.today.to_s).should == Date.today
1816
- @db.typecast_value(:date, :year=>Date.today.year, :month=>Date.today.month, :day=>Date.today.day).should == Date.today
1817
- end
1818
-
1819
- specify "should have Sequel.application_to_database_timestamp convert to Sequel.database_timezone" do
1801
+ v.must_be_kind_of(Sequel::SQL::Blob)
1802
+ v.must_equal Sequel::SQL::Blob.new("0x013")
1803
+ @db.typecast_value(:blob, v).object_id.must_equal v.object_id
1804
+ end
1805
+
1806
+ it "should typecast boolean values to true, false, or nil" do
1807
+ @db.typecast_value(:boolean, false).must_equal false
1808
+ @db.typecast_value(:boolean, 0).must_equal false
1809
+ @db.typecast_value(:boolean, "0").must_equal false
1810
+ @db.typecast_value(:boolean, 'f').must_equal false
1811
+ @db.typecast_value(:boolean, 'false').must_equal false
1812
+ @db.typecast_value(:boolean, true).must_equal true
1813
+ @db.typecast_value(:boolean, 1).must_equal true
1814
+ @db.typecast_value(:boolean, '1').must_equal true
1815
+ @db.typecast_value(:boolean, 't').must_equal true
1816
+ @db.typecast_value(:boolean, 'true').must_equal true
1817
+ @db.typecast_value(:boolean, '').must_equal nil
1818
+ end
1819
+
1820
+ it "should typecast date values to Date" do
1821
+ @db.typecast_value(:date, Date.today).must_equal Date.today
1822
+ @db.typecast_value(:date, DateTime.now).must_equal Date.today
1823
+ @db.typecast_value(:date, Time.now).must_equal Date.today
1824
+ @db.typecast_value(:date, Date.today.to_s).must_equal Date.today
1825
+ @db.typecast_value(:date, :year=>Date.today.year, :month=>Date.today.month, :day=>Date.today.day).must_equal Date.today
1826
+ end
1827
+
1828
+ it "should have Sequel.application_to_database_timestamp convert to Sequel.database_timezone" do
1820
1829
  begin
1821
1830
  t = Time.utc(2011, 1, 2, 3, 4, 5) # UTC Time
1822
1831
  t2 = Time.mktime(2011, 1, 2, 3, 4, 5) # Local Time
@@ -1824,42 +1833,42 @@ describe "Database#typecast_value" do
1824
1833
  t4 = Time.mktime(2011, 1, 2, 3, 4, 5) + (t - t2) # UTC Time in Local Time
1825
1834
  Sequel.application_timezone = :utc
1826
1835
  Sequel.database_timezone = :local
1827
- Sequel.application_to_database_timestamp(t).should == t4
1836
+ Sequel.application_to_database_timestamp(t).must_equal t4
1828
1837
  Sequel.application_timezone = :local
1829
1838
  Sequel.database_timezone = :utc
1830
- Sequel.application_to_database_timestamp(t2).should == t3
1839
+ Sequel.application_to_database_timestamp(t2).must_equal t3
1831
1840
  ensure
1832
1841
  Sequel.default_timezone = nil
1833
1842
  end
1834
1843
  end
1835
1844
 
1836
- specify "should have Database#to_application_timestamp convert values using the database's timezone" do
1845
+ it "should have Database#to_application_timestamp convert values using the database's timezone" do
1837
1846
  begin
1838
1847
  t = Time.utc(2011, 1, 2, 3, 4, 5) # UTC Time
1839
1848
  t2 = Time.mktime(2011, 1, 2, 3, 4, 5) # Local Time
1840
1849
  t3 = Time.utc(2011, 1, 2, 3, 4, 5) - (t - t2) # Local Time in UTC Time
1841
1850
  t4 = Time.mktime(2011, 1, 2, 3, 4, 5) + (t - t2) # UTC Time in Local Time
1842
1851
  Sequel.default_timezone = :utc
1843
- @db.to_application_timestamp('2011-01-02 03:04:05').should == t
1852
+ @db.to_application_timestamp('2011-01-02 03:04:05').must_equal t
1844
1853
  Sequel.database_timezone = :local
1845
- @db.to_application_timestamp('2011-01-02 03:04:05').should == t3
1854
+ @db.to_application_timestamp('2011-01-02 03:04:05').must_equal t3
1846
1855
  Sequel.default_timezone = :local
1847
- @db.to_application_timestamp('2011-01-02 03:04:05').should == t2
1856
+ @db.to_application_timestamp('2011-01-02 03:04:05').must_equal t2
1848
1857
  Sequel.database_timezone = :utc
1849
- @db.to_application_timestamp('2011-01-02 03:04:05').should == t4
1858
+ @db.to_application_timestamp('2011-01-02 03:04:05').must_equal t4
1850
1859
 
1851
1860
  Sequel.default_timezone = :utc
1852
1861
  @db.timezone = :local
1853
- @db.to_application_timestamp('2011-01-02 03:04:05').should == t3
1862
+ @db.to_application_timestamp('2011-01-02 03:04:05').must_equal t3
1854
1863
  Sequel.default_timezone = :local
1855
1864
  @db.timezone = :utc
1856
- @db.to_application_timestamp('2011-01-02 03:04:05').should == t4
1865
+ @db.to_application_timestamp('2011-01-02 03:04:05').must_equal t4
1857
1866
  ensure
1858
1867
  Sequel.default_timezone = nil
1859
1868
  end
1860
1869
  end
1861
1870
 
1862
- specify "should typecast datetime values to Sequel.datetime_class with correct timezone handling" do
1871
+ it "should typecast datetime values to Sequel.datetime_class with correct timezone handling" do
1863
1872
  t = Time.utc(2011, 1, 2, 3, 4, 5, 500000) # UTC Time
1864
1873
  t2 = Time.mktime(2011, 1, 2, 3, 4, 5, 500000) # Local Time
1865
1874
  t3 = Time.utc(2011, 1, 2, 3, 4, 5, 500000) - (t - t2) # Local Time in UTC Time
@@ -1872,40 +1881,40 @@ describe "Database#typecast_value" do
1872
1881
  dt3 = DateTime.civil(2011, 1, 2, 3, 4, secs) - r2
1873
1882
  dt4 = DateTime.civil(2011, 1, 2, 3, 4, secs, r1) + r2
1874
1883
 
1875
- t.should == t4
1876
- t2.should == t3
1877
- dt.should == dt4
1878
- dt2.should == dt3
1884
+ t.must_equal t4
1885
+ t2.must_equal t3
1886
+ dt.must_equal dt4
1887
+ dt2.must_equal dt3
1879
1888
 
1880
1889
  check = proc do |i, o|
1881
1890
  v = @db.typecast_value(:datetime, i)
1882
- v.should == o
1891
+ v.must_equal o
1883
1892
  if o.is_a?(Time)
1884
- v.utc_offset.should == o.utc_offset
1893
+ v.utc_offset.must_equal o.utc_offset
1885
1894
  else
1886
- v.offset.should == o.offset
1895
+ v.offset.must_equal o.offset
1887
1896
  end
1888
1897
  end
1889
1898
  @db.extend_datasets(Module.new{def supports_timestamp_timezones?; true; end})
1890
1899
  begin
1891
- @db.typecast_value(:datetime, dt).should == t
1892
- @db.typecast_value(:datetime, dt2).should == t2
1893
- @db.typecast_value(:datetime, t).should == t
1894
- @db.typecast_value(:datetime, t2).should == t2
1895
- @db.typecast_value(:datetime, @db.literal(dt)[1...-1]).should == t
1896
- @db.typecast_value(:datetime, dt.strftime('%F %T.%N')).should == t2
1897
- @db.typecast_value(:datetime, Date.civil(2011, 1, 2)).should == Time.mktime(2011, 1, 2, 0, 0, 0)
1898
- @db.typecast_value(:datetime, :year=>dt.year, :month=>dt.month, :day=>dt.day, :hour=>dt.hour, :minute=>dt.min, :second=>dt.sec, :nanos=>500000000).should == t2
1900
+ @db.typecast_value(:datetime, dt).must_equal t
1901
+ @db.typecast_value(:datetime, dt2).must_equal t2
1902
+ @db.typecast_value(:datetime, t).must_equal t
1903
+ @db.typecast_value(:datetime, t2).must_equal t2
1904
+ @db.typecast_value(:datetime, @db.literal(dt)[1...-1]).must_equal t
1905
+ @db.typecast_value(:datetime, dt.strftime('%F %T.%N')).must_equal t2
1906
+ @db.typecast_value(:datetime, Date.civil(2011, 1, 2)).must_equal Time.mktime(2011, 1, 2, 0, 0, 0)
1907
+ @db.typecast_value(:datetime, :year=>dt.year, :month=>dt.month, :day=>dt.day, :hour=>dt.hour, :minute=>dt.min, :second=>dt.sec, :nanos=>500000000).must_equal t2
1899
1908
 
1900
1909
  Sequel.datetime_class = DateTime
1901
- @db.typecast_value(:datetime, dt).should == dt
1902
- @db.typecast_value(:datetime, dt2).should == dt2
1903
- @db.typecast_value(:datetime, t).should == dt
1904
- @db.typecast_value(:datetime, t2).should == dt2
1905
- @db.typecast_value(:datetime, @db.literal(dt)[1...-1]).should == dt
1906
- @db.typecast_value(:datetime, dt.strftime('%F %T.%N')).should == dt
1907
- @db.typecast_value(:datetime, Date.civil(2011, 1, 2)).should == DateTime.civil(2011, 1, 2, 0, 0, 0)
1908
- @db.typecast_value(:datetime, :year=>dt.year, :month=>dt.month, :day=>dt.day, :hour=>dt.hour, :minute=>dt.min, :second=>dt.sec, :nanos=>500000000).should == dt
1910
+ @db.typecast_value(:datetime, dt).must_equal dt
1911
+ @db.typecast_value(:datetime, dt2).must_equal dt2
1912
+ @db.typecast_value(:datetime, t).must_equal dt
1913
+ @db.typecast_value(:datetime, t2).must_equal dt2
1914
+ @db.typecast_value(:datetime, @db.literal(dt)[1...-1]).must_equal dt
1915
+ @db.typecast_value(:datetime, dt.strftime('%F %T.%N')).must_equal dt
1916
+ @db.typecast_value(:datetime, Date.civil(2011, 1, 2)).must_equal DateTime.civil(2011, 1, 2, 0, 0, 0)
1917
+ @db.typecast_value(:datetime, :year=>dt.year, :month=>dt.month, :day=>dt.day, :hour=>dt.hour, :minute=>dt.min, :second=>dt.sec, :nanos=>500000000).must_equal dt
1909
1918
 
1910
1919
  Sequel.application_timezone = :utc
1911
1920
  Sequel.typecast_timezone = :local
@@ -1998,366 +2007,366 @@ describe "Database#typecast_value" do
1998
2007
  end
1999
2008
  end
2000
2009
 
2001
- specify "should handle arrays when typecasting timestamps" do
2010
+ it "should handle arrays when typecasting timestamps" do
2002
2011
  begin
2003
- @db.typecast_value(:datetime, [2011, 10, 11, 12, 13, 14]).should == Time.local(2011, 10, 11, 12, 13, 14)
2004
- @db.typecast_value(:datetime, [2011, 10, 11, 12, 13, 14, 500000000]).should == Time.local(2011, 10, 11, 12, 13, 14, 500000)
2012
+ @db.typecast_value(:datetime, [2011, 10, 11, 12, 13, 14]).must_equal Time.local(2011, 10, 11, 12, 13, 14)
2013
+ @db.typecast_value(:datetime, [2011, 10, 11, 12, 13, 14, 500000000]).must_equal Time.local(2011, 10, 11, 12, 13, 14, 500000)
2005
2014
 
2006
2015
  Sequel.datetime_class = DateTime
2007
- @db.typecast_value(:datetime, [2011, 10, 11, 12, 13, 14]).should == DateTime.civil(2011, 10, 11, 12, 13, 14)
2008
- @db.typecast_value(:datetime, [2011, 10, 11, 12, 13, 14, 500000000]).should == DateTime.civil(2011, 10, 11, 12, 13, (defined?(Rational) ? Rational(29, 2) : 14.5))
2009
- @db.typecast_value(:datetime, [2011, 10, 11, 12, 13, 14, 500000000, (defined?(Rational) ? Rational(1, 2) : 0.5)]).should == DateTime.civil(2011, 10, 11, 12, 13, (defined?(Rational) ? Rational(29, 2) : 14.5), (defined?(Rational) ? Rational(1, 2) : 0.5))
2016
+ @db.typecast_value(:datetime, [2011, 10, 11, 12, 13, 14]).must_equal DateTime.civil(2011, 10, 11, 12, 13, 14)
2017
+ @db.typecast_value(:datetime, [2011, 10, 11, 12, 13, 14, 500000000]).must_equal DateTime.civil(2011, 10, 11, 12, 13, (defined?(Rational) ? Rational(29, 2) : 14.5))
2018
+ @db.typecast_value(:datetime, [2011, 10, 11, 12, 13, 14, 500000000, (defined?(Rational) ? Rational(1, 2) : 0.5)]).must_equal DateTime.civil(2011, 10, 11, 12, 13, (defined?(Rational) ? Rational(29, 2) : 14.5), (defined?(Rational) ? Rational(1, 2) : 0.5))
2010
2019
  ensure
2011
2020
  Sequel.datetime_class = Time
2012
2021
  end
2013
2022
  end
2014
2023
 
2015
- specify "should handle hashes when typecasting timestamps" do
2024
+ it "should handle hashes when typecasting timestamps" do
2016
2025
  begin
2017
- @db.typecast_value(:datetime, :year=>2011, :month=>10, :day=>11, :hour=>12, :minute=>13, :second=>14).should == Time.local(2011, 10, 11, 12, 13, 14)
2018
- @db.typecast_value(:datetime, :year=>2011, :month=>10, :day=>11, :hour=>12, :minute=>13, :second=>14, :nanos=>500000000).should == Time.local(2011, 10, 11, 12, 13, 14, 500000)
2019
- @db.typecast_value(:datetime, 'year'=>2011, 'month'=>10, 'day'=>11, 'hour'=>12, 'minute'=>13, 'second'=>14).should == Time.local(2011, 10, 11, 12, 13, 14)
2020
- @db.typecast_value(:datetime, 'year'=>2011, 'month'=>10, 'day'=>11, 'hour'=>12, 'minute'=>13, 'second'=>14, 'nanos'=>500000000).should == Time.local(2011, 10, 11, 12, 13, 14, 500000)
2026
+ @db.typecast_value(:datetime, :year=>2011, :month=>10, :day=>11, :hour=>12, :minute=>13, :second=>14).must_equal Time.local(2011, 10, 11, 12, 13, 14)
2027
+ @db.typecast_value(:datetime, :year=>2011, :month=>10, :day=>11, :hour=>12, :minute=>13, :second=>14, :nanos=>500000000).must_equal Time.local(2011, 10, 11, 12, 13, 14, 500000)
2028
+ @db.typecast_value(:datetime, 'year'=>2011, 'month'=>10, 'day'=>11, 'hour'=>12, 'minute'=>13, 'second'=>14).must_equal Time.local(2011, 10, 11, 12, 13, 14)
2029
+ @db.typecast_value(:datetime, 'year'=>2011, 'month'=>10, 'day'=>11, 'hour'=>12, 'minute'=>13, 'second'=>14, 'nanos'=>500000000).must_equal Time.local(2011, 10, 11, 12, 13, 14, 500000)
2021
2030
 
2022
2031
  Sequel.datetime_class = DateTime
2023
- @db.typecast_value(:datetime, :year=>2011, :month=>10, :day=>11, :hour=>12, :minute=>13, :second=>14).should == DateTime.civil(2011, 10, 11, 12, 13, 14)
2024
- @db.typecast_value(:datetime, :year=>2011, :month=>10, :day=>11, :hour=>12, :minute=>13, :second=>14, :nanos=>500000000).should == DateTime.civil(2011, 10, 11, 12, 13, (defined?(Rational) ? Rational(29, 2) : 14.5))
2025
- @db.typecast_value(:datetime, 'year'=>2011, 'month'=>10, 'day'=>11, 'hour'=>12, 'minute'=>13, 'second'=>14).should == DateTime.civil(2011, 10, 11, 12, 13, 14)
2026
- @db.typecast_value(:datetime, 'year'=>2011, 'month'=>10, 'day'=>11, 'hour'=>12, 'minute'=>13, 'second'=>14, 'nanos'=>500000000).should == DateTime.civil(2011, 10, 11, 12, 13, (defined?(Rational) ? Rational(29, 2) : 14.5))
2027
- @db.typecast_value(:datetime, :year=>2011, :month=>10, :day=>11, :hour=>12, :minute=>13, :second=>14, :offset=>(defined?(Rational) ? Rational(1, 2) : 0.5)).should == DateTime.civil(2011, 10, 11, 12, 13, 14, (defined?(Rational) ? Rational(1, 2) : 0.5))
2028
- @db.typecast_value(:datetime, :year=>2011, :month=>10, :day=>11, :hour=>12, :minute=>13, :second=>14, :nanos=>500000000, :offset=>(defined?(Rational) ? Rational(1, 2) : 0.5)).should == DateTime.civil(2011, 10, 11, 12, 13, (defined?(Rational) ? Rational(29, 2) : 14.5), (defined?(Rational) ? Rational(1, 2) : 0.5))
2029
- @db.typecast_value(:datetime, 'year'=>2011, 'month'=>10, 'day'=>11, 'hour'=>12, 'minute'=>13, 'second'=>14, 'offset'=>(defined?(Rational) ? Rational(1, 2) : 0.5)).should == DateTime.civil(2011, 10, 11, 12, 13, 14, (defined?(Rational) ? Rational(1, 2) : 0.5))
2030
- @db.typecast_value(:datetime, 'year'=>2011, 'month'=>10, 'day'=>11, 'hour'=>12, 'minute'=>13, 'second'=>14, 'nanos'=>500000000, 'offset'=>(defined?(Rational) ? Rational(1, 2) : 0.5)).should == DateTime.civil(2011, 10, 11, 12, 13, (defined?(Rational) ? Rational(29, 2) : 14.5), (defined?(Rational) ? Rational(1, 2) : 0.5))
2032
+ @db.typecast_value(:datetime, :year=>2011, :month=>10, :day=>11, :hour=>12, :minute=>13, :second=>14).must_equal DateTime.civil(2011, 10, 11, 12, 13, 14)
2033
+ @db.typecast_value(:datetime, :year=>2011, :month=>10, :day=>11, :hour=>12, :minute=>13, :second=>14, :nanos=>500000000).must_equal DateTime.civil(2011, 10, 11, 12, 13, (defined?(Rational) ? Rational(29, 2) : 14.5))
2034
+ @db.typecast_value(:datetime, 'year'=>2011, 'month'=>10, 'day'=>11, 'hour'=>12, 'minute'=>13, 'second'=>14).must_equal DateTime.civil(2011, 10, 11, 12, 13, 14)
2035
+ @db.typecast_value(:datetime, 'year'=>2011, 'month'=>10, 'day'=>11, 'hour'=>12, 'minute'=>13, 'second'=>14, 'nanos'=>500000000).must_equal DateTime.civil(2011, 10, 11, 12, 13, (defined?(Rational) ? Rational(29, 2) : 14.5))
2036
+ @db.typecast_value(:datetime, :year=>2011, :month=>10, :day=>11, :hour=>12, :minute=>13, :second=>14, :offset=>(defined?(Rational) ? Rational(1, 2) : 0.5)).must_equal DateTime.civil(2011, 10, 11, 12, 13, 14, (defined?(Rational) ? Rational(1, 2) : 0.5))
2037
+ @db.typecast_value(:datetime, :year=>2011, :month=>10, :day=>11, :hour=>12, :minute=>13, :second=>14, :nanos=>500000000, :offset=>(defined?(Rational) ? Rational(1, 2) : 0.5)).must_equal DateTime.civil(2011, 10, 11, 12, 13, (defined?(Rational) ? Rational(29, 2) : 14.5), (defined?(Rational) ? Rational(1, 2) : 0.5))
2038
+ @db.typecast_value(:datetime, 'year'=>2011, 'month'=>10, 'day'=>11, 'hour'=>12, 'minute'=>13, 'second'=>14, 'offset'=>(defined?(Rational) ? Rational(1, 2) : 0.5)).must_equal DateTime.civil(2011, 10, 11, 12, 13, 14, (defined?(Rational) ? Rational(1, 2) : 0.5))
2039
+ @db.typecast_value(:datetime, 'year'=>2011, 'month'=>10, 'day'=>11, 'hour'=>12, 'minute'=>13, 'second'=>14, 'nanos'=>500000000, 'offset'=>(defined?(Rational) ? Rational(1, 2) : 0.5)).must_equal DateTime.civil(2011, 10, 11, 12, 13, (defined?(Rational) ? Rational(29, 2) : 14.5), (defined?(Rational) ? Rational(1, 2) : 0.5))
2031
2040
  ensure
2032
2041
  Sequel.datetime_class = Time
2033
2042
  end
2034
2043
  end
2035
2044
 
2036
- specify "should typecast decimal values to BigDecimal" do
2045
+ it "should typecast decimal values to BigDecimal" do
2037
2046
  [1.0, 1, '1.0', BigDecimal('1.0')].each do |i|
2038
2047
  v = @db.typecast_value(:decimal, i)
2039
- v.should be_a_kind_of(BigDecimal)
2040
- v.should == BigDecimal.new('1.0')
2048
+ v.must_be_kind_of(BigDecimal)
2049
+ v.must_equal BigDecimal.new('1.0')
2041
2050
  end
2042
2051
  end
2043
2052
 
2044
- specify "should typecast float values to Float" do
2053
+ it "should typecast float values to Float" do
2045
2054
  [1.0, 1, '1.0', BigDecimal('1.0')].each do |i|
2046
2055
  v = @db.typecast_value(:float, i)
2047
- v.should be_a_kind_of(Float)
2048
- v.should == 1.0
2056
+ v.must_be_kind_of(Float)
2057
+ v.must_equal 1.0
2049
2058
  end
2050
2059
  end
2051
2060
 
2052
- specify "should typecast string values to String" do
2061
+ it "should typecast string values to String" do
2053
2062
  [1.0, '1.0', Sequel.blob('1.0')].each do |i|
2054
2063
  v = @db.typecast_value(:string, i)
2055
- v.should be_an_instance_of(String)
2056
- v.should == "1.0"
2064
+ v.must_be_instance_of(String)
2065
+ v.must_equal "1.0"
2057
2066
  end
2058
2067
  end
2059
2068
 
2060
- specify "should raise errors when typecasting hash and array values to String" do
2069
+ it "should raise errors when typecasting hash and array values to String" do
2061
2070
  [[], {}].each do |i|
2062
- proc{@db.typecast_value(:string, i)}.should raise_error(Sequel::InvalidValue)
2071
+ proc{@db.typecast_value(:string, i)}.must_raise(Sequel::InvalidValue)
2063
2072
  end
2064
2073
  end
2065
2074
 
2066
- specify "should typecast time values to SQLTime" do
2075
+ it "should typecast time values to SQLTime" do
2067
2076
  t = Time.now
2068
2077
  st = Sequel::SQLTime.local(t.year, t.month, t.day, 1, 2, 3)
2069
2078
  [st, Time.utc(t.year, t.month, t.day, 1, 2, 3), Time.local(t.year, t.month, t.day, 1, 2, 3), '01:02:03', {:hour=>1, :minute=>2, :second=>3}].each do |i|
2070
2079
  v = @db.typecast_value(:time, i)
2071
- v.should be_an_instance_of(Sequel::SQLTime)
2072
- v.should == st
2080
+ v.must_be_instance_of(Sequel::SQLTime)
2081
+ v.must_equal st
2073
2082
  end
2074
2083
  end
2075
2084
 
2076
- specify "should correctly handle time value conversion to SQLTime with fractional seconds" do
2085
+ it "should correctly handle time value conversion to SQLTime with fractional seconds" do
2077
2086
  t = Time.now
2078
2087
  st = Sequel::SQLTime.local(t.year, t.month, t.day, 1, 2, 3, 500000)
2079
2088
  t = Time.local(t.year, t.month, t.day, 1, 2, 3, 500000)
2080
- @db.typecast_value(:time, t).should == st
2089
+ @db.typecast_value(:time, t).must_equal st
2081
2090
  end
2082
2091
 
2083
- specify "should have an underlying exception class available at wrapped_exception" do
2092
+ it "should have an underlying exception class available at wrapped_exception" do
2084
2093
  begin
2085
2094
  @db.typecast_value(:date, 'a')
2086
- true.should == false
2095
+ true.must_equal false
2087
2096
  rescue Sequel::InvalidValue => e
2088
- e.wrapped_exception.should be_a_kind_of(ArgumentError)
2097
+ e.wrapped_exception.must_be_kind_of(ArgumentError)
2089
2098
  end
2090
2099
  end
2091
2100
 
2092
- specify "should include underlying exception class in #inspect" do
2101
+ it "should include underlying exception class in #inspect" do
2093
2102
  begin
2094
2103
  @db.typecast_value(:date, 'a')
2095
- true.should == false
2104
+ true.must_equal false
2096
2105
  rescue Sequel::InvalidValue => e
2097
- e.inspect.should =~ /\A#<Sequel::InvalidValue: ArgumentError: .*>\z/
2106
+ e.inspect.must_match(/\A#<Sequel::InvalidValue: ArgumentError: .*>\z/)
2098
2107
  end
2099
2108
  end
2100
2109
  end
2101
2110
 
2102
2111
  describe "Database#blank_object?" do
2103
- specify "should return whether the object is considered blank" do
2112
+ it "should return whether the object is considered blank" do
2104
2113
  db = Sequel::Database.new
2105
2114
  c = lambda{|meth, value| Class.new{define_method(meth){value}}.new}
2106
2115
 
2107
- db.send(:blank_object?, "").should == true
2108
- db.send(:blank_object?, " ").should == true
2109
- db.send(:blank_object?, nil).should == true
2110
- db.send(:blank_object?, false).should == true
2111
- db.send(:blank_object?, []).should == true
2112
- db.send(:blank_object?, {}).should == true
2113
- db.send(:blank_object?, c[:empty?, true]).should == true
2114
- db.send(:blank_object?, c[:blank?, true]).should == true
2116
+ db.send(:blank_object?, "").must_equal true
2117
+ db.send(:blank_object?, " ").must_equal true
2118
+ db.send(:blank_object?, nil).must_equal true
2119
+ db.send(:blank_object?, false).must_equal true
2120
+ db.send(:blank_object?, []).must_equal true
2121
+ db.send(:blank_object?, {}).must_equal true
2122
+ db.send(:blank_object?, c[:empty?, true]).must_equal true
2123
+ db.send(:blank_object?, c[:blank?, true]).must_equal true
2115
2124
 
2116
- db.send(:blank_object?, " a ").should == false
2117
- db.send(:blank_object?, 1).should == false
2118
- db.send(:blank_object?, 1.0).should == false
2119
- db.send(:blank_object?, true).should == false
2120
- db.send(:blank_object?, [1]).should == false
2121
- db.send(:blank_object?, {1.0=>2.0}).should == false
2122
- db.send(:blank_object?, c[:empty?, false]).should == false
2123
- db.send(:blank_object?, c[:blank?, false]).should == false
2125
+ db.send(:blank_object?, " a ").must_equal false
2126
+ db.send(:blank_object?, 1).must_equal false
2127
+ db.send(:blank_object?, 1.0).must_equal false
2128
+ db.send(:blank_object?, true).must_equal false
2129
+ db.send(:blank_object?, [1]).must_equal false
2130
+ db.send(:blank_object?, {1.0=>2.0}).must_equal false
2131
+ db.send(:blank_object?, c[:empty?, false]).must_equal false
2132
+ db.send(:blank_object?, c[:blank?, false]).must_equal false
2124
2133
  end
2125
2134
  end
2126
2135
 
2127
2136
  describe "Database#schema_autoincrementing_primary_key?" do
2128
- specify "should indicate whether the parsed schema row indicates a primary key" do
2137
+ it "should indicate whether the parsed schema row indicates a primary key" do
2129
2138
  m = Sequel::Database.new.method(:schema_autoincrementing_primary_key?)
2130
- m.call(:primary_key=>true, :auto_increment=>true).should == true
2131
- m.call(:primary_key=>true, :auto_increment=>false).should == false
2132
- m.call(:primary_key=>false).should == false
2139
+ m.call(:primary_key=>true, :auto_increment=>true).must_equal true
2140
+ m.call(:primary_key=>true, :auto_increment=>false).must_equal false
2141
+ m.call(:primary_key=>false).must_equal false
2133
2142
  end
2134
2143
  end
2135
2144
 
2136
2145
  describe "Database#supports_schema_parsing?" do
2137
- specify "should be false by default" do
2138
- Sequel::Database.new.supports_schema_parsing?.should == false
2146
+ it "should be false by default" do
2147
+ Sequel::Database.new.supports_schema_parsing?.must_equal false
2139
2148
  end
2140
2149
 
2141
- specify "should be true if the database implements schema_parse_table" do
2150
+ it "should be true if the database implements schema_parse_table" do
2142
2151
  db = Sequel::Database.new
2143
2152
  def db.schema_parse_table(*) end
2144
- db.supports_schema_parsing?.should == true
2153
+ db.supports_schema_parsing?.must_equal true
2145
2154
  end
2146
2155
  end
2147
2156
 
2148
2157
  describe "Database#supports_foreign_key_parsing?" do
2149
- specify "should be false by default" do
2150
- Sequel::Database.new.supports_foreign_key_parsing?.should == false
2158
+ it "should be false by default" do
2159
+ Sequel::Database.new.supports_foreign_key_parsing?.must_equal false
2151
2160
  end
2152
2161
 
2153
- specify "should be true if the database implements foreign_key_list" do
2162
+ it "should be true if the database implements foreign_key_list" do
2154
2163
  db = Sequel::Database.new
2155
2164
  def db.foreign_key_list(*) end
2156
- db.supports_foreign_key_parsing?.should == true
2165
+ db.supports_foreign_key_parsing?.must_equal true
2157
2166
  end
2158
2167
  end
2159
2168
 
2160
2169
  describe "Database#supports_index_parsing?" do
2161
- specify "should be false by default" do
2162
- Sequel::Database.new.supports_index_parsing?.should == false
2170
+ it "should be false by default" do
2171
+ Sequel::Database.new.supports_index_parsing?.must_equal false
2163
2172
  end
2164
2173
 
2165
- specify "should be true if the database implements indexes" do
2174
+ it "should be true if the database implements indexes" do
2166
2175
  db = Sequel::Database.new
2167
2176
  def db.indexes(*) end
2168
- db.supports_index_parsing?.should == true
2177
+ db.supports_index_parsing?.must_equal true
2169
2178
  end
2170
2179
  end
2171
2180
 
2172
2181
  describe "Database#supports_table_listing?" do
2173
- specify "should be false by default" do
2174
- Sequel::Database.new.supports_table_listing?.should == false
2182
+ it "should be false by default" do
2183
+ Sequel::Database.new.supports_table_listing?.must_equal false
2175
2184
  end
2176
2185
 
2177
- specify "should be true if the database implements tables" do
2186
+ it "should be true if the database implements tables" do
2178
2187
  db = Sequel::Database.new
2179
2188
  def db.tables(*) end
2180
- db.supports_table_listing?.should == true
2189
+ db.supports_table_listing?.must_equal true
2181
2190
  end
2182
2191
  end
2183
2192
 
2184
2193
  describe "Database#supports_view_listing?" do
2185
- specify "should be false by default" do
2186
- Sequel::Database.new.supports_view_listing?.should == false
2194
+ it "should be false by default" do
2195
+ Sequel::Database.new.supports_view_listing?.must_equal false
2187
2196
  end
2188
2197
 
2189
- specify "should be true if the database implements views" do
2198
+ it "should be true if the database implements views" do
2190
2199
  db = Sequel::Database.new
2191
2200
  def db.views(*) end
2192
- db.supports_view_listing?.should == true
2201
+ db.supports_view_listing?.must_equal true
2193
2202
  end
2194
2203
  end
2195
2204
 
2196
2205
  describe "Database#supports_deferrable_constraints?" do
2197
- specify "should be false by default" do
2198
- Sequel::Database.new.supports_deferrable_constraints?.should == false
2206
+ it "should be false by default" do
2207
+ Sequel::Database.new.supports_deferrable_constraints?.must_equal false
2199
2208
  end
2200
2209
  end
2201
2210
 
2202
2211
  describe "Database#supports_deferrable_foreign_key_constraints?" do
2203
- specify "should be false by default" do
2204
- Sequel::Database.new.supports_deferrable_foreign_key_constraints?.should == false
2212
+ it "should be false by default" do
2213
+ Sequel::Database.new.supports_deferrable_foreign_key_constraints?.must_equal false
2205
2214
  end
2206
2215
  end
2207
2216
 
2208
2217
  describe "Database#supports_transactional_ddl?" do
2209
- specify "should be false by default" do
2210
- Sequel::Database.new.supports_transactional_ddl?.should == false
2218
+ it "should be false by default" do
2219
+ Sequel::Database.new.supports_transactional_ddl?.must_equal false
2211
2220
  end
2212
2221
  end
2213
2222
 
2214
2223
  describe "Database#global_index_namespace?" do
2215
- specify "should be true by default" do
2216
- Sequel::Database.new.global_index_namespace?.should == true
2224
+ it "should be true by default" do
2225
+ Sequel::Database.new.global_index_namespace?.must_equal true
2217
2226
  end
2218
2227
  end
2219
2228
 
2220
2229
  describe "Database#supports_savepoints?" do
2221
- specify "should be false by default" do
2222
- Sequel::Database.new.supports_savepoints?.should == false
2230
+ it "should be false by default" do
2231
+ Sequel::Database.new.supports_savepoints?.must_equal false
2223
2232
  end
2224
2233
  end
2225
2234
 
2226
2235
  describe "Database#supports_views_with_check_option?" do
2227
- specify "should be false by default" do
2228
- Sequel::Database.new.supports_views_with_check_option?.should == false
2236
+ it "should be false by default" do
2237
+ Sequel::Database.new.supports_views_with_check_option?.must_equal false
2229
2238
  end
2230
2239
  end
2231
2240
 
2232
2241
  describe "Database#supports_views_with_local_check_option?" do
2233
- specify "should be false by default" do
2234
- Sequel::Database.new.supports_views_with_local_check_option?.should == false
2242
+ it "should be false by default" do
2243
+ Sequel::Database.new.supports_views_with_local_check_option?.must_equal false
2235
2244
  end
2236
2245
  end
2237
2246
 
2238
2247
  describe "Database#supports_savepoints_in_prepared_transactions?" do
2239
- specify "should be false by default" do
2240
- Sequel::Database.new.supports_savepoints_in_prepared_transactions?.should == false
2248
+ it "should be false by default" do
2249
+ Sequel::Database.new.supports_savepoints_in_prepared_transactions?.must_equal false
2241
2250
  end
2242
2251
 
2243
- specify "should be true if both savepoints and prepared transactions are supported" do
2252
+ it "should be true if both savepoints and prepared transactions are supported" do
2244
2253
  db = Sequel::Database.new
2245
2254
  meta_def(db, :supports_savepoints?){true}
2246
2255
  meta_def(db, :supports_prepared_transactions?){true}
2247
- db.supports_savepoints_in_prepared_transactions?.should == true
2256
+ db.supports_savepoints_in_prepared_transactions?.must_equal true
2248
2257
  end
2249
2258
  end
2250
2259
 
2251
2260
  describe "Database#supports_prepared_transactions?" do
2252
- specify "should be false by default" do
2253
- Sequel::Database.new.supports_prepared_transactions?.should == false
2261
+ it "should be false by default" do
2262
+ Sequel::Database.new.supports_prepared_transactions?.must_equal false
2254
2263
  end
2255
2264
  end
2256
2265
 
2257
2266
  describe "Database#supports_transaction_isolation_levels?" do
2258
- specify "should be false by default" do
2259
- Sequel::Database.new.supports_transaction_isolation_levels?.should == false
2267
+ it "should be false by default" do
2268
+ Sequel::Database.new.supports_transaction_isolation_levels?.must_equal false
2260
2269
  end
2261
2270
  end
2262
2271
 
2263
2272
  describe "Database#input_identifier_meth" do
2264
- specify "should be the input_identifer method of a default dataset for this database" do
2273
+ it "should be the input_identifer method of a default dataset for this database" do
2265
2274
  db = Sequel::Database.new
2266
- db.send(:input_identifier_meth).call(:a).should == 'a'
2275
+ db.send(:input_identifier_meth).call(:a).must_equal 'a'
2267
2276
  db.identifier_input_method = :upcase
2268
- db.send(:input_identifier_meth).call(:a).should == 'A'
2277
+ db.send(:input_identifier_meth).call(:a).must_equal 'A'
2269
2278
  end
2270
2279
  end
2271
2280
 
2272
2281
  describe "Database#output_identifier_meth" do
2273
- specify "should be the output_identifer method of a default dataset for this database" do
2282
+ it "should be the output_identifer method of a default dataset for this database" do
2274
2283
  db = Sequel::Database.new
2275
- db.send(:output_identifier_meth).call('A').should == :A
2284
+ db.send(:output_identifier_meth).call('A').must_equal :A
2276
2285
  db.identifier_output_method = :downcase
2277
- db.send(:output_identifier_meth).call('A').should == :a
2286
+ db.send(:output_identifier_meth).call('A').must_equal :a
2278
2287
  end
2279
2288
  end
2280
2289
 
2281
2290
  describe "Database#metadata_dataset" do
2282
- specify "should be a dataset with the default settings for identifier_input_method and identifier_output_method" do
2291
+ it "should be a dataset with the default settings for identifier_input_method and identifier_output_method" do
2283
2292
  ds = Sequel::Database.new.send(:metadata_dataset)
2284
- ds.literal(:a).should == 'A'
2285
- ds.send(:output_identifier, 'A').should == :a
2293
+ ds.literal(:a).must_equal 'A'
2294
+ ds.send(:output_identifier, 'A').must_equal :a
2286
2295
  end
2287
2296
  end
2288
2297
 
2289
2298
  describe "Database#column_schema_to_ruby_default" do
2290
- specify "should handle converting many default formats" do
2299
+ it "should handle converting many default formats" do
2291
2300
  db = Sequel::Database.new
2292
2301
  p = lambda{|d,t| db.send(:column_schema_to_ruby_default, d, t)}
2293
- p[nil, :integer].should be_nil
2294
- p[1, :integer].should == 1
2295
- p['1', :integer].should == 1
2296
- p['-1', :integer].should == -1
2297
- p[1.0, :float].should == 1.0
2298
- p['1.0', :float].should == 1.0
2299
- p['-1.0', :float].should == -1.0
2300
- p['1.0', :decimal].should == BigDecimal.new('1.0')
2301
- p['-1.0', :decimal].should == BigDecimal.new('-1.0')
2302
- p[true, :boolean].should == true
2303
- p[false, :boolean].should == false
2304
- p['1', :boolean].should == true
2305
- p['0', :boolean].should == false
2306
- p['true', :boolean].should == true
2307
- p['false', :boolean].should == false
2308
- p["'t'", :boolean].should == true
2309
- p["'f'", :boolean].should == false
2310
- p["'a'", :string].should == 'a'
2311
- p["'a'", :blob].should == Sequel.blob('a')
2312
- p["'a'", :blob].should be_a_kind_of(Sequel::SQL::Blob)
2313
- p["''", :string].should == ''
2314
- p["'\\a''b'", :string].should == "\\a'b"
2315
- p["'NULL'", :string].should == "NULL"
2316
- p[Date.today, :date].should == Date.today
2317
- p["'2009-10-29'", :date].should == Date.new(2009,10,29)
2318
- p["CURRENT_TIMESTAMP", :date].should == Sequel::CURRENT_DATE
2319
- p["CURRENT_DATE", :date].should == Sequel::CURRENT_DATE
2320
- p["now()", :date].should == Sequel::CURRENT_DATE
2321
- p["getdate()", :date].should == Sequel::CURRENT_DATE
2322
- p["CURRENT_TIMESTAMP", :datetime].should == Sequel::CURRENT_TIMESTAMP
2323
- p["CURRENT_DATE", :datetime].should == Sequel::CURRENT_TIMESTAMP
2324
- p["now()", :datetime].should == Sequel::CURRENT_TIMESTAMP
2325
- p["getdate()", :datetime].should == Sequel::CURRENT_TIMESTAMP
2326
- p["'2009-10-29T10:20:30-07:00'", :datetime].should == DateTime.parse('2009-10-29T10:20:30-07:00')
2327
- p["'2009-10-29 10:20:30'", :datetime].should == DateTime.parse('2009-10-29 10:20:30')
2328
- p["'10:20:30'", :time].should == Time.parse('10:20:30')
2329
- p["NaN", :float].should be_nil
2302
+ p[nil, :integer].must_equal nil
2303
+ p[1, :integer].must_equal 1
2304
+ p['1', :integer].must_equal 1
2305
+ p['-1', :integer].must_equal(-1)
2306
+ p[1.0, :float].must_equal 1.0
2307
+ p['1.0', :float].must_equal 1.0
2308
+ p['-1.0', :float].must_equal(-1.0)
2309
+ p['1.0', :decimal].must_equal BigDecimal.new('1.0')
2310
+ p['-1.0', :decimal].must_equal BigDecimal.new('-1.0')
2311
+ p[true, :boolean].must_equal true
2312
+ p[false, :boolean].must_equal false
2313
+ p['1', :boolean].must_equal true
2314
+ p['0', :boolean].must_equal false
2315
+ p['true', :boolean].must_equal true
2316
+ p['false', :boolean].must_equal false
2317
+ p["'t'", :boolean].must_equal true
2318
+ p["'f'", :boolean].must_equal false
2319
+ p["'a'", :string].must_equal 'a'
2320
+ p["'a'", :blob].must_equal Sequel.blob('a')
2321
+ p["'a'", :blob].must_be_kind_of(Sequel::SQL::Blob)
2322
+ p["''", :string].must_equal ''
2323
+ p["'\\a''b'", :string].must_equal "\\a'b"
2324
+ p["'NULL'", :string].must_equal "NULL"
2325
+ p[Date.today, :date].must_equal Date.today
2326
+ p["'2009-10-29'", :date].must_equal Date.new(2009,10,29)
2327
+ p["CURRENT_TIMESTAMP", :date].must_equal Sequel::CURRENT_DATE
2328
+ p["CURRENT_DATE", :date].must_equal Sequel::CURRENT_DATE
2329
+ p["now()", :date].must_equal Sequel::CURRENT_DATE
2330
+ p["getdate()", :date].must_equal Sequel::CURRENT_DATE
2331
+ p["CURRENT_TIMESTAMP", :datetime].must_equal Sequel::CURRENT_TIMESTAMP
2332
+ p["CURRENT_DATE", :datetime].must_equal Sequel::CURRENT_TIMESTAMP
2333
+ p["now()", :datetime].must_equal Sequel::CURRENT_TIMESTAMP
2334
+ p["getdate()", :datetime].must_equal Sequel::CURRENT_TIMESTAMP
2335
+ p["'2009-10-29T10:20:30-07:00'", :datetime].must_equal DateTime.parse('2009-10-29T10:20:30-07:00')
2336
+ p["'2009-10-29 10:20:30'", :datetime].must_equal DateTime.parse('2009-10-29 10:20:30')
2337
+ p["'10:20:30'", :time].must_equal Time.parse('10:20:30')
2338
+ p["NaN", :float].must_equal nil
2330
2339
 
2331
2340
  db = Sequel.mock(:host=>'postgres')
2332
- p["''::text", :string].should == ""
2333
- p["'\\a''b'::character varying", :string].should == "\\a'b"
2334
- p["'a'::bpchar", :string].should == "a"
2335
- p["(-1)", :integer].should == -1
2336
- p["(-1.0)", :float].should == -1.0
2337
- p['(-1.0)', :decimal].should == BigDecimal.new('-1.0')
2338
- p["'a'::bytea", :blob].should == Sequel.blob('a')
2339
- p["'a'::bytea", :blob].should be_a_kind_of(Sequel::SQL::Blob)
2340
- p["'2009-10-29'::date", :date].should == Date.new(2009,10,29)
2341
- p["'2009-10-29 10:20:30.241343'::timestamp without time zone", :datetime].should == DateTime.parse('2009-10-29 10:20:30.241343')
2342
- p["'10:20:30'::time without time zone", :time].should == Time.parse('10:20:30')
2341
+ p["''::text", :string].must_equal ""
2342
+ p["'\\a''b'::character varying", :string].must_equal "\\a'b"
2343
+ p["'a'::bpchar", :string].must_equal "a"
2344
+ p["(-1)", :integer].must_equal(-1)
2345
+ p["(-1.0)", :float].must_equal(-1.0)
2346
+ p['(-1.0)', :decimal].must_equal BigDecimal.new('-1.0')
2347
+ p["'a'::bytea", :blob].must_equal Sequel.blob('a')
2348
+ p["'a'::bytea", :blob].must_be_kind_of(Sequel::SQL::Blob)
2349
+ p["'2009-10-29'::date", :date].must_equal Date.new(2009,10,29)
2350
+ p["'2009-10-29 10:20:30.241343'::timestamp without time zone", :datetime].must_equal DateTime.parse('2009-10-29 10:20:30.241343')
2351
+ p["'10:20:30'::time without time zone", :time].must_equal Time.parse('10:20:30')
2343
2352
 
2344
2353
  db = Sequel.mock(:host=>'mysql')
2345
- p["\\a'b", :string].should == "\\a'b"
2346
- p["a", :string].should == "a"
2347
- p["NULL", :string].should == "NULL"
2348
- p["-1", :float].should == -1.0
2349
- p['-1', :decimal].should == BigDecimal.new('-1.0')
2350
- p["2009-10-29", :date].should == Date.new(2009,10,29)
2351
- p["2009-10-29 10:20:30", :datetime].should == DateTime.parse('2009-10-29 10:20:30')
2352
- p["10:20:30", :time].should == Time.parse('10:20:30')
2353
- p["a", :enum].should == "a"
2354
- p["a,b", :set].should == "a,b"
2354
+ p["\\a'b", :string].must_equal "\\a'b"
2355
+ p["a", :string].must_equal "a"
2356
+ p["NULL", :string].must_equal "NULL"
2357
+ p["-1", :float].must_equal(-1.0)
2358
+ p['-1', :decimal].must_equal BigDecimal.new('-1.0')
2359
+ p["2009-10-29", :date].must_equal Date.new(2009,10,29)
2360
+ p["2009-10-29 10:20:30", :datetime].must_equal DateTime.parse('2009-10-29 10:20:30')
2361
+ p["10:20:30", :time].must_equal Time.parse('10:20:30')
2362
+ p["a", :enum].must_equal "a"
2363
+ p["a,b", :set].must_equal "a,b"
2355
2364
 
2356
2365
  db = Sequel.mock(:host=>'mssql')
2357
- p["(N'a')", :string].should == "a"
2358
- p["((-12))", :integer].should == -12
2359
- p["((12.1))", :float].should == 12.1
2360
- p["((-12.1))", :decimal].should == BigDecimal.new('-12.1')
2366
+ p["(N'a')", :string].must_equal "a"
2367
+ p["((-12))", :integer].must_equal(-12)
2368
+ p["((12.1))", :float].must_equal 12.1
2369
+ p["((-12.1))", :decimal].must_equal BigDecimal.new('-12.1')
2361
2370
  end
2362
2371
  end
2363
2372
 
@@ -2384,54 +2393,54 @@ describe "Database extensions" do
2384
2393
  Sequel::Database.instance_variable_set(:@initialize_hook, Proc.new {|db| })
2385
2394
  end
2386
2395
 
2387
- specify "should be able to register an extension with a module have Database#extension extend the module" do
2396
+ it "should be able to register an extension with a module have Database#extension extend the module" do
2388
2397
  Sequel::Database.register_extension(:foo, Module.new{def a; 1; end})
2389
- @db.extension(:foo).a.should == 1
2398
+ @db.extension(:foo).a.must_equal 1
2390
2399
  end
2391
2400
 
2392
- specify "should be able to register an extension with a block and have Database#extension call the block" do
2401
+ it "should be able to register an extension with a block and have Database#extension call the block" do
2393
2402
  @db.quote_identifiers = false
2394
2403
  Sequel::Database.register_extension(:foo){|db| db.quote_identifiers = true}
2395
- @db.extension(:foo).quote_identifiers?.should == true
2404
+ @db.extension(:foo).quote_identifiers?.must_equal true
2396
2405
  end
2397
2406
 
2398
- specify "should be able to register an extension with a callable and Database#extension call the callable" do
2407
+ it "should be able to register an extension with a callable and Database#extension call the callable" do
2399
2408
  @db.quote_identifiers = false
2400
2409
  Sequel::Database.register_extension(:foo, proc{|db| db.quote_identifiers = true})
2401
- @db.extension(:foo).quote_identifiers?.should == true
2410
+ @db.extension(:foo).quote_identifiers?.must_equal true
2402
2411
  end
2403
2412
 
2404
- specify "should be able to load multiple extensions in the same call" do
2413
+ it "should be able to load multiple extensions in the same call" do
2405
2414
  @db.quote_identifiers = false
2406
2415
  @db.identifier_input_method = :downcase
2407
2416
  Sequel::Database.register_extension(:foo, proc{|db| db.quote_identifiers = true})
2408
2417
  Sequel::Database.register_extension(:bar, proc{|db| db.identifier_input_method = nil})
2409
2418
  @db.extension(:foo, :bar)
2410
- @db.quote_identifiers?.should == true
2411
- @db.identifier_input_method.should be_nil
2419
+ @db.quote_identifiers?.must_equal true
2420
+ @db.identifier_input_method.must_equal nil
2412
2421
  end
2413
2422
 
2414
- specify "should return the receiver" do
2423
+ it "should return the receiver" do
2415
2424
  Sequel::Database.register_extension(:foo, Module.new{def a; 1; end})
2416
- @db.extension(:foo).should equal(@db)
2425
+ @db.extension(:foo).must_be_same_as(@db)
2417
2426
  end
2418
2427
 
2419
- specify "should raise an Error if registering with both a module and a block" do
2420
- proc{Sequel::Database.register_extension(:foo, Module.new){}}.should raise_error(Sequel::Error)
2428
+ it "should raise an Error if registering with both a module and a block" do
2429
+ proc{Sequel::Database.register_extension(:foo, Module.new){}}.must_raise(Sequel::Error)
2421
2430
  end
2422
2431
 
2423
- specify "should raise an Error if attempting to load an incompatible extension" do
2424
- proc{@db.extension(:foo2)}.should raise_error(Sequel::Error)
2432
+ it "should raise an Error if attempting to load an incompatible extension" do
2433
+ proc{@db.extension(:foo2)}.must_raise(Sequel::Error)
2425
2434
  end
2426
2435
 
2427
- specify "should be able to load an extension into all future Databases with Database.extension" do
2436
+ it "should be able to load an extension into all future Databases with Database.extension" do
2428
2437
  Sequel::Database.register_extension(:foo, Module.new{def a; 1; end})
2429
2438
  Sequel::Database.register_extension(:bar, Module.new{def b; 2; end})
2430
2439
  Sequel::Database.extension(:foo, :bar)
2431
- @db.should_not respond_to(:a)
2432
- @db.should_not respond_to(:b)
2433
- Sequel.mock.a.should == 1
2434
- Sequel.mock.b.should == 2
2440
+ @db.wont_respond_to(:a)
2441
+ @db.wont_respond_to(:b)
2442
+ Sequel.mock.a.must_equal 1
2443
+ Sequel.mock.b.must_equal 2
2435
2444
  end
2436
2445
  end
2437
2446
 
@@ -2447,18 +2456,18 @@ describe "Database specific exception classes" do
2447
2456
  end
2448
2457
  end
2449
2458
 
2450
- specify "should use appropriate exception classes for given SQL states" do
2459
+ it "should use appropriate exception classes for given SQL states" do
2451
2460
  @db.fetch = ArgumentError
2452
2461
  @db.sql_state = '23502'
2453
- proc{@db.get(:a)}.should raise_error(Sequel::NotNullConstraintViolation)
2462
+ proc{@db.get(:a)}.must_raise(Sequel::NotNullConstraintViolation)
2454
2463
  @db.sql_state = '23503'
2455
- proc{@db.get(:a)}.should raise_error(Sequel::ForeignKeyConstraintViolation)
2464
+ proc{@db.get(:a)}.must_raise(Sequel::ForeignKeyConstraintViolation)
2456
2465
  @db.sql_state = '23505'
2457
- proc{@db.get(:a)}.should raise_error(Sequel::UniqueConstraintViolation)
2466
+ proc{@db.get(:a)}.must_raise(Sequel::UniqueConstraintViolation)
2458
2467
  @db.sql_state = '23513'
2459
- proc{@db.get(:a)}.should raise_error(Sequel::CheckConstraintViolation)
2468
+ proc{@db.get(:a)}.must_raise(Sequel::CheckConstraintViolation)
2460
2469
  @db.sql_state = '40001'
2461
- proc{@db.get(:a)}.should raise_error(Sequel::SerializationFailure)
2470
+ proc{@db.get(:a)}.must_raise(Sequel::SerializationFailure)
2462
2471
  end
2463
2472
  end
2464
2473
 
@@ -2467,36 +2476,36 @@ describe "Database.after_initialize" do
2467
2476
  Sequel::Database.instance_variable_set(:@initialize_hook, Proc.new {|db| })
2468
2477
  end
2469
2478
 
2470
- specify "should allow a block to be run after each new instance is created" do
2479
+ it "should allow a block to be run after each new instance is created" do
2471
2480
  Sequel::Database.after_initialize{|db| db.sql_log_level = :debug }
2472
2481
  db = Sequel.mock
2473
- db.sql_log_level.should == :debug
2482
+ db.sql_log_level.must_equal :debug
2474
2483
  end
2475
2484
 
2476
- specify "should allow multiple hooks to be registered" do
2485
+ it "should allow multiple hooks to be registered" do
2477
2486
  Sequel::Database.after_initialize{|db| db.sql_log_level = :debug }
2478
2487
  Sequel::Database.after_initialize{|db| db.loggers << 11 }
2479
2488
 
2480
2489
  db = Sequel.mock
2481
2490
 
2482
- db.sql_log_level.should == :debug
2483
- db.loggers.should include(11)
2491
+ db.sql_log_level.must_equal :debug
2492
+ db.loggers.must_include(11)
2484
2493
  end
2485
2494
 
2486
- specify "should raise an error if registration is called without a block" do
2495
+ it "should raise an error if registration is called without a block" do
2487
2496
  proc {
2488
2497
  Sequel::Database.after_initialize
2489
- }.should raise_error(Sequel::Error, /must provide block/i)
2498
+ }.must_raise(Sequel::Error, /must provide block/i)
2490
2499
  end
2491
2500
  end
2492
2501
 
2493
2502
  describe "Database#schema_type_class" do
2494
- specify "should return the class or array of classes for the given type symbol" do
2503
+ it "should return the class or array of classes for the given type symbol" do
2495
2504
  db = Sequel.mock
2496
2505
  {:string=>String, :integer=>Integer, :date=>Date, :datetime=>[Time, DateTime],
2497
2506
  :time=>Sequel::SQLTime, :boolean=>[TrueClass, FalseClass], :float=>Float, :decimal=>BigDecimal,
2498
2507
  :blob=>Sequel::SQL::Blob}.each do |sym, klass|
2499
- db.schema_type_class(sym).should == klass
2508
+ db.schema_type_class(sym).must_equal klass
2500
2509
  end
2501
2510
  end
2502
2511
  end
@@ -2512,10 +2521,10 @@ describe "Database#execute_{dui,ddl,insert}" do
2512
2521
  end
2513
2522
  end
2514
2523
 
2515
- specify "should execute the SQL" do
2524
+ it "should execute the SQL" do
2516
2525
  @db.execute_dui "DELETE FROM table"
2517
2526
  @db.execute_ddl "SET foo"
2518
2527
  @db.execute_insert "INSERT INTO table DEFAULT VALUES"
2519
- @db.sqls.should == ["DELETE FROM table", "SET foo", "INSERT INTO table DEFAULT VALUES"]
2528
+ @db.sqls.must_equal ["DELETE FROM table", "SET foo", "INSERT INTO table DEFAULT VALUES"]
2520
2529
  end
2521
2530
  end