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
@@ -34,8 +34,8 @@ describe "Sequel::Plugins::XmlSerializer" do
34
34
  end
35
35
 
36
36
  it "should round trip successfully" do
37
- Artist.from_xml(@artist.to_xml).should == @artist
38
- Album.from_xml(@album.to_xml).should == @album
37
+ Artist.from_xml(@artist.to_xml).must_equal @artist
38
+ Album.from_xml(@album.to_xml).must_equal @album
39
39
  end
40
40
 
41
41
  it "should round trip successfully for namespaced models" do
@@ -48,160 +48,160 @@ describe "Sequel::Plugins::XmlSerializer" do
48
48
  end
49
49
  end
50
50
  artist = XmlSerializerTest::Artist.load(:id=>2, :name=>'YJM')
51
- XmlSerializerTest::Artist.from_xml(artist.to_xml).should == artist
51
+ XmlSerializerTest::Artist.from_xml(artist.to_xml).must_equal artist
52
52
  end
53
53
 
54
54
  it "should round trip successfully with empty strings" do
55
55
  artist = Artist.load(:id=>2, :name=>'')
56
- Artist.from_xml(artist.to_xml).should == artist
56
+ Artist.from_xml(artist.to_xml).must_equal artist
57
57
  end
58
58
 
59
59
  it "should round trip successfully with nil values" do
60
60
  artist = Artist.load(:id=>2, :name=>nil)
61
- Artist.from_xml(artist.to_xml).should == artist
61
+ Artist.from_xml(artist.to_xml).must_equal artist
62
62
  end
63
63
 
64
64
  it "should handle the :only option" do
65
- Artist.from_xml(@artist.to_xml(:only=>:name)).should == Artist.load(:name=>@artist.name)
66
- Album.from_xml(@album.to_xml(:only=>[:id, :name])).should == Album.load(:id=>@album.id, :name=>@album.name)
65
+ Artist.from_xml(@artist.to_xml(:only=>:name)).must_equal Artist.load(:name=>@artist.name)
66
+ Album.from_xml(@album.to_xml(:only=>[:id, :name])).must_equal Album.load(:id=>@album.id, :name=>@album.name)
67
67
  end
68
68
 
69
69
  it "should handle the :except option" do
70
- Artist.from_xml(@artist.to_xml(:except=>:id)).should == Artist.load(:name=>@artist.name)
71
- Album.from_xml(@album.to_xml(:except=>[:id, :artist_id])).should == Album.load(:name=>@album.name)
70
+ Artist.from_xml(@artist.to_xml(:except=>:id)).must_equal Artist.load(:name=>@artist.name)
71
+ Album.from_xml(@album.to_xml(:except=>[:id, :artist_id])).must_equal Album.load(:name=>@album.name)
72
72
  end
73
73
 
74
74
  it "should handle the :include option for associations" do
75
- Artist.from_xml(@artist.to_xml(:include=>:albums), :associations=>:albums).albums.should == [@album]
76
- Album.from_xml(@album.to_xml(:include=>:artist), :associations=>:artist).artist.should == @artist
75
+ Artist.from_xml(@artist.to_xml(:include=>:albums), :associations=>:albums).albums.must_equal [@album]
76
+ Album.from_xml(@album.to_xml(:include=>:artist), :associations=>:artist).artist.must_equal @artist
77
77
  end
78
78
 
79
79
  it "should handle the :include option for arbitrary attributes" do
80
- Album.from_xml(@album.to_xml(:include=>:blah)).blah.should == @album.blah
80
+ Album.from_xml(@album.to_xml(:include=>:blah)).blah.must_equal @album.blah
81
81
  end
82
82
 
83
83
  it "should handle multiple inclusions using an array for the :include option" do
84
84
  a = Album.from_xml(@album.to_xml(:include=>[:blah, :artist]), :associations=>:artist)
85
- a.blah.should == @album.blah
86
- a.artist.should == @artist
85
+ a.blah.must_equal @album.blah
86
+ a.artist.must_equal @artist
87
87
  end
88
88
 
89
89
  it "should handle cascading using a hash for the :include option" do
90
- Artist.from_xml(@artist.to_xml(:include=>{:albums=>{:include=>:artist}}), :associations=>{:albums=>{:associations=>:artist}}).albums.map{|a| a.artist}.should == [@artist]
91
- Album.from_xml(@album.to_xml(:include=>{:artist=>{:include=>:albums}}), :associations=>{:artist=>{:associations=>:albums}}).artist.albums.should == [@album]
90
+ Artist.from_xml(@artist.to_xml(:include=>{:albums=>{:include=>:artist}}), :associations=>{:albums=>{:associations=>:artist}}).albums.map{|a| a.artist}.must_equal [@artist]
91
+ Album.from_xml(@album.to_xml(:include=>{:artist=>{:include=>:albums}}), :associations=>{:artist=>{:associations=>:albums}}).artist.albums.must_equal [@album]
92
92
 
93
- Artist.from_xml(@artist.to_xml(:include=>{:albums=>{:only=>:name}}), :associations=>{:albums=>{:fields=>%w'name'}}).albums.should == [Album.load(:name=>@album.name)]
94
- Album.from_xml(@album.to_xml(:include=>{:artist=>{:except=>:name}}), :associations=>:artist).artist.should == Artist.load(:id=>@artist.id)
93
+ Artist.from_xml(@artist.to_xml(:include=>{:albums=>{:only=>:name}}), :associations=>{:albums=>{:fields=>%w'name'}}).albums.must_equal [Album.load(:name=>@album.name)]
94
+ Album.from_xml(@album.to_xml(:include=>{:artist=>{:except=>:name}}), :associations=>:artist).artist.must_equal Artist.load(:id=>@artist.id)
95
95
 
96
- Artist.from_xml(@artist.to_xml(:include=>{:albums=>{:include=>{:artist=>{:include=>:albums}}}}), :associations=>{:albums=>{:associations=>{:artist=>{:associations=>:albums}}}}).albums.map{|a| a.artist.albums}.should == [[@album]]
97
- Album.from_xml(@album.to_xml(:include=>{:artist=>{:include=>{:albums=>{:only=>:name}}}}), :associations=>{:artist=>{:associations=>{:albums=>{:fields=>%w'name'}}}}).artist.albums.should == [Album.load(:name=>@album.name)]
96
+ Artist.from_xml(@artist.to_xml(:include=>{:albums=>{:include=>{:artist=>{:include=>:albums}}}}), :associations=>{:albums=>{:associations=>{:artist=>{:associations=>:albums}}}}).albums.map{|a| a.artist.albums}.must_equal [[@album]]
97
+ Album.from_xml(@album.to_xml(:include=>{:artist=>{:include=>{:albums=>{:only=>:name}}}}), :associations=>{:artist=>{:associations=>{:albums=>{:fields=>%w'name'}}}}).artist.albums.must_equal [Album.load(:name=>@album.name)]
98
98
  end
99
99
 
100
100
  it "should handle the :include option cascading with an empty hash" do
101
- Album.from_xml(@album.to_xml(:include=>{:artist=>{}}), :associations=>:artist).artist.should == @artist
102
- Album.from_xml(@album.to_xml(:include=>{:blah=>{}})).blah.should == @album.blah
101
+ Album.from_xml(@album.to_xml(:include=>{:artist=>{}}), :associations=>:artist).artist.must_equal @artist
102
+ Album.from_xml(@album.to_xml(:include=>{:blah=>{}})).blah.must_equal @album.blah
103
103
  end
104
104
 
105
105
  it "should support #from_xml to set column values" do
106
106
  @artist.from_xml('<album><name>AS</name></album>')
107
- @artist.name.should == 'AS'
108
- @artist.id.should == 2
107
+ @artist.name.must_equal 'AS'
108
+ @artist.id.must_equal 2
109
109
  end
110
110
 
111
111
  it "should support a :name_proc option when serializing and deserializing" do
112
- Album.from_xml(@album.to_xml(:name_proc=>proc{|s| s.reverse}), :name_proc=>proc{|s| s.reverse}).should == @album
112
+ Album.from_xml(@album.to_xml(:name_proc=>proc{|s| s.reverse}), :name_proc=>proc{|s| s.reverse}).must_equal @album
113
113
  end
114
114
 
115
115
  it "should support a :camelize option when serializing and :underscore option when deserializing" do
116
- Album.from_xml(@album.to_xml(:camelize=>true), :underscore=>true).should == @album
116
+ Album.from_xml(@album.to_xml(:camelize=>true), :underscore=>true).must_equal @album
117
117
  end
118
118
 
119
119
  it "should support a :camelize option when serializing and :underscore option when deserializing" do
120
- Album.from_xml(@album.to_xml(:dasherize=>true), :underscore=>true).should == @album
120
+ Album.from_xml(@album.to_xml(:dasherize=>true), :underscore=>true).must_equal @album
121
121
  end
122
122
 
123
123
  it "should support an :encoding option when serializing" do
124
124
  ["<?xml version=\"1.0\" encoding=\"UTF-8\"?><artist><id>2</id><name>YJM</name></artist>",
125
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><artist><name>YJM</name><id>2</id></artist>"].should include(@artist.to_xml(:encoding=>'UTF-8').gsub(/\n */m, ''))
125
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><artist><name>YJM</name><id>2</id></artist>"].must_include(@artist.to_xml(:encoding=>'UTF-8').gsub(/\n */m, ''))
126
126
  end
127
127
 
128
128
  it "should support a :builder_opts option when serializing" do
129
129
  ["<?xml version=\"1.0\" encoding=\"UTF-8\"?><artist><id>2</id><name>YJM</name></artist>",
130
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?><artist><name>YJM</name><id>2</id></artist>"].should include(@artist.to_xml(:builder_opts=>{:encoding=>'UTF-8'}).gsub(/\n */m, ''))
130
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?><artist><name>YJM</name><id>2</id></artist>"].must_include(@artist.to_xml(:builder_opts=>{:encoding=>'UTF-8'}).gsub(/\n */m, ''))
131
131
  end
132
132
 
133
133
  it "should support an :types option when serializing" do
134
134
  ["<?xml version=\"1.0\"?><artist><id type=\"integer\">2</id><name type=\"string\">YJM</name></artist>",
135
- "<?xml version=\"1.0\"?><artist><name type=\"string\">YJM</name><id type=\"integer\">2</id></artist>"].should include(@artist.to_xml(:types=>true).gsub(/\n */m, ''))
135
+ "<?xml version=\"1.0\"?><artist><name type=\"string\">YJM</name><id type=\"integer\">2</id></artist>"].must_include(@artist.to_xml(:types=>true).gsub(/\n */m, ''))
136
136
  end
137
137
 
138
138
  it "should support an :root_name option when serializing" do
139
139
  ["<?xml version=\"1.0\"?><ar><id>2</id><name>YJM</name></ar>",
140
- "<?xml version=\"1.0\"?><ar><name>YJM</name><id>2</id></ar>"].should include(@artist.to_xml(:root_name=>'ar').gsub(/\n */m, ''))
140
+ "<?xml version=\"1.0\"?><ar><name>YJM</name><id>2</id></ar>"].must_include(@artist.to_xml(:root_name=>'ar').gsub(/\n */m, ''))
141
141
  end
142
142
 
143
143
  it "should support an :array_root_name option when serializing arrays" do
144
144
  artist = @artist
145
145
  Artist.dataset.meta_def(:all){[artist]}
146
146
  ["<?xml version=\"1.0\"?><ars><ar><id>2</id><name>YJM</name></ar></ars>",
147
- "<?xml version=\"1.0\"?><ars><ar><name>YJM</name><id>2</id></ar></ars>"].should include(Artist.to_xml(:array_root_name=>'ars', :root_name=>'ar').gsub(/\n */m, ''))
147
+ "<?xml version=\"1.0\"?><ars><ar><name>YJM</name><id>2</id></ar></ars>"].must_include(Artist.to_xml(:array_root_name=>'ars', :root_name=>'ar').gsub(/\n */m, ''))
148
148
  end
149
149
 
150
150
  it "should raise an exception for xml tags that aren't associations, columns, or setter methods" do
151
151
  Album.send(:undef_method, :blah=)
152
- proc{Album.from_xml(@album.to_xml(:include=>:blah))}.should raise_error(Sequel::MassAssignmentRestriction)
152
+ proc{Album.from_xml(@album.to_xml(:include=>:blah))}.must_raise(Sequel::MassAssignmentRestriction)
153
153
  end
154
154
 
155
155
  it "should support a to_xml class and dataset method" do
156
156
  album = @album
157
157
  Album.dataset.meta_def(:all){[album]}
158
- Album.array_from_xml(Album.to_xml).should == [@album]
159
- Album.array_from_xml(Album.to_xml(:include=>:artist), :associations=>:artist).map{|x| x.artist}.should == [@artist]
160
- Album.array_from_xml(Album.dataset.to_xml(:only=>:name)).should == [Album.load(:name=>@album.name)]
158
+ Album.array_from_xml(Album.to_xml).must_equal [@album]
159
+ Album.array_from_xml(Album.to_xml(:include=>:artist), :associations=>:artist).map{|x| x.artist}.must_equal [@artist]
160
+ Album.array_from_xml(Album.dataset.to_xml(:only=>:name)).must_equal [Album.load(:name=>@album.name)]
161
161
  end
162
162
 
163
163
  it "should have to_xml dataset method respect an :array option" do
164
164
  a = Album.load(:id=>1, :name=>'RF', :artist_id=>3)
165
- Album.array_from_xml(Album.to_xml(:array=>[a])).should == [a]
165
+ Album.array_from_xml(Album.to_xml(:array=>[a])).must_equal [a]
166
166
 
167
167
  a.associations[:artist] = artist = Artist.load(:id=>3, :name=>'YJM')
168
- Album.array_from_xml(Album.to_xml(:array=>[a], :include=>:artist), :associations=>:artist).first.artist.should == artist
168
+ Album.array_from_xml(Album.to_xml(:array=>[a], :include=>:artist), :associations=>:artist).first.artist.must_equal artist
169
169
 
170
170
  artist.associations[:albums] = [a]
171
171
  x = Artist.array_from_xml(Artist.to_xml(:array=>[artist], :include=>:albums), :associations=>[:albums])
172
- x.should == [artist]
173
- x.first.albums.should == [a]
172
+ x.must_equal [artist]
173
+ x.first.albums.must_equal [a]
174
174
  end
175
175
 
176
176
  it "should raise an error if the dataset does not have a row_proc" do
177
- proc{Album.dataset.naked.to_xml}.should raise_error(Sequel::Error)
177
+ proc{Album.dataset.naked.to_xml}.must_raise(Sequel::Error)
178
178
  end
179
179
 
180
180
  it "should raise an error if using parsing empty xml" do
181
- proc{Artist.from_xml("<?xml version=\"1.0\"?>\n")}.should raise_error(Sequel::Error)
182
- proc{Artist.array_from_xml("<?xml version=\"1.0\"?>\n")}.should raise_error(Sequel::Error)
181
+ proc{Artist.from_xml("<?xml version=\"1.0\"?>\n")}.must_raise(Sequel::Error)
182
+ proc{Artist.array_from_xml("<?xml version=\"1.0\"?>\n")}.must_raise(Sequel::Error)
183
183
  end
184
184
 
185
185
  it "should raise an error if attempting to set a restricted column and :all_columns is not used" do
186
186
  Artist.restrict_primary_key
187
- proc{Artist.from_xml(@artist.to_xml)}.should raise_error(Sequel::MassAssignmentRestriction)
187
+ proc{Artist.from_xml(@artist.to_xml)}.must_raise(Sequel::MassAssignmentRestriction)
188
188
  end
189
189
 
190
190
  it "should raise an error if an unsupported association is passed in the :associations option" do
191
191
  Artist.association_reflections.delete(:albums)
192
- proc{Artist.from_xml(@artist.to_xml(:include=>:albums), :associations=>:albums)}.should raise_error(Sequel::Error)
192
+ proc{Artist.from_xml(@artist.to_xml(:include=>:albums), :associations=>:albums)}.must_raise(Sequel::Error)
193
193
  end
194
194
 
195
195
  it "should raise an error if using from_xml and XML represents an array" do
196
- proc{Artist.from_xml(Artist.to_xml(:array=>[@artist]))}.should raise_error(Sequel::MassAssignmentRestriction)
196
+ proc{Artist.from_xml(Artist.to_xml(:array=>[@artist]))}.must_raise(Sequel::MassAssignmentRestriction)
197
197
  end
198
198
 
199
199
  it "should raise an error if using array_from_xml and XML does not represent an array" do
200
- proc{Artist.array_from_xml(@artist.to_xml)}.should raise_error(Sequel::Error)
200
+ proc{Artist.array_from_xml(@artist.to_xml)}.must_raise(Sequel::Error)
201
201
  end
202
202
 
203
203
  it "should raise an error if using an unsupported :associations option" do
204
- proc{Artist.from_xml(@artist.to_xml, :associations=>'')}.should raise_error(Sequel::Error)
204
+ proc{Artist.from_xml(@artist.to_xml, :associations=>'')}.must_raise(Sequel::Error)
205
205
  end
206
206
  end
207
207
  end
@@ -0,0 +1,55 @@
1
+ gem 'minitest'
2
+ require 'minitest/autorun'
3
+ require 'minitest/hooks/default'
4
+ require 'minitest/shared_description'
5
+
6
+ def Sequel.guarded?(*checked)
7
+ unless ENV['SEQUEL_NO_PENDING']
8
+ checked.each do |c|
9
+ case c
10
+ when DB.database_type
11
+ return c
12
+ when Array
13
+ case c.length
14
+ when 1
15
+ return c if c.first == DB.adapter_scheme
16
+ when 2
17
+ if c.first.is_a?(Proc)
18
+ return c if c.last == DB.database_type && c.first.call(DB)
19
+ elsif c.last.is_a?(Proc)
20
+ return c if c.first == DB.adapter_scheme && c.last.call(DB)
21
+ else
22
+ return c if c.first == DB.adapter_scheme && c.last == DB.database_type
23
+ end
24
+ when 3
25
+ return c if c[0] == DB.adapter_scheme && c[1] == DB.database_type && c[2].call(DB)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ false
31
+ end
32
+
33
+ module Minitest::Spec::DSL
34
+ def cspecify(message, *checked, &block)
35
+ if pending = Sequel.guarded?(*checked)
36
+ it(message) do
37
+ skip "Not yet working on #{Array(pending).map{|x| x.is_a?(Proc) ? :proc : x}.join(', ')}"
38
+ end
39
+ else
40
+ it(message, &block)
41
+ end
42
+ end
43
+ end
44
+
45
+ class Minitest::HooksSpec
46
+ def log
47
+ begin
48
+ DB.loggers << Logger.new(STDOUT)
49
+ yield
50
+ ensure
51
+ DB.loggers.pop
52
+ end
53
+ end
54
+ end
55
+
@@ -1,7 +1,7 @@
1
1
  require File.join(File.dirname(File.expand_path(__FILE__)), 'spec_helper.rb')
2
2
 
3
- shared_examples_for "one_to_one eager limit strategies" do
4
- specify "eager loading one_to_one associations should work correctly" do
3
+ OneToOneEagerLimitStrategies = shared_description do
4
+ it "eager loading one_to_one associations should work correctly" do
5
5
  Artist.one_to_one :first_album, {:clone=>:first_album}.merge(@els) if @els
6
6
  Artist.one_to_one :last_album, {:clone=>:last_album}.merge(@els) if @els
7
7
  Artist.one_to_one :second_album, {:clone=>:second_album}.merge(@els) if @els && @els[:eager_limit_strategy] != :distinct_on
@@ -10,29 +10,29 @@ shared_examples_for "one_to_one eager limit strategies" do
10
10
  ar = @pr.call[1]
11
11
 
12
12
  a = Artist.eager(:first_album, :last_album, :second_album).order(:name).all
13
- a.should == [@artist, ar]
14
- a.first.first_album.should == @album
15
- a.first.last_album.should == diff_album
16
- a.first.second_album.should == diff_album
17
- a.last.first_album.should == nil
18
- a.last.last_album.should == nil
19
- a.last.second_album.should == nil
13
+ a.must_equal [@artist, ar]
14
+ a.first.first_album.must_equal @album
15
+ a.first.last_album.must_equal diff_album
16
+ a.first.second_album.must_equal diff_album
17
+ a.last.first_album.must_equal nil
18
+ a.last.last_album.must_equal nil
19
+ a.last.second_album.must_equal nil
20
20
 
21
21
  # Check that no extra columns got added by the eager loading
22
- a.first.first_album.values.should == @album.values
23
- a.first.last_album.values.should == diff_album.values
24
- a.first.second_album.values.should == diff_album.values
22
+ a.first.first_album.values.must_equal @album.values
23
+ a.first.last_album.values.must_equal diff_album.values
24
+ a.first.second_album.values.must_equal diff_album.values
25
25
 
26
26
  same_album = @same_album.call
27
27
  a = Artist.eager(:first_album).order(:name).all
28
- a.should == [@artist, ar]
29
- [@album, same_album].should include(a.first.first_album)
30
- a.last.first_album.should == nil
28
+ a.must_equal [@artist, ar]
29
+ [@album, same_album].must_include(a.first.first_album)
30
+ a.last.first_album.must_equal nil
31
31
  end
32
32
  end
33
33
 
34
- shared_examples_for "one_to_one eager_graph limit strategies" do
35
- specify "eager graphing one_to_one associations should work correctly" do
34
+ OneToOneEagerGraphLimitStrategies = shared_description do
35
+ it "eager graphing one_to_one associations should work correctly" do
36
36
  @album.update(:artist => @artist)
37
37
  diff_album = @diff_album.call
38
38
  ar = @pr.call[1]
@@ -40,37 +40,37 @@ shared_examples_for "one_to_one eager_graph limit strategies" do
40
40
  limit_strategy = {:limit_strategy=>@els[:eager_limit_strategy]}
41
41
 
42
42
  a = ds.eager_graph_with_options(:first_album, limit_strategy).all
43
- a.should == [@artist, ar]
44
- a.first.first_album.should == @album
45
- a.last.first_album.should == nil
46
- a.first.first_album.values.should == @album.values
43
+ a.must_equal [@artist, ar]
44
+ a.first.first_album.must_equal @album
45
+ a.last.first_album.must_equal nil
46
+ a.first.first_album.values.must_equal @album.values
47
47
 
48
48
  a = ds.eager_graph_with_options(:last_album, limit_strategy).all
49
49
  a = ds.eager_graph(:last_album).all
50
- a.should == [@artist, ar]
51
- a.first.last_album.should == diff_album
52
- a.last.last_album.should == nil
53
- a.first.last_album.values.should == diff_album.values
50
+ a.must_equal [@artist, ar]
51
+ a.first.last_album.must_equal diff_album
52
+ a.last.last_album.must_equal nil
53
+ a.first.last_album.values.must_equal diff_album.values
54
54
 
55
55
  if @els[:eager_limit_strategy] != :distinct_on && (@els[:eager_limit_strategy] != :correlated_subquery || Album.dataset.supports_offsets_in_correlated_subqueries?)
56
56
  a = ds.eager_graph_with_options(:second_album, limit_strategy).all
57
57
  a = ds.eager_graph(:second_album).all
58
- a.should == [@artist, ar]
59
- a.first.second_album.should == diff_album
60
- a.last.second_album.should == nil
61
- a.first.second_album.values.should == diff_album.values
58
+ a.must_equal [@artist, ar]
59
+ a.first.second_album.must_equal diff_album
60
+ a.last.second_album.must_equal nil
61
+ a.first.second_album.values.must_equal diff_album.values
62
62
  end
63
63
 
64
64
  same_album = @same_album.call
65
65
  a = ds.eager_graph_with_options(:first_album, limit_strategy).all
66
- a.should == [@artist, ar]
67
- [@album, same_album].should include(a.first.first_album)
68
- a.last.first_album.should == nil
66
+ a.must_equal [@artist, ar]
67
+ [@album, same_album].must_include(a.first.first_album)
68
+ a.last.first_album.must_equal nil
69
69
  end
70
70
  end
71
71
 
72
- shared_examples_for "one_to_many eager limit strategies" do
73
- specify "should correctly handle limits and offsets when eager loading one_to_many associations" do
72
+ OneToManyEagerLimitStrategies = shared_description do
73
+ it "should correctly handle limits and offsets when eager loading one_to_many associations" do
74
74
  Artist.one_to_many :first_two_albums, {:clone=>:first_two_albums}.merge(@els) if @els
75
75
  Artist.one_to_many :second_two_albums, {:clone=>:second_two_albums}.merge(@els) if @els
76
76
  Artist.one_to_many :not_first_albums, {:clone=>:not_first_albums}.merge(@els) if @els
@@ -81,26 +81,26 @@ shared_examples_for "one_to_many eager limit strategies" do
81
81
  ar = @pr.call[1]
82
82
 
83
83
  ars = Artist.eager(:first_two_albums, :second_two_albums, :not_first_albums, :last_two_albums).order(:name).all
84
- ars.should == [@artist, ar]
85
- ars.first.first_two_albums.should == [@album, middle_album]
86
- ars.first.second_two_albums.should == [middle_album, diff_album]
87
- ars.first.not_first_albums.should == [middle_album, diff_album]
88
- ars.first.last_two_albums.should == [diff_album, middle_album]
89
- ars.last.first_two_albums.should == []
90
- ars.last.second_two_albums.should == []
91
- ars.last.not_first_albums.should == []
92
- ars.last.last_two_albums.should == []
84
+ ars.must_equal [@artist, ar]
85
+ ars.first.first_two_albums.must_equal [@album, middle_album]
86
+ ars.first.second_two_albums.must_equal [middle_album, diff_album]
87
+ ars.first.not_first_albums.must_equal [middle_album, diff_album]
88
+ ars.first.last_two_albums.must_equal [diff_album, middle_album]
89
+ ars.last.first_two_albums.must_equal []
90
+ ars.last.second_two_albums.must_equal []
91
+ ars.last.not_first_albums.must_equal []
92
+ ars.last.last_two_albums.must_equal []
93
93
 
94
94
  # Check that no extra columns got added by the eager loading
95
- ars.first.first_two_albums.map{|x| x.values}.should == [@album, middle_album].map{|x| x.values}
96
- ars.first.second_two_albums.map{|x| x.values}.should == [middle_album, diff_album].map{|x| x.values}
97
- ars.first.not_first_albums.map{|x| x.values}.should == [middle_album, diff_album].map{|x| x.values}
98
- ars.first.last_two_albums.map{|x| x.values}.should == [diff_album, middle_album].map{|x| x.values}
95
+ ars.first.first_two_albums.map{|x| x.values}.must_equal [@album, middle_album].map{|x| x.values}
96
+ ars.first.second_two_albums.map{|x| x.values}.must_equal [middle_album, diff_album].map{|x| x.values}
97
+ ars.first.not_first_albums.map{|x| x.values}.must_equal [middle_album, diff_album].map{|x| x.values}
98
+ ars.first.last_two_albums.map{|x| x.values}.must_equal [diff_album, middle_album].map{|x| x.values}
99
99
  end
100
100
  end
101
101
 
102
- shared_examples_for "one_to_many eager_graph limit strategies" do
103
- specify "should correctly handle limits and offsets when eager graphing one_to_many associations" do
102
+ OneToManyEagerGraphLimitStrategies = shared_description do
103
+ it "should correctly handle limits and offsets when eager graphing one_to_many associations" do
104
104
  @album.update(:artist => @artist)
105
105
  middle_album = @middle_album.call
106
106
  diff_album = @diff_album.call
@@ -109,35 +109,35 @@ shared_examples_for "one_to_many eager_graph limit strategies" do
109
109
  limit_strategy = {:limit_strategy=>@els[:eager_limit_strategy]}
110
110
 
111
111
  ars = ds.eager_graph_with_options(:first_two_albums, limit_strategy).all
112
- ars.should == [@artist, ar]
113
- ars.first.first_two_albums.should == [@album, middle_album]
114
- ars.last.first_two_albums.should == []
115
- ars.first.first_two_albums.map{|x| x.values}.should == [@album, middle_album].map{|x| x.values}
112
+ ars.must_equal [@artist, ar]
113
+ ars.first.first_two_albums.must_equal [@album, middle_album]
114
+ ars.last.first_two_albums.must_equal []
115
+ ars.first.first_two_albums.map{|x| x.values}.must_equal [@album, middle_album].map{|x| x.values}
116
116
 
117
117
  if @els[:eager_limit_strategy] != :correlated_subquery || Album.dataset.supports_offsets_in_correlated_subqueries?
118
118
  ars = ds.eager_graph_with_options(:second_two_albums, limit_strategy).all
119
- ars.should == [@artist, ar]
120
- ars.first.second_two_albums.should == [middle_album, diff_album]
121
- ars.last.second_two_albums.should == []
122
- ars.first.second_two_albums.map{|x| x.values}.should == [middle_album, diff_album].map{|x| x.values}
119
+ ars.must_equal [@artist, ar]
120
+ ars.first.second_two_albums.must_equal [middle_album, diff_album]
121
+ ars.last.second_two_albums.must_equal []
122
+ ars.first.second_two_albums.map{|x| x.values}.must_equal [middle_album, diff_album].map{|x| x.values}
123
123
 
124
124
  ars = ds.eager_graph_with_options(:not_first_albums, limit_strategy).all
125
- ars.should == [@artist, ar]
126
- ars.first.not_first_albums.should == [middle_album, diff_album]
127
- ars.last.not_first_albums.should == []
128
- ars.first.not_first_albums.map{|x| x.values}.should == [middle_album, diff_album].map{|x| x.values}
125
+ ars.must_equal [@artist, ar]
126
+ ars.first.not_first_albums.must_equal [middle_album, diff_album]
127
+ ars.last.not_first_albums.must_equal []
128
+ ars.first.not_first_albums.map{|x| x.values}.must_equal [middle_album, diff_album].map{|x| x.values}
129
129
  end
130
130
 
131
131
  ars = ds.eager_graph_with_options(:last_two_albums, limit_strategy).all
132
- ars.should == [@artist, ar]
133
- ars.first.last_two_albums.should == [diff_album, middle_album]
134
- ars.last.last_two_albums.should == []
135
- ars.first.last_two_albums.map{|x| x.values}.should == [diff_album, middle_album].map{|x| x.values}
132
+ ars.must_equal [@artist, ar]
133
+ ars.first.last_two_albums.must_equal [diff_album, middle_album]
134
+ ars.last.last_two_albums.must_equal []
135
+ ars.first.last_two_albums.map{|x| x.values}.must_equal [diff_album, middle_album].map{|x| x.values}
136
136
  end
137
137
  end
138
138
 
139
- shared_examples_for "one_through_one eager limit strategies" do
140
- specify "should correctly handle offsets when eager loading one_through_one associations" do
139
+ OneThroughOneEagerLimitStrategies = shared_description do
140
+ it "should correctly handle offsets when eager loading one_through_one associations" do
141
141
  Album.one_through_one :first_tag, {:clone=>:first_tag}.merge(@els) if @els
142
142
  Album.one_through_one :second_tag, {:clone=>:second_tag}.merge(@els) if @els && @els[:eager_limit_strategy] != :distinct_on
143
143
  Album.one_through_one :last_tag, {:clone=>:last_tag}.merge(@els) if @els
@@ -145,50 +145,50 @@ shared_examples_for "one_through_one eager limit strategies" do
145
145
  al = @pr.call.first
146
146
 
147
147
  als = Album.eager(:first_tag, :second_tag, :last_tag).order(:name).all
148
- als.should == [@album, al]
149
- als.first.first_tag.should == @tag
150
- als.first.second_tag.should == tu
151
- als.first.last_tag.should == tv
152
- als.last.first_tag.should == nil
153
- als.last.second_tag.should == nil
154
- als.last.last_tag.should == nil
148
+ als.must_equal [@album, al]
149
+ als.first.first_tag.must_equal @tag
150
+ als.first.second_tag.must_equal tu
151
+ als.first.last_tag.must_equal tv
152
+ als.last.first_tag.must_equal nil
153
+ als.last.second_tag.must_equal nil
154
+ als.last.last_tag.must_equal nil
155
155
 
156
156
  # Check that no extra columns got added by the eager loading
157
- als.first.first_tag.values.should == @tag.values
158
- als.first.second_tag.values.should == tu.values
159
- als.first.last_tag.values.should == tv.values
157
+ als.first.first_tag.values.must_equal @tag.values
158
+ als.first.second_tag.values.must_equal tu.values
159
+ als.first.last_tag.values.must_equal tv.values
160
160
  end
161
161
  end
162
162
 
163
- shared_examples_for "one_through_one eager_graph limit strategies" do
164
- specify "should correctly handle offsets when eager graphing one_through_one associations" do
163
+ OneThroughOneEagerGraphLimitStrategies = shared_description do
164
+ it "should correctly handle offsets when eager graphing one_through_one associations" do
165
165
  tu, tv = @other_tags.call
166
166
  al = @pr.call.first
167
167
  ds = Album.order(:albums__name)
168
168
  limit_strategy = {:limit_strategy=>@els[:eager_limit_strategy]}
169
169
 
170
170
  als = ds.eager_graph_with_options(:first_tag, limit_strategy).all
171
- als.should == [@album, al]
172
- als.first.first_tag.should == @tag
173
- als.last.first_tag.should == nil
174
- als.first.first_tag.values.should == @tag.values
171
+ als.must_equal [@album, al]
172
+ als.first.first_tag.must_equal @tag
173
+ als.last.first_tag.must_equal nil
174
+ als.first.first_tag.values.must_equal @tag.values
175
175
 
176
176
  als = ds.eager_graph_with_options(:second_tag, @els[:eager_limit_strategy] != :distinct_on ? limit_strategy : {}).all
177
- als.should == [@album, al]
178
- als.first.second_tag.should == tu
179
- als.last.second_tag.should == nil
180
- als.first.second_tag.values.should == tu.values
177
+ als.must_equal [@album, al]
178
+ als.first.second_tag.must_equal tu
179
+ als.last.second_tag.must_equal nil
180
+ als.first.second_tag.values.must_equal tu.values
181
181
 
182
182
  als = ds.eager_graph_with_options(:last_tag, limit_strategy).all
183
- als.should == [@album, al]
184
- als.first.last_tag.should == tv
185
- als.last.last_tag.should == nil
186
- als.first.last_tag.values.should == tv.values
183
+ als.must_equal [@album, al]
184
+ als.first.last_tag.must_equal tv
185
+ als.last.last_tag.must_equal nil
186
+ als.first.last_tag.values.must_equal tv.values
187
187
  end
188
188
  end
189
189
 
190
- shared_examples_for "many_to_many eager limit strategies" do
191
- specify "should correctly handle limits and offsets when eager loading many_to_many associations" do
190
+ ManyToManyEagerLimitStrategies = shared_description do
191
+ it "should correctly handle limits and offsets when eager loading many_to_many associations" do
192
192
  Album.send @many_to_many_method||:many_to_many, :first_two_tags, {:clone=>:first_two_tags}.merge(@els) if @els
193
193
  Album.send @many_to_many_method||:many_to_many, :second_two_tags, {:clone=>:second_two_tags}.merge(@els) if @els
194
194
  Album.send @many_to_many_method||:many_to_many, :not_first_tags, {:clone=>:not_first_tags}.merge(@els) if @els
@@ -198,25 +198,25 @@ shared_examples_for "many_to_many eager limit strategies" do
198
198
  al.add_tag(tu)
199
199
 
200
200
  als = Album.eager(:first_two_tags, :second_two_tags, :not_first_tags, :last_two_tags).order(:name).all
201
- als.should == [@album, al]
202
- als.first.first_two_tags.should == [@tag, tu]
203
- als.first.second_two_tags.should == [tu, tv]
204
- als.first.not_first_tags.should == [tu, tv]
205
- als.first.last_two_tags.should == [tv, tu]
206
- als.last.first_two_tags.should == [tu]
207
- als.last.second_two_tags.should == []
208
- als.last.last_two_tags.should == [tu]
201
+ als.must_equal [@album, al]
202
+ als.first.first_two_tags.must_equal [@tag, tu]
203
+ als.first.second_two_tags.must_equal [tu, tv]
204
+ als.first.not_first_tags.must_equal [tu, tv]
205
+ als.first.last_two_tags.must_equal [tv, tu]
206
+ als.last.first_two_tags.must_equal [tu]
207
+ als.last.second_two_tags.must_equal []
208
+ als.last.last_two_tags.must_equal [tu]
209
209
 
210
210
  # Check that no extra columns got added by the eager loading
211
- als.first.first_two_tags.map{|x| x.values}.should == [@tag, tu].map{|x| x.values}
212
- als.first.second_two_tags.map{|x| x.values}.should == [tu, tv].map{|x| x.values}
213
- als.first.not_first_tags.map{|x| x.values}.should == [tu, tv].map{|x| x.values}
214
- als.first.last_two_tags.map{|x| x.values}.should == [tv, tu].map{|x| x.values}
211
+ als.first.first_two_tags.map{|x| x.values}.must_equal [@tag, tu].map{|x| x.values}
212
+ als.first.second_two_tags.map{|x| x.values}.must_equal [tu, tv].map{|x| x.values}
213
+ als.first.not_first_tags.map{|x| x.values}.must_equal [tu, tv].map{|x| x.values}
214
+ als.first.last_two_tags.map{|x| x.values}.must_equal [tv, tu].map{|x| x.values}
215
215
  end
216
216
  end
217
217
 
218
- shared_examples_for "many_to_many eager_graph limit strategies" do
219
- specify "should correctly handle limits and offsets when eager loading many_to_many associations" do
218
+ ManyToManyEagerGraphLimitStrategies = shared_description do
219
+ it "should correctly handle limits and offsets when eager loading many_to_many associations" do
220
220
  tu, tv = @other_tags.call
221
221
  al = @pr.call.first
222
222
  al.add_tag(tu)
@@ -224,33 +224,33 @@ shared_examples_for "many_to_many eager_graph limit strategies" do
224
224
  limit_strategy = {:limit_strategy=>(@els||{})[:eager_limit_strategy]}
225
225
 
226
226
  als = ds.eager_graph_with_options(:first_two_tags, limit_strategy).all
227
- als.should == [@album, al]
228
- als.first.first_two_tags.should == [@tag, tu]
229
- als.last.first_two_tags.should == [tu]
230
- als.first.first_two_tags.map{|x| x.values}.should == [@tag, tu].map{|x| x.values}
227
+ als.must_equal [@album, al]
228
+ als.first.first_two_tags.must_equal [@tag, tu]
229
+ als.last.first_two_tags.must_equal [tu]
230
+ als.first.first_two_tags.map{|x| x.values}.must_equal [@tag, tu].map{|x| x.values}
231
231
 
232
232
  als = ds.eager_graph_with_options(:second_two_tags, limit_strategy).all
233
- als.should == [@album, al]
234
- als.first.second_two_tags.should == [tu, tv]
235
- als.last.second_two_tags.should == []
236
- als.first.second_two_tags.map{|x| x.values}.should == [tu, tv].map{|x| x.values}
233
+ als.must_equal [@album, al]
234
+ als.first.second_two_tags.must_equal [tu, tv]
235
+ als.last.second_two_tags.must_equal []
236
+ als.first.second_two_tags.map{|x| x.values}.must_equal [tu, tv].map{|x| x.values}
237
237
 
238
238
  als = ds.eager_graph_with_options(:not_first_tags, limit_strategy).all
239
- als.should == [@album, al]
240
- als.first.not_first_tags.should == [tu, tv]
241
- als.last.not_first_tags.should == []
242
- als.first.not_first_tags.map{|x| x.values}.should == [tu, tv].map{|x| x.values}
239
+ als.must_equal [@album, al]
240
+ als.first.not_first_tags.must_equal [tu, tv]
241
+ als.last.not_first_tags.must_equal []
242
+ als.first.not_first_tags.map{|x| x.values}.must_equal [tu, tv].map{|x| x.values}
243
243
 
244
244
  als = ds.eager_graph_with_options(:last_two_tags, limit_strategy).all
245
- als.should == [@album, al]
246
- als.first.last_two_tags.should == [tv, tu]
247
- als.last.last_two_tags.should == [tu]
248
- als.first.last_two_tags.map{|x| x.values}.should == [tv, tu].map{|x| x.values}
245
+ als.must_equal [@album, al]
246
+ als.first.last_two_tags.must_equal [tv, tu]
247
+ als.last.last_two_tags.must_equal [tu]
248
+ als.first.last_two_tags.map{|x| x.values}.must_equal [tv, tu].map{|x| x.values}
249
249
  end
250
250
  end
251
251
 
252
- shared_examples_for "many_through_many eager limit strategies" do
253
- specify "should correctly handle limits and offsets when eager loading many_through_many associations" do
252
+ ManyThroughManyEagerLimitStrategies = shared_description do
253
+ it "should correctly handle limits and offsets when eager loading many_through_many associations" do
254
254
  Artist.many_through_many :first_two_tags, {:clone=>:first_two_tags}.merge(@els) if @els
255
255
  Artist.many_through_many :second_two_tags, {:clone=>:second_two_tags}.merge(@els) if @els
256
256
  Artist.many_through_many :not_first_tags, {:clone=>:not_first_tags}.merge(@els) if @els
@@ -262,26 +262,26 @@ shared_examples_for "many_through_many eager limit strategies" do
262
262
  al.add_tag(tu)
263
263
 
264
264
  ars = Artist.eager(:first_two_tags, :second_two_tags, :not_first_tags, :last_two_tags).order(:name).all
265
- ars.should == [@artist, ar]
266
- ars.first.first_two_tags.should == [@tag, tu]
267
- ars.first.second_two_tags.should == [tu, tv]
268
- ars.first.not_first_tags.should == [tu, tv]
269
- ars.first.last_two_tags.should == [tv, tu]
270
- ars.last.first_two_tags.should == [tu]
271
- ars.last.second_two_tags.should == []
272
- ars.last.not_first_tags.should == []
273
- ars.last.last_two_tags.should == [tu]
265
+ ars.must_equal [@artist, ar]
266
+ ars.first.first_two_tags.must_equal [@tag, tu]
267
+ ars.first.second_two_tags.must_equal [tu, tv]
268
+ ars.first.not_first_tags.must_equal [tu, tv]
269
+ ars.first.last_two_tags.must_equal [tv, tu]
270
+ ars.last.first_two_tags.must_equal [tu]
271
+ ars.last.second_two_tags.must_equal []
272
+ ars.last.not_first_tags.must_equal []
273
+ ars.last.last_two_tags.must_equal [tu]
274
274
 
275
275
  # Check that no extra columns got added by the eager loading
276
- ars.first.first_two_tags.map{|x| x.values}.should == [@tag, tu].map{|x| x.values}
277
- ars.first.second_two_tags.map{|x| x.values}.should == [tu, tv].map{|x| x.values}
278
- ars.first.not_first_tags.map{|x| x.values}.should == [tu, tv].map{|x| x.values}
279
- ars.first.last_two_tags.map{|x| x.values}.should == [tv, tu].map{|x| x.values}
276
+ ars.first.first_two_tags.map{|x| x.values}.must_equal [@tag, tu].map{|x| x.values}
277
+ ars.first.second_two_tags.map{|x| x.values}.must_equal [tu, tv].map{|x| x.values}
278
+ ars.first.not_first_tags.map{|x| x.values}.must_equal [tu, tv].map{|x| x.values}
279
+ ars.first.last_two_tags.map{|x| x.values}.must_equal [tv, tu].map{|x| x.values}
280
280
  end
281
281
  end
282
282
 
283
- shared_examples_for "many_through_many eager_graph limit strategies" do
284
- specify "should correctly handle limits and offsets when eager loading many_through_many associations" do
283
+ ManyThroughManyEagerGraphLimitStrategies = shared_description do
284
+ it "should correctly handle limits and offsets when eager loading many_through_many associations" do
285
285
  @album.update(:artist => @artist)
286
286
  tu, tv = @other_tags.call
287
287
  al, ar, _ = @pr.call
@@ -291,33 +291,33 @@ shared_examples_for "many_through_many eager_graph limit strategies" do
291
291
  limit_strategy = {:limit_strategy=>@els[:eager_limit_strategy]}
292
292
 
293
293
  ars = ds.eager_graph_with_options(:first_two_tags, limit_strategy).all
294
- ars.should == [@artist, ar]
295
- ars.first.first_two_tags.should == [@tag, tu]
296
- ars.last.first_two_tags.should == [tu]
297
- ars.first.first_two_tags.map{|x| x.values}.should == [@tag, tu].map{|x| x.values}
294
+ ars.must_equal [@artist, ar]
295
+ ars.first.first_two_tags.must_equal [@tag, tu]
296
+ ars.last.first_two_tags.must_equal [tu]
297
+ ars.first.first_two_tags.map{|x| x.values}.must_equal [@tag, tu].map{|x| x.values}
298
298
 
299
299
  ars = ds.eager_graph_with_options(:second_two_tags, limit_strategy).all
300
- ars.should == [@artist, ar]
301
- ars.first.second_two_tags.should == [tu, tv]
302
- ars.last.second_two_tags.should == []
303
- ars.first.second_two_tags.map{|x| x.values}.should == [tu, tv].map{|x| x.values}
300
+ ars.must_equal [@artist, ar]
301
+ ars.first.second_two_tags.must_equal [tu, tv]
302
+ ars.last.second_two_tags.must_equal []
303
+ ars.first.second_two_tags.map{|x| x.values}.must_equal [tu, tv].map{|x| x.values}
304
304
 
305
305
  ars = ds.eager_graph_with_options(:not_first_tags, limit_strategy).all
306
- ars.should == [@artist, ar]
307
- ars.first.not_first_tags.should == [tu, tv]
308
- ars.last.not_first_tags.should == []
309
- ars.first.not_first_tags.map{|x| x.values}.should == [tu, tv].map{|x| x.values}
306
+ ars.must_equal [@artist, ar]
307
+ ars.first.not_first_tags.must_equal [tu, tv]
308
+ ars.last.not_first_tags.must_equal []
309
+ ars.first.not_first_tags.map{|x| x.values}.must_equal [tu, tv].map{|x| x.values}
310
310
 
311
311
  ars = ds.eager_graph_with_options(:last_two_tags, limit_strategy).all
312
- ars.should == [@artist, ar]
313
- ars.first.last_two_tags.should == [tv, tu]
314
- ars.last.last_two_tags.should == [tu]
315
- ars.first.last_two_tags.map{|x| x.values}.should == [tv, tu].map{|x| x.values}
312
+ ars.must_equal [@artist, ar]
313
+ ars.first.last_two_tags.must_equal [tv, tu]
314
+ ars.last.last_two_tags.must_equal [tu]
315
+ ars.first.last_two_tags.map{|x| x.values}.must_equal [tv, tu].map{|x| x.values}
316
316
  end
317
317
  end
318
318
 
319
- shared_examples_for "one_through_many eager limit strategies" do
320
- specify "should correctly handle offsets when eager loading one_through_many associations" do
319
+ OneThroughManyEagerLimitStrategies = shared_description do
320
+ it "should correctly handle offsets when eager loading one_through_many associations" do
321
321
  Artist.one_through_many :first_tag, {:clone=>:first_tag}.merge(@els) if @els
322
322
  Artist.one_through_many :second_tag, {:clone=>:second_tag}.merge(@els) if @els && @els[:eager_limit_strategy] != :distinct_on
323
323
  Artist.one_through_many :last_tag, {:clone=>:last_tag}.merge(@els) if @els
@@ -328,23 +328,23 @@ shared_examples_for "one_through_many eager limit strategies" do
328
328
  al.add_tag(tu)
329
329
 
330
330
  ars = Artist.eager(:first_tag, :second_tag, :last_tag).order(:name).all
331
- ars.should == [@artist, ar]
332
- ars.first.first_tag.should == @tag
333
- ars.first.second_tag.should == tu
334
- ars.first.last_tag.should == tv
335
- ars.last.first_tag.should == tu
336
- ars.last.second_tag.should == nil
337
- ars.last.last_tag.should == tu
331
+ ars.must_equal [@artist, ar]
332
+ ars.first.first_tag.must_equal @tag
333
+ ars.first.second_tag.must_equal tu
334
+ ars.first.last_tag.must_equal tv
335
+ ars.last.first_tag.must_equal tu
336
+ ars.last.second_tag.must_equal nil
337
+ ars.last.last_tag.must_equal tu
338
338
 
339
339
  # Check that no extra columns got added by the eager loading
340
- ars.first.first_tag.values.should == @tag.values
341
- ars.first.second_tag.values.should == tu.values
342
- ars.first.last_tag.values.should == tv.values
340
+ ars.first.first_tag.values.must_equal @tag.values
341
+ ars.first.second_tag.values.must_equal tu.values
342
+ ars.first.last_tag.values.must_equal tv.values
343
343
  end
344
344
  end
345
345
 
346
- shared_examples_for "one_through_many eager_graph limit strategies" do
347
- specify "should correctly handle offsets when eager graphing one_through_many associations" do
346
+ OneThroughManyEagerGraphLimitStrategies = shared_description do
347
+ it "should correctly handle offsets when eager graphing one_through_many associations" do
348
348
  @album.update(:artist => @artist)
349
349
  tu, tv = @other_tags.call
350
350
  al, ar, _ = @pr.call
@@ -354,331 +354,331 @@ shared_examples_for "one_through_many eager_graph limit strategies" do
354
354
  limit_strategy = {:limit_strategy=>@els[:eager_limit_strategy]}
355
355
 
356
356
  ars = ds.eager_graph_with_options(:first_tag, limit_strategy).all
357
- ars.should == [@artist, ar]
358
- ars.first.first_tag.should == @tag
359
- ars.last.first_tag.should == tu
360
- ars.first.first_tag.values.should == @tag.values
357
+ ars.must_equal [@artist, ar]
358
+ ars.first.first_tag.must_equal @tag
359
+ ars.last.first_tag.must_equal tu
360
+ ars.first.first_tag.values.must_equal @tag.values
361
361
 
362
362
  ars = ds.eager_graph_with_options(:second_tag, @els[:eager_limit_strategy] != :distinct_on ? limit_strategy : {}).all
363
- ars.should == [@artist, ar]
364
- ars.first.second_tag.should == tu
365
- ars.last.second_tag.should == nil
366
- ars.first.second_tag.values.should == tu.values
363
+ ars.must_equal [@artist, ar]
364
+ ars.first.second_tag.must_equal tu
365
+ ars.last.second_tag.must_equal nil
366
+ ars.first.second_tag.values.must_equal tu.values
367
367
 
368
368
  ars = ds.eager_graph_with_options(:last_tag, limit_strategy).all
369
- ars.should == [@artist, ar]
370
- ars.first.last_tag.should == tv
371
- ars.last.last_tag.should == tu
372
- ars.first.last_tag.values.should == tv.values
369
+ ars.must_equal [@artist, ar]
370
+ ars.first.last_tag.must_equal tv
371
+ ars.last.last_tag.must_equal tu
372
+ ars.first.last_tag.values.must_equal tv.values
373
373
  end
374
374
  end
375
375
 
376
- shared_examples_for "eager limit strategies" do
377
- it_should_behave_like "one_to_one eager limit strategies"
378
- it_should_behave_like "one_to_many eager limit strategies"
379
- it_should_behave_like "many_to_many eager limit strategies"
380
- it_should_behave_like "one_through_one eager limit strategies"
381
- it_should_behave_like "many_through_many eager limit strategies"
382
- it_should_behave_like "one_through_many eager limit strategies"
376
+ EagerLimitStrategies = shared_description do
377
+ include OneToOneEagerLimitStrategies
378
+ include OneToManyEagerLimitStrategies
379
+ include ManyToManyEagerLimitStrategies
380
+ include OneThroughOneEagerLimitStrategies
381
+ include ManyThroughManyEagerLimitStrategies
382
+ include OneThroughManyEagerLimitStrategies
383
383
  end
384
384
 
385
- shared_examples_for "eager_graph limit strategies" do
386
- it_should_behave_like "one_to_one eager_graph limit strategies"
387
- it_should_behave_like "one_to_many eager_graph limit strategies"
388
- it_should_behave_like "many_to_many eager_graph limit strategies"
389
- it_should_behave_like "one_through_one eager_graph limit strategies"
390
- it_should_behave_like "many_through_many eager_graph limit strategies"
391
- it_should_behave_like "one_through_many eager_graph limit strategies"
385
+ EagerGraphLimitStrategies = shared_description do
386
+ include OneToOneEagerGraphLimitStrategies
387
+ include OneToManyEagerGraphLimitStrategies
388
+ include ManyToManyEagerGraphLimitStrategies
389
+ include OneThroughOneEagerGraphLimitStrategies
390
+ include ManyThroughManyEagerGraphLimitStrategies
391
+ include OneThroughManyEagerGraphLimitStrategies
392
392
  end
393
393
 
394
- shared_examples_for "filtering/excluding by associations" do
395
- specify "should handle association inner joins" do
396
- @Artist.association_join(:albums).all.should == []
397
- @Artist.association_join(:first_album).all.should == []
398
- @Album.association_join(:artist).all.should == []
399
- @Album.association_join(:tags).all.should == []
400
- @Album.association_join(:alias_tags).all.should == []
401
- @Tag.association_join(:albums).all.should == []
394
+ FilterByAssociations = shared_description do
395
+ it "should handle association inner joins" do
396
+ @Artist.association_join(:albums).all.must_equal []
397
+ @Artist.association_join(:first_album).all.must_equal []
398
+ @Album.association_join(:artist).all.must_equal []
399
+ @Album.association_join(:tags).all.must_equal []
400
+ @Album.association_join(:alias_tags).all.must_equal []
401
+ @Tag.association_join(:albums).all.must_equal []
402
402
  unless @no_many_through_many
403
- @Artist.association_join(:tags).all.should == []
404
- @Artist.association_join(:first_tag).all.should == []
403
+ @Artist.association_join(:tags).all.must_equal []
404
+ @Artist.association_join(:first_tag).all.must_equal []
405
405
  end
406
406
 
407
407
  @album.update(:artist => @artist)
408
408
  @album.add_tag(@tag)
409
409
 
410
- @Artist.association_join(:albums).select_all(:artists).all.should == [@artist]
411
- @Artist.association_join(:first_album).select_all(:artists).all.should == [@artist]
412
- @Album.association_join(:artist).select_all(:albums).all.should == [@album]
413
- @Album.association_join(:tags).select_all(:albums).all.should == [@album]
414
- @Album.association_join(:alias_tags).select_all(:albums).all.should == [@album]
415
- @Tag.association_join(:albums).select_all(:tags).all.should == [@tag]
410
+ @Artist.association_join(:albums).select_all(:artists).all.must_equal [@artist]
411
+ @Artist.association_join(:first_album).select_all(:artists).all.must_equal [@artist]
412
+ @Album.association_join(:artist).select_all(:albums).all.must_equal [@album]
413
+ @Album.association_join(:tags).select_all(:albums).all.must_equal [@album]
414
+ @Album.association_join(:alias_tags).select_all(:albums).all.must_equal [@album]
415
+ @Tag.association_join(:albums).select_all(:tags).all.must_equal [@tag]
416
416
  unless @no_many_through_many
417
- @Artist.association_join(:tags).select_all(:artists).all.should == [@artist]
418
- @Artist.association_join(:first_tag).select_all(:artists).all.should == [@artist]
417
+ @Artist.association_join(:tags).select_all(:artists).all.must_equal [@artist]
418
+ @Artist.association_join(:first_tag).select_all(:artists).all.must_equal [@artist]
419
419
  end
420
420
 
421
- @Artist.association_join(:albums).select_all(:albums).naked.all.should == [@album.values]
422
- @Artist.association_join(:first_album).select_all(:first_album).naked.all.should == [@album.values]
423
- @Album.association_join(:artist).select_all(:artist).naked.all.should == [@artist.values]
424
- @Album.association_join(:tags).select_all(:tags).naked.all.should == [@tag.values]
425
- @Album.association_join(:alias_tags).select_all(:alias_tags).naked.all.should == [@tag.values]
426
- @Tag.association_join(:albums).select_all(:albums).naked.all.should == [@album.values]
421
+ @Artist.association_join(:albums).select_all(:albums).naked.all.must_equal [@album.values]
422
+ @Artist.association_join(:first_album).select_all(:first_album).naked.all.must_equal [@album.values]
423
+ @Album.association_join(:artist).select_all(:artist).naked.all.must_equal [@artist.values]
424
+ @Album.association_join(:tags).select_all(:tags).naked.all.must_equal [@tag.values]
425
+ @Album.association_join(:alias_tags).select_all(:alias_tags).naked.all.must_equal [@tag.values]
426
+ @Tag.association_join(:albums).select_all(:albums).naked.all.must_equal [@album.values]
427
427
  unless @no_many_through_many
428
- @Artist.association_join(:tags).select_all(:tags).naked.all.should == [@tag.values]
429
- @Artist.association_join(:first_tag).select_all(:first_tag).naked.all.should == [@tag.values]
428
+ @Artist.association_join(:tags).select_all(:tags).naked.all.must_equal [@tag.values]
429
+ @Artist.association_join(:first_tag).select_all(:first_tag).naked.all.must_equal [@tag.values]
430
430
  end
431
431
  end
432
432
 
433
- specify "should handle association left joins" do
434
- @Artist.association_left_join(:albums).select_all(:artists).all.should == [@artist]
435
- @Artist.association_left_join(:first_album).select_all(:artists).all.should == [@artist]
436
- @Album.association_left_join(:artist).select_all(:albums).all.should == [@album]
437
- @Album.association_left_join(:tags).select_all(:albums).all.should == [@album]
438
- @Album.association_left_join(:alias_tags).select_all(:albums).all.should == [@album]
439
- @Tag.association_left_join(:albums).select_all(:tags).all.should == [@tag]
433
+ it "should handle association left joins" do
434
+ @Artist.association_left_join(:albums).select_all(:artists).all.must_equal [@artist]
435
+ @Artist.association_left_join(:first_album).select_all(:artists).all.must_equal [@artist]
436
+ @Album.association_left_join(:artist).select_all(:albums).all.must_equal [@album]
437
+ @Album.association_left_join(:tags).select_all(:albums).all.must_equal [@album]
438
+ @Album.association_left_join(:alias_tags).select_all(:albums).all.must_equal [@album]
439
+ @Tag.association_left_join(:albums).select_all(:tags).all.must_equal [@tag]
440
440
  unless @no_many_through_many
441
- @Artist.association_left_join(:tags).select_all(:artists).all.should == [@artist]
442
- @Artist.association_left_join(:first_tag).select_all(:artists).all.should == [@artist]
441
+ @Artist.association_left_join(:tags).select_all(:artists).all.must_equal [@artist]
442
+ @Artist.association_left_join(:first_tag).select_all(:artists).all.must_equal [@artist]
443
443
  end
444
444
 
445
445
  nil_hash = lambda{|obj| [obj.values.keys.inject({}){|h,k| h[k] = nil; h}]}
446
- @Artist.association_left_join(:albums).select_all(:albums).naked.all.should == nil_hash[@album]
447
- @Artist.association_left_join(:first_album).select_all(:first_album).naked.all.should == nil_hash[@album]
448
- @Album.association_left_join(:artist).select_all(:artist).naked.all.should == nil_hash[@artist]
449
- @Album.association_left_join(:tags).select_all(:tags).naked.all.should == nil_hash[@tag]
450
- @Album.association_left_join(:alias_tags).select_all(:alias_tags).naked.all.should == nil_hash[@tag]
451
- @Tag.association_left_join(:albums).select_all(:albums).naked.all.should == nil_hash[@album]
446
+ @Artist.association_left_join(:albums).select_all(:albums).naked.all.must_equal nil_hash[@album]
447
+ @Artist.association_left_join(:first_album).select_all(:first_album).naked.all.must_equal nil_hash[@album]
448
+ @Album.association_left_join(:artist).select_all(:artist).naked.all.must_equal nil_hash[@artist]
449
+ @Album.association_left_join(:tags).select_all(:tags).naked.all.must_equal nil_hash[@tag]
450
+ @Album.association_left_join(:alias_tags).select_all(:alias_tags).naked.all.must_equal nil_hash[@tag]
451
+ @Tag.association_left_join(:albums).select_all(:albums).naked.all.must_equal nil_hash[@album]
452
452
  unless @no_many_through_many
453
- @Artist.association_left_join(:tags).select_all(:tags).naked.all.should == nil_hash[@tag]
454
- @Artist.association_left_join(:first_tag).select_all(:first_tag).naked.all.should == nil_hash[@tag]
453
+ @Artist.association_left_join(:tags).select_all(:tags).naked.all.must_equal nil_hash[@tag]
454
+ @Artist.association_left_join(:first_tag).select_all(:first_tag).naked.all.must_equal nil_hash[@tag]
455
455
  end
456
456
 
457
457
  @album.update(:artist => @artist)
458
458
  @album.add_tag(@tag)
459
459
 
460
460
 
461
- @Artist.association_left_join(:albums).select_all(:albums).naked.all.should == [@album.values]
462
- @Artist.association_left_join(:first_album).select_all(:first_album).naked.all.should == [@album.values]
463
- @Album.association_left_join(:artist).select_all(:artist).naked.all.should == [@artist.values]
464
- @Album.association_left_join(:tags).select_all(:tags).naked.all.should == [@tag.values]
465
- @Album.association_left_join(:alias_tags).select_all(:alias_tags).naked.all.should == [@tag.values]
466
- @Tag.association_left_join(:albums).select_all(:albums).naked.all.should == [@album.values]
461
+ @Artist.association_left_join(:albums).select_all(:albums).naked.all.must_equal [@album.values]
462
+ @Artist.association_left_join(:first_album).select_all(:first_album).naked.all.must_equal [@album.values]
463
+ @Album.association_left_join(:artist).select_all(:artist).naked.all.must_equal [@artist.values]
464
+ @Album.association_left_join(:tags).select_all(:tags).naked.all.must_equal [@tag.values]
465
+ @Album.association_left_join(:alias_tags).select_all(:alias_tags).naked.all.must_equal [@tag.values]
466
+ @Tag.association_left_join(:albums).select_all(:albums).naked.all.must_equal [@album.values]
467
467
  unless @no_many_through_many
468
- @Artist.association_left_join(:tags).select_all(:tags).naked.all.should == [@tag.values]
469
- @Artist.association_left_join(:first_tag).select_all(:first_tag).naked.all.should == [@tag.values]
468
+ @Artist.association_left_join(:tags).select_all(:tags).naked.all.must_equal [@tag.values]
469
+ @Artist.association_left_join(:first_tag).select_all(:first_tag).naked.all.must_equal [@tag.values]
470
470
  end
471
471
  end
472
472
 
473
- specify "should work correctly when filtering by associations" do
473
+ it "should work correctly when filtering by associations" do
474
474
  @album.update(:artist => @artist)
475
475
  @album.add_tag(@tag)
476
476
 
477
- @Artist.filter(:albums=>@album).all.should == [@artist]
478
- @Artist.filter(:first_album=>@album).all.should == [@artist]
477
+ @Artist.filter(:albums=>@album).all.must_equal [@artist]
478
+ @Artist.filter(:first_album=>@album).all.must_equal [@artist]
479
479
  unless @no_many_through_many
480
- @Artist.filter(:tags=>@tag).all.should == [@artist]
481
- @Artist.filter(:first_tag=>@tag).all.should == [@artist]
480
+ @Artist.filter(:tags=>@tag).all.must_equal [@artist]
481
+ @Artist.filter(:first_tag=>@tag).all.must_equal [@artist]
482
482
  end
483
- @Album.filter(:artist=>@artist).all.should == [@album]
484
- @Album.filter(:tags=>@tag).all.should == [@album]
485
- @Album.filter(:alias_tags=>@tag).all.should == [@album]
486
- @Tag.filter(:albums=>@album).all.should == [@tag]
487
- @Album.filter(:artist=>@artist, :tags=>@tag).all.should == [@album]
488
- @artist.albums_dataset.filter(:tags=>@tag).all.should == [@album]
483
+ @Album.filter(:artist=>@artist).all.must_equal [@album]
484
+ @Album.filter(:tags=>@tag).all.must_equal [@album]
485
+ @Album.filter(:alias_tags=>@tag).all.must_equal [@album]
486
+ @Tag.filter(:albums=>@album).all.must_equal [@tag]
487
+ @Album.filter(:artist=>@artist, :tags=>@tag).all.must_equal [@album]
488
+ @artist.albums_dataset.filter(:tags=>@tag).all.must_equal [@album]
489
489
  end
490
490
 
491
- specify "should work correctly when excluding by associations" do
491
+ it "should work correctly when excluding by associations" do
492
492
  @album.update(:artist => @artist)
493
493
  @album.add_tag(@tag)
494
494
  album, artist, tag = @pr.call
495
495
 
496
- @Artist.exclude(:albums=>@album).all.should == [artist]
497
- @Artist.exclude(:first_album=>@album).all.should == [artist]
496
+ @Artist.exclude(:albums=>@album).all.must_equal [artist]
497
+ @Artist.exclude(:first_album=>@album).all.must_equal [artist]
498
498
  unless @no_many_through_many
499
- @Artist.exclude(:tags=>@tag).all.should == [artist]
500
- @Artist.exclude(:first_tag=>@tag).all.should == [artist]
499
+ @Artist.exclude(:tags=>@tag).all.must_equal [artist]
500
+ @Artist.exclude(:first_tag=>@tag).all.must_equal [artist]
501
501
  end
502
- @Album.exclude(:artist=>@artist).all.should == [album]
503
- @Album.exclude(:tags=>@tag).all.should == [album]
504
- @Album.exclude(:alias_tags=>@tag).all.should == [album]
505
- @Tag.exclude(:albums=>@album).all.should == [tag]
506
- @Album.exclude(:artist=>@artist, :tags=>@tag).all.should == [album]
502
+ @Album.exclude(:artist=>@artist).all.must_equal [album]
503
+ @Album.exclude(:tags=>@tag).all.must_equal [album]
504
+ @Album.exclude(:alias_tags=>@tag).all.must_equal [album]
505
+ @Tag.exclude(:albums=>@album).all.must_equal [tag]
506
+ @Album.exclude(:artist=>@artist, :tags=>@tag).all.must_equal [album]
507
507
  end
508
508
 
509
- specify "should work correctly when filtering by associations with conditions" do
509
+ it "should work correctly when filtering by associations with conditions" do
510
510
  @album.update(:artist => @artist)
511
511
  @album.add_tag(@tag)
512
512
 
513
- @Artist.filter(:a_albums=>@album).all.should == [@artist]
514
- @Artist.filter(:first_a_album=>@album).all.should == [@artist]
513
+ @Artist.filter(:a_albums=>@album).all.must_equal [@artist]
514
+ @Artist.filter(:first_a_album=>@album).all.must_equal [@artist]
515
515
  @album.update(:name=>'Foo')
516
- @Artist.filter(:a_albums=>@album).all.should == []
517
- @Artist.filter(:first_a_album=>@album).all.should == []
516
+ @Artist.filter(:a_albums=>@album).all.must_equal []
517
+ @Artist.filter(:first_a_album=>@album).all.must_equal []
518
518
 
519
- @Album.filter(:a_artist=>@artist).all.should == [@album]
519
+ @Album.filter(:a_artist=>@artist).all.must_equal [@album]
520
520
  @artist.update(:name=>'Foo')
521
- @Album.filter(:a_artist=>@artist).all.should == []
521
+ @Album.filter(:a_artist=>@artist).all.must_equal []
522
522
 
523
- @Album.filter(:t_tags=>@tag).all.should == [@album]
524
- @Album.filter(:alias_t_tags=>@tag).all.should == [@album]
523
+ @Album.filter(:t_tags=>@tag).all.must_equal [@album]
524
+ @Album.filter(:alias_t_tags=>@tag).all.must_equal [@album]
525
525
  unless @no_many_through_many
526
- @Album.filter(:t_tag=>@tag).all.should == [@album]
527
- @Album.filter(:alias_t_tag=>@tag).all.should == [@album]
528
- @Artist.filter(:t_tags=>@tag).all.should == [@artist]
529
- @Artist.filter(:t_tag=>@tag).all.should == [@artist]
526
+ @Album.filter(:t_tag=>@tag).all.must_equal [@album]
527
+ @Album.filter(:alias_t_tag=>@tag).all.must_equal [@album]
528
+ @Artist.filter(:t_tags=>@tag).all.must_equal [@artist]
529
+ @Artist.filter(:t_tag=>@tag).all.must_equal [@artist]
530
530
  end
531
531
  @tag.update(:name=>'Foo')
532
- @Album.filter(:t_tags=>@tag).all.should == []
533
- @Album.filter(:alias_t_tags=>@tag).all.should == []
532
+ @Album.filter(:t_tags=>@tag).all.must_equal []
533
+ @Album.filter(:alias_t_tags=>@tag).all.must_equal []
534
534
  unless @no_many_through_many
535
- @Album.filter(:t_tag=>@tag).all.should == []
536
- @Album.filter(:alias_t_tag=>@tag).all.should == []
537
- @Artist.filter(:t_tags=>@tag).all.should == []
538
- @Artist.filter(:t_tag=>@tag).all.should == []
535
+ @Album.filter(:t_tag=>@tag).all.must_equal []
536
+ @Album.filter(:alias_t_tag=>@tag).all.must_equal []
537
+ @Artist.filter(:t_tags=>@tag).all.must_equal []
538
+ @Artist.filter(:t_tag=>@tag).all.must_equal []
539
539
  end
540
540
  end
541
541
 
542
- specify "should work correctly when excluding by associations with conditions" do
542
+ it "should work correctly when excluding by associations with conditions" do
543
543
  @album.update(:artist => @artist)
544
544
  @album.add_tag(@tag)
545
545
 
546
- @Artist.exclude(:a_albums=>@album).all.should == []
547
- @Artist.exclude(:first_a_album=>@album).all.should == []
546
+ @Artist.exclude(:a_albums=>@album).all.must_equal []
547
+ @Artist.exclude(:first_a_album=>@album).all.must_equal []
548
548
  @album.update(:name=>'Foo')
549
- @Artist.exclude(:a_albums=>@album).all.should == [@artist]
550
- @Artist.exclude(:first_a_album=>@album).all.should == [@artist]
549
+ @Artist.exclude(:a_albums=>@album).all.must_equal [@artist]
550
+ @Artist.exclude(:first_a_album=>@album).all.must_equal [@artist]
551
551
 
552
- @Album.exclude(:a_artist=>@artist).all.should == []
552
+ @Album.exclude(:a_artist=>@artist).all.must_equal []
553
553
  @artist.update(:name=>'Foo')
554
- @Album.exclude(:a_artist=>@artist).all.should == [@album]
554
+ @Album.exclude(:a_artist=>@artist).all.must_equal [@album]
555
555
 
556
- @Album.exclude(:t_tags=>@tag).all.should == []
557
- @Album.exclude(:alias_t_tags=>@tag).all.should == []
556
+ @Album.exclude(:t_tags=>@tag).all.must_equal []
557
+ @Album.exclude(:alias_t_tags=>@tag).all.must_equal []
558
558
  unless @no_many_through_many
559
- @Album.exclude(:t_tag=>@tag).all.should == []
560
- @Album.exclude(:alias_t_tag=>@tag).all.should == []
561
- @Artist.exclude(:t_tags=>@tag).all.should == []
562
- @Artist.exclude(:t_tag=>@tag).all.should == []
559
+ @Album.exclude(:t_tag=>@tag).all.must_equal []
560
+ @Album.exclude(:alias_t_tag=>@tag).all.must_equal []
561
+ @Artist.exclude(:t_tags=>@tag).all.must_equal []
562
+ @Artist.exclude(:t_tag=>@tag).all.must_equal []
563
563
  end
564
564
  @tag.update(:name=>'Foo')
565
- @Album.exclude(:t_tags=>@tag).all.should == [@album]
566
- @Album.exclude(:alias_t_tags=>@tag).all.should == [@album]
565
+ @Album.exclude(:t_tags=>@tag).all.must_equal [@album]
566
+ @Album.exclude(:alias_t_tags=>@tag).all.must_equal [@album]
567
567
  unless @no_many_through_many
568
- @Album.exclude(:t_tag=>@tag).all.should == [@album]
569
- @Album.exclude(:alias_t_tag=>@tag).all.should == [@album]
570
- @Artist.exclude(:t_tags=>@tag).all.should == [@artist]
571
- @Artist.exclude(:t_tag=>@tag).all.should == [@artist]
568
+ @Album.exclude(:t_tag=>@tag).all.must_equal [@album]
569
+ @Album.exclude(:alias_t_tag=>@tag).all.must_equal [@album]
570
+ @Artist.exclude(:t_tags=>@tag).all.must_equal [@artist]
571
+ @Artist.exclude(:t_tag=>@tag).all.must_equal [@artist]
572
572
  end
573
573
  end
574
574
 
575
- specify "should work correctly when filtering by multiple associations" do
575
+ it "should work correctly when filtering by multiple associations" do
576
576
  album, artist, tag = @pr.call
577
577
  @album.update(:artist => @artist)
578
578
  @album.add_tag(@tag)
579
579
 
580
- @Artist.filter(:albums=>[@album, album]).all.should == [@artist]
581
- @Artist.filter(:first_album=>[@album, album]).all.should == [@artist]
582
- @Album.filter(:artist=>[@artist, artist]).all.should == [@album]
583
- @Album.filter(:tags=>[@tag, tag]).all.should == [@album]
584
- @Album.filter(:alias_tags=>[@tag, tag]).all.should == [@album]
585
- @Tag.filter(:albums=>[@album, album]).all.should == [@tag]
586
- @Album.filter(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.should == [@album]
587
- @artist.albums_dataset.filter(:tags=>[@tag, tag]).all.should == [@album]
580
+ @Artist.filter(:albums=>[@album, album]).all.must_equal [@artist]
581
+ @Artist.filter(:first_album=>[@album, album]).all.must_equal [@artist]
582
+ @Album.filter(:artist=>[@artist, artist]).all.must_equal [@album]
583
+ @Album.filter(:tags=>[@tag, tag]).all.must_equal [@album]
584
+ @Album.filter(:alias_tags=>[@tag, tag]).all.must_equal [@album]
585
+ @Tag.filter(:albums=>[@album, album]).all.must_equal [@tag]
586
+ @Album.filter(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.must_equal [@album]
587
+ @artist.albums_dataset.filter(:tags=>[@tag, tag]).all.must_equal [@album]
588
588
  unless @no_many_through_many
589
- @Artist.filter(:tags=>[@tag, tag]).all.should == [@artist]
590
- @Artist.filter(:first_tag=>[@tag, tag]).all.should == [@artist]
589
+ @Artist.filter(:tags=>[@tag, tag]).all.must_equal [@artist]
590
+ @Artist.filter(:first_tag=>[@tag, tag]).all.must_equal [@artist]
591
591
  end
592
592
 
593
593
  album.add_tag(tag)
594
594
 
595
- @Artist.filter(:albums=>[@album, album]).all.should == [@artist]
596
- @Artist.filter(:first_album=>[@album, album]).all.should == [@artist]
597
- @Album.filter(:artist=>[@artist, artist]).all.should == [@album]
598
- @Album.filter(:tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@album, album]
599
- @Album.filter(:alias_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@album, album]
600
- @Tag.filter(:albums=>[@album, album]).all.sort_by{|x| x.pk}.should == [@tag, tag]
601
- @Album.filter(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.should == [@album]
595
+ @Artist.filter(:albums=>[@album, album]).all.must_equal [@artist]
596
+ @Artist.filter(:first_album=>[@album, album]).all.must_equal [@artist]
597
+ @Album.filter(:artist=>[@artist, artist]).all.must_equal [@album]
598
+ @Album.filter(:tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@album, album]
599
+ @Album.filter(:alias_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@album, album]
600
+ @Tag.filter(:albums=>[@album, album]).all.sort_by{|x| x.pk}.must_equal [@tag, tag]
601
+ @Album.filter(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.must_equal [@album]
602
602
  unless @no_many_through_many
603
- @Artist.filter(:tags=>[@tag, tag]).all.should == [@artist]
604
- @Artist.filter(:first_tag=>[@tag, tag]).all.should == [@artist]
603
+ @Artist.filter(:tags=>[@tag, tag]).all.must_equal [@artist]
604
+ @Artist.filter(:first_tag=>[@tag, tag]).all.must_equal [@artist]
605
605
  end
606
606
 
607
607
  album.update(:artist => artist)
608
608
 
609
- @Artist.filter(:albums=>[@album, album]).all.sort_by{|x| x.pk}.should == [@artist, artist]
610
- @Artist.filter(:first_album=>[@album, album]).all.sort_by{|x| x.pk}.should == [@artist, artist]
611
- @Album.filter(:artist=>[@artist, artist]).all.sort_by{|x| x.pk}.should == [@album, album]
612
- @Album.filter(:tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@album, album]
613
- @Album.filter(:alias_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@album, album]
614
- @Tag.filter(:albums=>[@album, album]).all.sort_by{|x| x.pk}.should == [@tag, tag]
615
- @Album.filter(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@album, album]
609
+ @Artist.filter(:albums=>[@album, album]).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
610
+ @Artist.filter(:first_album=>[@album, album]).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
611
+ @Album.filter(:artist=>[@artist, artist]).all.sort_by{|x| x.pk}.must_equal [@album, album]
612
+ @Album.filter(:tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@album, album]
613
+ @Album.filter(:alias_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@album, album]
614
+ @Tag.filter(:albums=>[@album, album]).all.sort_by{|x| x.pk}.must_equal [@tag, tag]
615
+ @Album.filter(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@album, album]
616
616
  unless @no_many_through_many
617
- @Artist.filter(:tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@artist, artist]
618
- @Artist.filter(:first_tag=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@artist, artist]
617
+ @Artist.filter(:tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
618
+ @Artist.filter(:first_tag=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
619
619
  end
620
620
  end
621
621
 
622
- specify "should work correctly when excluding by multiple associations" do
622
+ it "should work correctly when excluding by multiple associations" do
623
623
  album, artist, tag = @pr.call
624
624
 
625
- @Artist.exclude(:albums=>[@album, album]).all.sort_by{|x| x.pk}.should == [@artist, artist]
626
- @Artist.exclude(:first_album=>[@album, album]).all.sort_by{|x| x.pk}.should == [@artist, artist]
627
- @Album.exclude(:artist=>[@artist, artist]).all.sort_by{|x| x.pk}.should == [@album, album]
628
- @Album.exclude(:tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@album, album]
629
- @Album.exclude(:alias_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@album, album]
630
- @Tag.exclude(:albums=>[@album, album]).all.sort_by{|x| x.pk}.should == [@tag, tag]
631
- @Album.exclude(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@album, album]
625
+ @Artist.exclude(:albums=>[@album, album]).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
626
+ @Artist.exclude(:first_album=>[@album, album]).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
627
+ @Album.exclude(:artist=>[@artist, artist]).all.sort_by{|x| x.pk}.must_equal [@album, album]
628
+ @Album.exclude(:tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@album, album]
629
+ @Album.exclude(:alias_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@album, album]
630
+ @Tag.exclude(:albums=>[@album, album]).all.sort_by{|x| x.pk}.must_equal [@tag, tag]
631
+ @Album.exclude(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@album, album]
632
632
  unless @no_many_through_many
633
- @Artist.exclude(:tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@artist, artist]
634
- @Artist.exclude(:first_tag=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@artist, artist]
633
+ @Artist.exclude(:tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
634
+ @Artist.exclude(:first_tag=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
635
635
  end
636
636
 
637
637
  @album.update(:artist => @artist)
638
638
  @album.add_tag(@tag)
639
639
 
640
- @Artist.exclude(:albums=>[@album, album]).all.sort_by{|x| x.pk}.should == [artist]
641
- @Artist.exclude(:first_album=>[@album, album]).all.sort_by{|x| x.pk}.should == [artist]
642
- @Album.exclude(:artist=>[@artist, artist]).all.sort_by{|x| x.pk}.should == [album]
643
- @Album.exclude(:tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [album]
644
- @Album.exclude(:alias_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [album]
645
- @Tag.exclude(:albums=>[@album, album]).all.sort_by{|x| x.pk}.should == [tag]
646
- @Album.exclude(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [album]
640
+ @Artist.exclude(:albums=>[@album, album]).all.sort_by{|x| x.pk}.must_equal [artist]
641
+ @Artist.exclude(:first_album=>[@album, album]).all.sort_by{|x| x.pk}.must_equal [artist]
642
+ @Album.exclude(:artist=>[@artist, artist]).all.sort_by{|x| x.pk}.must_equal [album]
643
+ @Album.exclude(:tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [album]
644
+ @Album.exclude(:alias_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [album]
645
+ @Tag.exclude(:albums=>[@album, album]).all.sort_by{|x| x.pk}.must_equal [tag]
646
+ @Album.exclude(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [album]
647
647
  unless @no_many_through_many
648
- @Artist.exclude(:tags=>[@tag, tag]).all.should == [artist]
649
- @Artist.exclude(:first_tag=>[@tag, tag]).all.should == [artist]
648
+ @Artist.exclude(:tags=>[@tag, tag]).all.must_equal [artist]
649
+ @Artist.exclude(:first_tag=>[@tag, tag]).all.must_equal [artist]
650
650
  end
651
651
 
652
652
  album.add_tag(tag)
653
653
 
654
- @Artist.exclude(:albums=>[@album, album]).all.should == [artist]
655
- @Artist.exclude(:first_album=>[@album, album]).all.should == [artist]
656
- @Album.exclude(:artist=>[@artist, artist]).all.should == [album]
657
- @Album.exclude(:tags=>[@tag, tag]).all.should == []
658
- @Album.exclude(:alias_tags=>[@tag, tag]).all.should == []
659
- @Tag.exclude(:albums=>[@album, album]).all.should == []
660
- @Album.exclude(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.should == [album]
654
+ @Artist.exclude(:albums=>[@album, album]).all.must_equal [artist]
655
+ @Artist.exclude(:first_album=>[@album, album]).all.must_equal [artist]
656
+ @Album.exclude(:artist=>[@artist, artist]).all.must_equal [album]
657
+ @Album.exclude(:tags=>[@tag, tag]).all.must_equal []
658
+ @Album.exclude(:alias_tags=>[@tag, tag]).all.must_equal []
659
+ @Tag.exclude(:albums=>[@album, album]).all.must_equal []
660
+ @Album.exclude(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.must_equal [album]
661
661
  unless @no_many_through_many
662
- @Artist.exclude(:tags=>[@tag, tag]).all.should == [artist]
663
- @Artist.exclude(:first_tag=>[@tag, tag]).all.should == [artist]
662
+ @Artist.exclude(:tags=>[@tag, tag]).all.must_equal [artist]
663
+ @Artist.exclude(:first_tag=>[@tag, tag]).all.must_equal [artist]
664
664
  end
665
665
 
666
666
  album.update(:artist => artist)
667
667
 
668
- @Artist.exclude(:albums=>[@album, album]).all.should == []
669
- @Artist.exclude(:first_album=>[@album, album]).all.should == []
670
- @Album.exclude(:artist=>[@artist, artist]).all.should == []
671
- @Album.exclude(:tags=>[@tag, tag]).all.should == []
672
- @Album.exclude(:alias_tags=>[@tag, tag]).all.should == []
673
- @Tag.exclude(:albums=>[@album, album]).all.should == []
674
- @Album.exclude(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.should == []
668
+ @Artist.exclude(:albums=>[@album, album]).all.must_equal []
669
+ @Artist.exclude(:first_album=>[@album, album]).all.must_equal []
670
+ @Album.exclude(:artist=>[@artist, artist]).all.must_equal []
671
+ @Album.exclude(:tags=>[@tag, tag]).all.must_equal []
672
+ @Album.exclude(:alias_tags=>[@tag, tag]).all.must_equal []
673
+ @Tag.exclude(:albums=>[@album, album]).all.must_equal []
674
+ @Album.exclude(:artist=>[@artist, artist], :tags=>[@tag, tag]).all.must_equal []
675
675
  unless @no_many_through_many
676
- @Artist.exclude(:tags=>[@tag, tag]).all.should == []
677
- @Artist.exclude(:first_tag=>[@tag, tag]).all.should == []
676
+ @Artist.exclude(:tags=>[@tag, tag]).all.must_equal []
677
+ @Artist.exclude(:first_tag=>[@tag, tag]).all.must_equal []
678
678
  end
679
679
  end
680
680
 
681
- specify "should work correctly when filtering associations with conditions with multiple objects" do
681
+ it "should work correctly when filtering associations with conditions with multiple objects" do
682
682
  album, artist, tag = @pr.call
683
683
  album.update(:name=>@album.name)
684
684
  artist.update(:name=>@artist.name)
@@ -689,52 +689,52 @@ shared_examples_for "filtering/excluding by associations" do
689
689
  album.update(:artist => @artist)
690
690
  tag.add_album(@album)
691
691
 
692
- @Artist.filter(:a_albums=>[@album, album]).all.should == [@artist]
693
- @Artist.filter(:first_a_album=>[@album, album]).all.should == [@artist]
692
+ @Artist.filter(:a_albums=>[@album, album]).all.must_equal [@artist]
693
+ @Artist.filter(:first_a_album=>[@album, album]).all.must_equal [@artist]
694
694
  @album.update(:name=>'Foo')
695
- @Artist.filter(:a_albums=>[@album, album]).all.should == [@artist]
696
- @Artist.filter(:first_a_album=>[@album, album]).all.should == [@artist]
695
+ @Artist.filter(:a_albums=>[@album, album]).all.must_equal [@artist]
696
+ @Artist.filter(:first_a_album=>[@album, album]).all.must_equal [@artist]
697
697
  album.update(:name=>'Foo')
698
- @Artist.filter(:a_albums=>[@album, album]).all.should == []
699
- @Artist.filter(:first_a_album=>[@album, album]).all.should == []
698
+ @Artist.filter(:a_albums=>[@album, album]).all.must_equal []
699
+ @Artist.filter(:first_a_album=>[@album, album]).all.must_equal []
700
700
 
701
701
  album.update(:artist => nil)
702
702
  artist.add_album(@album)
703
- @Album.filter(:a_artist=>[@artist, artist]).all.should == [@album]
703
+ @Album.filter(:a_artist=>[@artist, artist]).all.must_equal [@album]
704
704
  @artist.update(:name=>'Foo')
705
- @Album.filter(:a_artist=>[@artist, artist]).all.should == [@album]
705
+ @Album.filter(:a_artist=>[@artist, artist]).all.must_equal [@album]
706
706
  artist.update(:name=>'Foo')
707
- @Album.filter(:a_artist=>[@artist, artist]).all.should == []
707
+ @Album.filter(:a_artist=>[@artist, artist]).all.must_equal []
708
708
 
709
- @Album.filter(:t_tags=>[@tag, tag]).all.should == [@album]
710
- @Album.filter(:alias_t_tags=>[@tag, tag]).all.should == [@album]
709
+ @Album.filter(:t_tags=>[@tag, tag]).all.must_equal [@album]
710
+ @Album.filter(:alias_t_tags=>[@tag, tag]).all.must_equal [@album]
711
711
  unless @no_many_through_many
712
- @Album.filter(:t_tag=>[@tag, tag]).all.should == [@album]
713
- @Album.filter(:alias_t_tag=>[@tag, tag]).all.should == [@album]
714
- @Artist.filter(:t_tags=>[@tag, tag]).all.should == [artist]
715
- @Artist.filter(:t_tag=>[@tag, tag]).all.should == [artist]
712
+ @Album.filter(:t_tag=>[@tag, tag]).all.must_equal [@album]
713
+ @Album.filter(:alias_t_tag=>[@tag, tag]).all.must_equal [@album]
714
+ @Artist.filter(:t_tags=>[@tag, tag]).all.must_equal [artist]
715
+ @Artist.filter(:t_tag=>[@tag, tag]).all.must_equal [artist]
716
716
  end
717
717
  @tag.update(:name=>'Foo')
718
- @Album.filter(:t_tags=>[@tag, tag]).all.should == [@album]
719
- @Album.filter(:alias_t_tags=>[@tag, tag]).all.should == [@album]
718
+ @Album.filter(:t_tags=>[@tag, tag]).all.must_equal [@album]
719
+ @Album.filter(:alias_t_tags=>[@tag, tag]).all.must_equal [@album]
720
720
  unless @no_many_through_many
721
- @Album.filter(:t_tag=>[@tag, tag]).all.should == [@album]
722
- @Album.filter(:alias_t_tag=>[@tag, tag]).all.should == [@album]
723
- @Artist.filter(:t_tags=>[@tag, tag]).all.should == [artist]
724
- @Artist.filter(:t_tag=>[@tag, tag]).all.should == [artist]
721
+ @Album.filter(:t_tag=>[@tag, tag]).all.must_equal [@album]
722
+ @Album.filter(:alias_t_tag=>[@tag, tag]).all.must_equal [@album]
723
+ @Artist.filter(:t_tags=>[@tag, tag]).all.must_equal [artist]
724
+ @Artist.filter(:t_tag=>[@tag, tag]).all.must_equal [artist]
725
725
  end
726
726
  tag.update(:name=>'Foo')
727
- @Album.filter(:t_tags=>[@tag, tag]).all.should == []
728
- @Album.filter(:alias_t_tags=>[@tag, tag]).all.should == []
727
+ @Album.filter(:t_tags=>[@tag, tag]).all.must_equal []
728
+ @Album.filter(:alias_t_tags=>[@tag, tag]).all.must_equal []
729
729
  unless @no_many_through_many
730
- @Album.filter(:t_tag=>[@tag, tag]).all.should == []
731
- @Album.filter(:alias_t_tag=>[@tag, tag]).all.should == []
732
- @Artist.filter(:t_tags=>[@tag, tag]).all.should == []
733
- @Artist.filter(:t_tag=>[@tag, tag]).all.should == []
730
+ @Album.filter(:t_tag=>[@tag, tag]).all.must_equal []
731
+ @Album.filter(:alias_t_tag=>[@tag, tag]).all.must_equal []
732
+ @Artist.filter(:t_tags=>[@tag, tag]).all.must_equal []
733
+ @Artist.filter(:t_tag=>[@tag, tag]).all.must_equal []
734
734
  end
735
735
  end
736
736
 
737
- specify "should work correctly when excluding associations with conditions with multiple objects" do
737
+ it "should work correctly when excluding associations with conditions with multiple objects" do
738
738
  album, artist, tag = @pr.call
739
739
  album.update(:name=>@album.name)
740
740
  artist.update(:name=>@artist.name)
@@ -746,295 +746,295 @@ shared_examples_for "filtering/excluding by associations" do
746
746
  tag.add_album(@album)
747
747
 
748
748
  artist.add_album(@album)
749
- @Artist.exclude(:a_albums=>[@album, album]).all.should == []
750
- @Artist.exclude(:first_a_album=>[@album, album]).all.should == []
749
+ @Artist.exclude(:a_albums=>[@album, album]).all.must_equal []
750
+ @Artist.exclude(:first_a_album=>[@album, album]).all.must_equal []
751
751
  @album.update(:name=>'Foo')
752
- @Artist.exclude(:a_albums=>[@album, album]).all.should == [artist]
753
- @Artist.exclude(:first_a_album=>[@album, album]).all.should == [artist]
752
+ @Artist.exclude(:a_albums=>[@album, album]).all.must_equal [artist]
753
+ @Artist.exclude(:first_a_album=>[@album, album]).all.must_equal [artist]
754
754
  album.update(:name=>'Foo')
755
- @Artist.exclude(:a_albums=>[@album, album]).all.sort_by{|x| x.pk}.should == [@artist, artist]
756
- @Artist.exclude(:first_a_album=>[@album, album]).all.sort_by{|x| x.pk}.should == [@artist, artist]
755
+ @Artist.exclude(:a_albums=>[@album, album]).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
756
+ @Artist.exclude(:first_a_album=>[@album, album]).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
757
757
 
758
- @Album.exclude(:a_artist=>[@artist, artist]).all.should == []
758
+ @Album.exclude(:a_artist=>[@artist, artist]).all.must_equal []
759
759
  album.update(:artist => nil)
760
760
  @artist.update(:name=>'Foo')
761
- @Album.exclude(:a_artist=>[@artist, artist]).all.should == [album]
761
+ @Album.exclude(:a_artist=>[@artist, artist]).all.must_equal [album]
762
762
  artist.update(:name=>'Foo')
763
- @Album.exclude(:a_artist=>[@artist, artist]).all.sort_by{|x| x.pk}.should == [@album, album]
763
+ @Album.exclude(:a_artist=>[@artist, artist]).all.sort_by{|x| x.pk}.must_equal [@album, album]
764
764
 
765
765
  @tag.add_album(album)
766
- @Album.exclude(:t_tags=>[@tag, tag]).all.should == []
767
- @Album.exclude(:alias_t_tags=>[@tag, tag]).all.should == []
766
+ @Album.exclude(:t_tags=>[@tag, tag]).all.must_equal []
767
+ @Album.exclude(:alias_t_tags=>[@tag, tag]).all.must_equal []
768
768
  unless @no_many_through_many
769
- @Album.exclude(:t_tag=>[@tag, tag]).all.should == []
770
- @Album.exclude(:alias_t_tag=>[@tag, tag]).all.should == []
771
- @Artist.exclude(:t_tags=>[@tag, tag]).all.should == [@artist]
772
- @Artist.exclude(:t_tag=>[@tag, tag]).all.should == [@artist]
769
+ @Album.exclude(:t_tag=>[@tag, tag]).all.must_equal []
770
+ @Album.exclude(:alias_t_tag=>[@tag, tag]).all.must_equal []
771
+ @Artist.exclude(:t_tags=>[@tag, tag]).all.must_equal [@artist]
772
+ @Artist.exclude(:t_tag=>[@tag, tag]).all.must_equal [@artist]
773
773
  end
774
774
  @tag.update(:name=>'Foo')
775
- @Album.exclude(:t_tags=>[@tag, tag]).all.should == [album]
776
- @Album.exclude(:alias_t_tags=>[@tag, tag]).all.should == [album]
775
+ @Album.exclude(:t_tags=>[@tag, tag]).all.must_equal [album]
776
+ @Album.exclude(:alias_t_tags=>[@tag, tag]).all.must_equal [album]
777
777
  unless @no_many_through_many
778
- @Album.exclude(:t_tag=>[@tag, tag]).all.should == [album]
779
- @Album.exclude(:alias_t_tag=>[@tag, tag]).all.should == [album]
780
- @Artist.exclude(:t_tags=>[@tag, tag]).all.should == [@artist]
781
- @Artist.exclude(:t_tag=>[@tag, tag]).all.should == [@artist]
778
+ @Album.exclude(:t_tag=>[@tag, tag]).all.must_equal [album]
779
+ @Album.exclude(:alias_t_tag=>[@tag, tag]).all.must_equal [album]
780
+ @Artist.exclude(:t_tags=>[@tag, tag]).all.must_equal [@artist]
781
+ @Artist.exclude(:t_tag=>[@tag, tag]).all.must_equal [@artist]
782
782
  end
783
783
  tag.update(:name=>'Foo')
784
- @Album.exclude(:t_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@album, album]
785
- @Album.exclude(:alias_t_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@album, album]
784
+ @Album.exclude(:t_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@album, album]
785
+ @Album.exclude(:alias_t_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@album, album]
786
786
  unless @no_many_through_many
787
- @Album.exclude(:t_tag=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@album, album]
788
- @Album.exclude(:alias_t_tag=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@album, album]
789
- @Artist.exclude(:t_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@artist, artist]
790
- @Artist.exclude(:t_tag=>[@tag, tag]).all.sort_by{|x| x.pk}.should == [@artist, artist]
787
+ @Album.exclude(:t_tag=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@album, album]
788
+ @Album.exclude(:alias_t_tag=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@album, album]
789
+ @Artist.exclude(:t_tags=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
790
+ @Artist.exclude(:t_tag=>[@tag, tag]).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
791
791
  end
792
792
  end
793
793
 
794
- specify "should work correctly when excluding by associations in regards to NULL values" do
795
- @Artist.exclude(:albums=>@album).all.should == [@artist]
796
- @Artist.exclude(:first_album=>@album).all.should == [@artist]
797
- @Album.exclude(:artist=>@artist).all.should == [@album]
798
- @Album.exclude(:tags=>@tag).all.should == [@album]
799
- @Album.exclude(:alias_tags=>@tag).all.should == [@album]
800
- @Tag.exclude(:albums=>@album).all.should == [@tag]
801
- @Album.exclude(:artist=>@artist, :tags=>@tag).all.should == [@album]
802
-
803
- @Artist.exclude(:a_albums=>@album).all.should == [@artist]
804
- @Artist.exclude(:first_a_album=>@album).all.should == [@artist]
805
- @Album.exclude(:a_artist=>@artist).all.should == [@album]
806
- @Album.exclude(:t_tags=>@tag).all.should == [@album]
807
- @Album.exclude(:alias_t_tags=>@tag).all.should == [@album]
794
+ it "should work correctly when excluding by associations in regards to NULL values" do
795
+ @Artist.exclude(:albums=>@album).all.must_equal [@artist]
796
+ @Artist.exclude(:first_album=>@album).all.must_equal [@artist]
797
+ @Album.exclude(:artist=>@artist).all.must_equal [@album]
798
+ @Album.exclude(:tags=>@tag).all.must_equal [@album]
799
+ @Album.exclude(:alias_tags=>@tag).all.must_equal [@album]
800
+ @Tag.exclude(:albums=>@album).all.must_equal [@tag]
801
+ @Album.exclude(:artist=>@artist, :tags=>@tag).all.must_equal [@album]
802
+
803
+ @Artist.exclude(:a_albums=>@album).all.must_equal [@artist]
804
+ @Artist.exclude(:first_a_album=>@album).all.must_equal [@artist]
805
+ @Album.exclude(:a_artist=>@artist).all.must_equal [@album]
806
+ @Album.exclude(:t_tags=>@tag).all.must_equal [@album]
807
+ @Album.exclude(:alias_t_tags=>@tag).all.must_equal [@album]
808
808
  unless @no_many_through_many
809
- @Album.exclude(:t_tag=>@tag).all.should == [@album]
810
- @Album.exclude(:alias_t_tag=>@tag).all.should == [@album]
811
- @Artist.exclude(:t_tags=>@tag).all.should == [@artist]
812
- @Artist.exclude(:t_tag=>@tag).all.should == [@artist]
809
+ @Album.exclude(:t_tag=>@tag).all.must_equal [@album]
810
+ @Album.exclude(:alias_t_tag=>@tag).all.must_equal [@album]
811
+ @Artist.exclude(:t_tags=>@tag).all.must_equal [@artist]
812
+ @Artist.exclude(:t_tag=>@tag).all.must_equal [@artist]
813
813
  end
814
814
 
815
815
  @album.update(:artist => @artist)
816
- @artist.albums_dataset.exclude(:tags=>@tag).all.should == [@album]
816
+ @artist.albums_dataset.exclude(:tags=>@tag).all.must_equal [@album]
817
817
  end
818
818
 
819
- specify "should handle NULL values in join table correctly when filtering/excluding many_to_many associations" do
819
+ it "should handle NULL values in join table correctly when filtering/excluding many_to_many associations" do
820
820
  @ins.call
821
- @Album.exclude(:tags=>@tag).all.should == [@album]
822
- @Album.exclude(:alias_tags=>@tag).all.should == [@album]
823
- @Album.exclude(:t_tags=>@tag).all.should == [@album]
824
- @Album.exclude(:alias_t_tags=>@tag).all.should == [@album]
821
+ @Album.exclude(:tags=>@tag).all.must_equal [@album]
822
+ @Album.exclude(:alias_tags=>@tag).all.must_equal [@album]
823
+ @Album.exclude(:t_tags=>@tag).all.must_equal [@album]
824
+ @Album.exclude(:alias_t_tags=>@tag).all.must_equal [@album]
825
825
  @album.add_tag(@tag)
826
- @Album.filter(:tags=>@tag).all.should == [@album]
827
- @Album.filter(:alias_tags=>@tag).all.should == [@album]
828
- @Album.filter(:t_tags=>@tag).all.should == [@album]
829
- @Album.filter(:alias_t_tags=>@tag).all.should == [@album]
826
+ @Album.filter(:tags=>@tag).all.must_equal [@album]
827
+ @Album.filter(:alias_tags=>@tag).all.must_equal [@album]
828
+ @Album.filter(:t_tags=>@tag).all.must_equal [@album]
829
+ @Album.filter(:alias_t_tags=>@tag).all.must_equal [@album]
830
830
  album, tag = @pr.call.values_at(0, 2)
831
- @Album.exclude(:tags=>@tag).all.should == [album]
832
- @Album.exclude(:alias_tags=>@tag).all.should == [album]
833
- @Album.exclude(:t_tags=>@tag).all.should == [album]
834
- @Album.exclude(:alias_t_tags=>@tag).all.should == [album]
835
- @Album.exclude(:tags=>tag).all.sort_by{|x| x.pk}.should == [@album, album]
836
- @Album.exclude(:alias_tags=>tag).all.sort_by{|x| x.pk}.should == [@album, album]
837
- @Album.exclude(:t_tags=>tag).all.sort_by{|x| x.pk}.should == [@album, album]
838
- @Album.exclude(:alias_t_tags=>tag).all.sort_by{|x| x.pk}.should == [@album, album]
831
+ @Album.exclude(:tags=>@tag).all.must_equal [album]
832
+ @Album.exclude(:alias_tags=>@tag).all.must_equal [album]
833
+ @Album.exclude(:t_tags=>@tag).all.must_equal [album]
834
+ @Album.exclude(:alias_t_tags=>@tag).all.must_equal [album]
835
+ @Album.exclude(:tags=>tag).all.sort_by{|x| x.pk}.must_equal [@album, album]
836
+ @Album.exclude(:alias_tags=>tag).all.sort_by{|x| x.pk}.must_equal [@album, album]
837
+ @Album.exclude(:t_tags=>tag).all.sort_by{|x| x.pk}.must_equal [@album, album]
838
+ @Album.exclude(:alias_t_tags=>tag).all.sort_by{|x| x.pk}.must_equal [@album, album]
839
839
  end
840
840
 
841
- specify "should work correctly when filtering by association datasets" do
841
+ it "should work correctly when filtering by association datasets" do
842
842
  album, artist, tag = @pr.call
843
843
  @album.update(:artist => @artist)
844
844
  @album.add_tag(@tag)
845
845
  album.add_tag(tag)
846
846
  album.update(:artist => artist)
847
847
 
848
- @Artist.filter(:albums=>@Album).all.sort_by{|x| x.pk}.should == [@artist, artist]
849
- @Artist.filter(:albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [artist]
850
- @Artist.filter(:albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
851
- @Artist.filter(:first_album=>@Album).all.sort_by{|x| x.pk}.should == [@artist, artist]
852
- @Artist.filter(:first_album=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [artist]
853
- @Artist.filter(:first_album=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
854
- @Album.filter(:artist=>@Artist).all.sort_by{|x| x.pk}.should == [@album, album]
855
- @Album.filter(:artist=>@Artist.filter(Array(Artist.primary_key).map{|k| Sequel.qualify(Artist.table_name, k)}.zip(Array(artist.pk)))).all.sort_by{|x| x.pk}.should == [album]
856
- @Album.filter(:artist=>@Artist.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
857
- @Album.filter(:tags=>@Tag).all.sort_by{|x| x.pk}.should == [@album, album]
858
- @Album.filter(:tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [album]
859
- @Album.filter(:tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
860
- @Album.filter(:alias_tags=>@Tag).all.sort_by{|x| x.pk}.should == [@album, album]
861
- @Album.filter(:alias_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [album]
862
- @Album.filter(:alias_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
863
- @Tag.filter(:albums=>@Album).all.sort_by{|x| x.pk}.should == [@tag, tag]
864
- @Tag.filter(:albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [tag]
865
- @Tag.filter(:albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
848
+ @Artist.filter(:albums=>@Album).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
849
+ @Artist.filter(:albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.must_equal [artist]
850
+ @Artist.filter(:albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
851
+ @Artist.filter(:first_album=>@Album).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
852
+ @Artist.filter(:first_album=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.must_equal [artist]
853
+ @Artist.filter(:first_album=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
854
+ @Album.filter(:artist=>@Artist).all.sort_by{|x| x.pk}.must_equal [@album, album]
855
+ @Album.filter(:artist=>@Artist.filter(Array(Artist.primary_key).map{|k| Sequel.qualify(Artist.table_name, k)}.zip(Array(artist.pk)))).all.sort_by{|x| x.pk}.must_equal [album]
856
+ @Album.filter(:artist=>@Artist.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
857
+ @Album.filter(:tags=>@Tag).all.sort_by{|x| x.pk}.must_equal [@album, album]
858
+ @Album.filter(:tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [album]
859
+ @Album.filter(:tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
860
+ @Album.filter(:alias_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal [@album, album]
861
+ @Album.filter(:alias_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [album]
862
+ @Album.filter(:alias_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
863
+ @Tag.filter(:albums=>@Album).all.sort_by{|x| x.pk}.must_equal [@tag, tag]
864
+ @Tag.filter(:albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.must_equal [tag]
865
+ @Tag.filter(:albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
866
866
 
867
867
  unless @no_many_through_many
868
- @Artist.filter(:tags=>@Tag).all.sort_by{|x| x.pk}.should == [@artist, artist]
869
- @Artist.filter(:tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [artist]
870
- @Artist.filter(:tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
871
- @Artist.filter(:first_tag=>@Tag).all.sort_by{|x| x.pk}.should == [@artist, artist]
872
- @Artist.filter(:first_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [artist]
873
- @Artist.filter(:first_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
868
+ @Artist.filter(:tags=>@Tag).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
869
+ @Artist.filter(:tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [artist]
870
+ @Artist.filter(:tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
871
+ @Artist.filter(:first_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
872
+ @Artist.filter(:first_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [artist]
873
+ @Artist.filter(:first_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
874
874
  end
875
875
  end
876
876
 
877
- specify "should work correctly when excluding by association datasets" do
877
+ it "should work correctly when excluding by association datasets" do
878
878
  album, artist, tag = @pr.call
879
879
  @album.update(:artist => @artist)
880
880
  @album.add_tag(@tag)
881
881
  album.add_tag(tag)
882
882
  album.update(:artist => artist)
883
883
 
884
- @Artist.exclude(:albums=>@Album).all.sort_by{|x| x.pk}.should == []
885
- @Artist.exclude(:albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [@artist]
886
- @Artist.exclude(:albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@artist, artist]
887
- @Artist.exclude(:first_album=>@Album).all.sort_by{|x| x.pk}.should == []
888
- @Artist.exclude(:first_album=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [@artist]
889
- @Artist.exclude(:first_album=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@artist, artist]
890
- @Album.exclude(:artist=>@Artist).all.sort_by{|x| x.pk}.should == []
891
- @Album.exclude(:artist=>@Artist.filter(Array(Artist.primary_key).map{|k| Sequel.qualify(Artist.table_name, k)}.zip(Array(artist.pk)))).all.sort_by{|x| x.pk}.should == [@album]
892
- @Album.exclude(:artist=>@Artist.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@album, album]
893
- @Album.exclude(:tags=>@Tag).all.sort_by{|x| x.pk}.should == []
894
- @Album.exclude(:tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@album]
895
- @Album.exclude(:tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@album, album]
896
- @Album.exclude(:alias_tags=>@Tag).all.sort_by{|x| x.pk}.should == []
897
- @Album.exclude(:alias_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@album]
898
- @Album.exclude(:alias_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@album, album]
899
- @Tag.exclude(:albums=>@Album).all.sort_by{|x| x.pk}.should == []
900
- @Tag.exclude(:albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [@tag]
901
- @Tag.exclude(:albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@tag, tag]
884
+ @Artist.exclude(:albums=>@Album).all.sort_by{|x| x.pk}.must_equal []
885
+ @Artist.exclude(:albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.must_equal [@artist]
886
+ @Artist.exclude(:albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
887
+ @Artist.exclude(:first_album=>@Album).all.sort_by{|x| x.pk}.must_equal []
888
+ @Artist.exclude(:first_album=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.must_equal [@artist]
889
+ @Artist.exclude(:first_album=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
890
+ @Album.exclude(:artist=>@Artist).all.sort_by{|x| x.pk}.must_equal []
891
+ @Album.exclude(:artist=>@Artist.filter(Array(Artist.primary_key).map{|k| Sequel.qualify(Artist.table_name, k)}.zip(Array(artist.pk)))).all.sort_by{|x| x.pk}.must_equal [@album]
892
+ @Album.exclude(:artist=>@Artist.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@album, album]
893
+ @Album.exclude(:tags=>@Tag).all.sort_by{|x| x.pk}.must_equal []
894
+ @Album.exclude(:tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [@album]
895
+ @Album.exclude(:tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@album, album]
896
+ @Album.exclude(:alias_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal []
897
+ @Album.exclude(:alias_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [@album]
898
+ @Album.exclude(:alias_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@album, album]
899
+ @Tag.exclude(:albums=>@Album).all.sort_by{|x| x.pk}.must_equal []
900
+ @Tag.exclude(:albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.must_equal [@tag]
901
+ @Tag.exclude(:albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@tag, tag]
902
902
 
903
903
  unless @no_many_through_many
904
- @Artist.exclude(:tags=>@Tag).all.sort_by{|x| x.pk}.should == []
905
- @Artist.exclude(:tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@artist]
906
- @Artist.exclude(:tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@artist, artist]
907
- @Artist.exclude(:first_tag=>@Tag).all.sort_by{|x| x.pk}.should == []
908
- @Artist.exclude(:first_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@artist]
909
- @Artist.exclude(:first_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@artist, artist]
904
+ @Artist.exclude(:tags=>@Tag).all.sort_by{|x| x.pk}.must_equal []
905
+ @Artist.exclude(:tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [@artist]
906
+ @Artist.exclude(:tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
907
+ @Artist.exclude(:first_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal []
908
+ @Artist.exclude(:first_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [@artist]
909
+ @Artist.exclude(:first_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
910
910
  end
911
911
  end
912
912
 
913
- specify "should work correctly when filtering by association datasets with conditions" do
913
+ it "should work correctly when filtering by association datasets with conditions" do
914
914
  album, artist, tag = @pr.call
915
915
  @album.update(:artist => @artist)
916
916
  @album.add_tag(@tag)
917
917
  album.add_tag(tag)
918
918
  album.update(:artist => artist)
919
919
 
920
- @Artist.filter(:a_albums=>@Album).all.sort_by{|x| x.pk}.should == [@artist]
921
- @Artist.filter(:first_a_album=>@Album).all.sort_by{|x| x.pk}.should == [@artist]
922
- @Album.filter(:a_artist=>@Artist).all.sort_by{|x| x.pk}.should == [@album]
923
- @Album.filter(:t_tags=>@Tag).all.sort_by{|x| x.pk}.should == [@album]
924
- @Album.filter(:alias_t_tags=>@Tag).all.sort_by{|x| x.pk}.should == [@album]
920
+ @Artist.filter(:a_albums=>@Album).all.sort_by{|x| x.pk}.must_equal [@artist]
921
+ @Artist.filter(:first_a_album=>@Album).all.sort_by{|x| x.pk}.must_equal [@artist]
922
+ @Album.filter(:a_artist=>@Artist).all.sort_by{|x| x.pk}.must_equal [@album]
923
+ @Album.filter(:t_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal [@album]
924
+ @Album.filter(:alias_t_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal [@album]
925
925
  unless @no_many_through_many
926
- @Album.filter(:t_tag=>@Tag).all.sort_by{|x| x.pk}.should == [@album]
927
- @Album.filter(:alias_t_tag=>@Tag).all.sort_by{|x| x.pk}.should == [@album]
928
- @Artist.filter(:t_tags=>@Tag).all.sort_by{|x| x.pk}.should == [@artist]
929
- @Artist.filter(:t_tag=>@Tag).all.sort_by{|x| x.pk}.should == [@artist]
926
+ @Album.filter(:t_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal [@album]
927
+ @Album.filter(:alias_t_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal [@album]
928
+ @Artist.filter(:t_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal [@artist]
929
+ @Artist.filter(:t_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal [@artist]
930
930
  end
931
931
 
932
932
  artist.update(:name=>@artist.name)
933
933
  album.update(:name=>@album.name)
934
934
  tag.update(:name=>@tag.name)
935
935
 
936
- @Artist.filter(:a_albums=>@Album).all.sort_by{|x| x.pk}.should == [@artist, artist]
937
- @Artist.filter(:first_a_album=>@Album).all.sort_by{|x| x.pk}.should == [@artist, artist]
938
- @Album.filter(:a_artist=>@Artist).all.sort_by{|x| x.pk}.should == [@album, album]
939
- @Album.filter(:t_tags=>@Tag).all.sort_by{|x| x.pk}.should == [@album, album]
940
- @Album.filter(:alias_t_tags=>@Tag).all.sort_by{|x| x.pk}.should == [@album, album]
936
+ @Artist.filter(:a_albums=>@Album).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
937
+ @Artist.filter(:first_a_album=>@Album).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
938
+ @Album.filter(:a_artist=>@Artist).all.sort_by{|x| x.pk}.must_equal [@album, album]
939
+ @Album.filter(:t_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal [@album, album]
940
+ @Album.filter(:alias_t_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal [@album, album]
941
941
  unless @no_many_through_many
942
- @Album.filter(:t_tag=>@Tag).all.sort_by{|x| x.pk}.should == [@album, album]
943
- @Album.filter(:alias_t_tag=>@Tag).all.sort_by{|x| x.pk}.should == [@album, album]
944
- @Artist.filter(:t_tags=>@Tag).all.sort_by{|x| x.pk}.should == [@artist, artist]
945
- @Artist.filter(:t_tag=>@Tag).all.sort_by{|x| x.pk}.should == [@artist, artist]
942
+ @Album.filter(:t_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal [@album, album]
943
+ @Album.filter(:alias_t_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal [@album, album]
944
+ @Artist.filter(:t_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
945
+ @Artist.filter(:t_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
946
946
  end
947
947
 
948
- @Artist.filter(:a_albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [artist]
949
- @Artist.filter(:first_a_album=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [artist]
950
- @Album.filter(:a_artist=>@Artist.filter(Array(Artist.primary_key).map{|k| Sequel.qualify(Artist.table_name, k)}.zip(Array(artist.pk)))).all.sort_by{|x| x.pk}.should == [album]
951
- @Album.filter(:t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [album]
952
- @Album.filter(:alias_t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [album]
948
+ @Artist.filter(:a_albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.must_equal [artist]
949
+ @Artist.filter(:first_a_album=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.must_equal [artist]
950
+ @Album.filter(:a_artist=>@Artist.filter(Array(Artist.primary_key).map{|k| Sequel.qualify(Artist.table_name, k)}.zip(Array(artist.pk)))).all.sort_by{|x| x.pk}.must_equal [album]
951
+ @Album.filter(:t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [album]
952
+ @Album.filter(:alias_t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [album]
953
953
  unless @no_many_through_many
954
- @Album.filter(:t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [album]
955
- @Album.filter(:alias_t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [album]
956
- @Artist.filter(:t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [artist]
957
- @Artist.filter(:t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [artist]
958
- end
959
-
960
- @Artist.filter(:a_albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
961
- @Artist.filter(:first_a_album=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
962
- @Album.filter(:a_artist=>@Artist.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
963
- @Album.filter(:t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [album]
964
- @Album.filter(:t_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
965
- @Album.filter(:alias_t_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
954
+ @Album.filter(:t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [album]
955
+ @Album.filter(:alias_t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [album]
956
+ @Artist.filter(:t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [artist]
957
+ @Artist.filter(:t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [artist]
958
+ end
959
+
960
+ @Artist.filter(:a_albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
961
+ @Artist.filter(:first_a_album=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
962
+ @Album.filter(:a_artist=>@Artist.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
963
+ @Album.filter(:t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [album]
964
+ @Album.filter(:t_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
965
+ @Album.filter(:alias_t_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
966
966
  unless @no_many_through_many
967
- @Album.filter(:t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [album]
968
- @Album.filter(:t_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
969
- @Album.filter(:alias_t_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
970
- @Artist.filter(:t_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
971
- @Artist.filter(:t_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == []
967
+ @Album.filter(:t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [album]
968
+ @Album.filter(:t_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
969
+ @Album.filter(:alias_t_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
970
+ @Artist.filter(:t_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
971
+ @Artist.filter(:t_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal []
972
972
  end
973
973
  end
974
974
 
975
- specify "should work correctly when excluding by association datasets with conditions" do
975
+ it "should work correctly when excluding by association datasets with conditions" do
976
976
  album, artist, tag = @pr.call
977
977
  @album.update(:artist => @artist)
978
978
  @album.add_tag(@tag)
979
979
  album.add_tag(tag)
980
980
  album.update(:artist => artist)
981
981
 
982
- @Artist.exclude(:a_albums=>@Album).all.sort_by{|x| x.pk}.should == [artist]
983
- @Artist.exclude(:first_a_album=>@Album).all.sort_by{|x| x.pk}.should == [artist]
984
- @Album.exclude(:a_artist=>@Artist).all.sort_by{|x| x.pk}.should == [album]
985
- @Album.exclude(:t_tags=>@Tag).all.sort_by{|x| x.pk}.should == [album]
986
- @Album.exclude(:alias_t_tags=>@Tag).all.sort_by{|x| x.pk}.should == [album]
982
+ @Artist.exclude(:a_albums=>@Album).all.sort_by{|x| x.pk}.must_equal [artist]
983
+ @Artist.exclude(:first_a_album=>@Album).all.sort_by{|x| x.pk}.must_equal [artist]
984
+ @Album.exclude(:a_artist=>@Artist).all.sort_by{|x| x.pk}.must_equal [album]
985
+ @Album.exclude(:t_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal [album]
986
+ @Album.exclude(:alias_t_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal [album]
987
987
  unless @no_many_through_many
988
- @Album.exclude(:t_tag=>@Tag).all.sort_by{|x| x.pk}.should == [album]
989
- @Album.exclude(:alias_t_tag=>@Tag).all.sort_by{|x| x.pk}.should == [album]
990
- @Artist.exclude(:t_tags=>@Tag).all.sort_by{|x| x.pk}.should == [artist]
991
- @Artist.exclude(:t_tag=>@Tag).all.sort_by{|x| x.pk}.should == [artist]
988
+ @Album.exclude(:t_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal [album]
989
+ @Album.exclude(:alias_t_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal [album]
990
+ @Artist.exclude(:t_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal [artist]
991
+ @Artist.exclude(:t_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal [artist]
992
992
  end
993
993
 
994
994
  artist.update(:name=>@artist.name)
995
995
  album.update(:name=>@album.name)
996
996
  tag.update(:name=>@tag.name)
997
997
 
998
- @Artist.exclude(:a_albums=>@Album).all.sort_by{|x| x.pk}.should == []
999
- @Artist.exclude(:first_a_album=>@Album).all.sort_by{|x| x.pk}.should == []
1000
- @Album.exclude(:a_artist=>@Artist).all.sort_by{|x| x.pk}.should == []
1001
- @Album.exclude(:t_tags=>@Tag).all.sort_by{|x| x.pk}.should == []
1002
- @Album.exclude(:alias_t_tags=>@Tag).all.sort_by{|x| x.pk}.should == []
998
+ @Artist.exclude(:a_albums=>@Album).all.sort_by{|x| x.pk}.must_equal []
999
+ @Artist.exclude(:first_a_album=>@Album).all.sort_by{|x| x.pk}.must_equal []
1000
+ @Album.exclude(:a_artist=>@Artist).all.sort_by{|x| x.pk}.must_equal []
1001
+ @Album.exclude(:t_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal []
1002
+ @Album.exclude(:alias_t_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal []
1003
1003
  unless @no_many_through_many
1004
- @Album.exclude(:t_tag=>@Tag).all.sort_by{|x| x.pk}.should == []
1005
- @Album.exclude(:alias_t_tag=>@Tag).all.sort_by{|x| x.pk}.should == []
1006
- @Artist.exclude(:t_tags=>@Tag).all.sort_by{|x| x.pk}.should == []
1007
- @Artist.exclude(:t_tag=>@Tag).all.sort_by{|x| x.pk}.should == []
1004
+ @Album.exclude(:t_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal []
1005
+ @Album.exclude(:alias_t_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal []
1006
+ @Artist.exclude(:t_tags=>@Tag).all.sort_by{|x| x.pk}.must_equal []
1007
+ @Artist.exclude(:t_tag=>@Tag).all.sort_by{|x| x.pk}.must_equal []
1008
1008
  end
1009
1009
 
1010
- @Artist.exclude(:a_albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [@artist]
1011
- @Artist.exclude(:first_a_album=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.should == [@artist]
1012
- @Album.exclude(:a_artist=>@Artist.filter(Array(Artist.primary_key).map{|k| Sequel.qualify(Artist.table_name, k)}.zip(Array(artist.pk)))).all.sort_by{|x| x.pk}.should == [@album]
1013
- @Album.exclude(:t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@album]
1014
- @Album.exclude(:alias_t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@album]
1010
+ @Artist.exclude(:a_albums=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.must_equal [@artist]
1011
+ @Artist.exclude(:first_a_album=>@Album.filter(Array(Album.primary_key).map{|k| Sequel.qualify(Album.table_name, k)}.zip(Array(album.pk)))).all.sort_by{|x| x.pk}.must_equal [@artist]
1012
+ @Album.exclude(:a_artist=>@Artist.filter(Array(Artist.primary_key).map{|k| Sequel.qualify(Artist.table_name, k)}.zip(Array(artist.pk)))).all.sort_by{|x| x.pk}.must_equal [@album]
1013
+ @Album.exclude(:t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [@album]
1014
+ @Album.exclude(:alias_t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [@album]
1015
1015
  unless @no_many_through_many
1016
- @Album.exclude(:t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@album]
1017
- @Album.exclude(:alias_t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@album]
1018
- @Artist.exclude(:t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@artist]
1019
- @Artist.exclude(:t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.should == [@artist]
1016
+ @Album.exclude(:t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [@album]
1017
+ @Album.exclude(:alias_t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [@album]
1018
+ @Artist.exclude(:t_tags=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [@artist]
1019
+ @Artist.exclude(:t_tag=>@Tag.filter(Array(Tag.primary_key).map{|k| Sequel.qualify(Tag.table_name, k)}.zip(Array(tag.pk)))).all.sort_by{|x| x.pk}.must_equal [@artist]
1020
1020
  end
1021
1021
 
1022
- @Artist.exclude(:a_albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@artist, artist]
1023
- @Artist.exclude(:first_a_album=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@artist, artist]
1024
- @Album.exclude(:a_artist=>@Artist.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@album, album]
1025
- @Album.exclude(:t_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@album, album]
1026
- @Album.exclude(:alias_t_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@album, album]
1022
+ @Artist.exclude(:a_albums=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
1023
+ @Artist.exclude(:first_a_album=>@Album.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
1024
+ @Album.exclude(:a_artist=>@Artist.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@album, album]
1025
+ @Album.exclude(:t_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@album, album]
1026
+ @Album.exclude(:alias_t_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@album, album]
1027
1027
  unless @no_many_through_many
1028
- @Album.exclude(:t_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@album, album]
1029
- @Album.exclude(:alias_t_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@album, album]
1030
- @Artist.exclude(:t_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@artist, artist]
1031
- @Artist.exclude(:t_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.should == [@artist, artist]
1028
+ @Album.exclude(:t_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@album, album]
1029
+ @Album.exclude(:alias_t_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@album, album]
1030
+ @Artist.exclude(:t_tags=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
1031
+ @Artist.exclude(:t_tag=>@Tag.filter(1=>0)).all.sort_by{|x| x.pk}.must_equal [@artist, artist]
1032
1032
  end
1033
1033
  end
1034
1034
  end
1035
1035
 
1036
- shared_examples_for "filter by associations one_to_one limit strategies" do
1037
- specify "filter by associations with limited one_to_one associations should work correctly" do
1036
+ FilterByAssociationsOneToOneLimitStrategies = shared_description do
1037
+ it "filter by associations with limited one_to_one associations should work correctly" do
1038
1038
  Artist.one_to_one :first_album, {:clone=>:first_album}.merge(@els)
1039
1039
  Artist.one_to_one :last_album, {:clone=>:last_album}.merge(@els)
1040
1040
  Artist.one_to_one :second_album, {:clone=>:second_album}.merge(@els)
@@ -1043,34 +1043,34 @@ shared_examples_for "filter by associations one_to_one limit strategies" do
1043
1043
  ar = @pr.call[1]
1044
1044
  ds = Artist.order(:name)
1045
1045
 
1046
- ds.where(:first_album=>@album).all.should == [@artist]
1047
- ds.where(:first_album=>diff_album).all.should == []
1048
- ds.exclude(:first_album=>@album).all.should == [ar]
1049
- ds.exclude(:first_album=>diff_album).all.should == [@artist, ar]
1046
+ ds.where(:first_album=>@album).all.must_equal [@artist]
1047
+ ds.where(:first_album=>diff_album).all.must_equal []
1048
+ ds.exclude(:first_album=>@album).all.must_equal [ar]
1049
+ ds.exclude(:first_album=>diff_album).all.must_equal [@artist, ar]
1050
1050
 
1051
1051
  if @els[:eager_limit_strategy] != :distinct_on && (@els[:eager_limit_strategy] != :correlated_subquery || Album.dataset.supports_offsets_in_correlated_subqueries?)
1052
- ds.where(:second_album=>@album).all.should == []
1053
- ds.where(:second_album=>diff_album).all.should == [@artist]
1054
- ds.exclude(:second_album=>@album).all.should == [@artist, ar]
1055
- ds.exclude(:second_album=>diff_album).all.should == [ar]
1052
+ ds.where(:second_album=>@album).all.must_equal []
1053
+ ds.where(:second_album=>diff_album).all.must_equal [@artist]
1054
+ ds.exclude(:second_album=>@album).all.must_equal [@artist, ar]
1055
+ ds.exclude(:second_album=>diff_album).all.must_equal [ar]
1056
1056
  end
1057
1057
 
1058
- ds.where(:last_album=>@album).all.should == []
1059
- ds.where(:last_album=>diff_album).all.should == [@artist]
1060
- ds.exclude(:last_album=>@album).all.should == [@artist, ar]
1061
- ds.exclude(:last_album=>diff_album).all.should == [ar]
1058
+ ds.where(:last_album=>@album).all.must_equal []
1059
+ ds.where(:last_album=>diff_album).all.must_equal [@artist]
1060
+ ds.exclude(:last_album=>@album).all.must_equal [@artist, ar]
1061
+ ds.exclude(:last_album=>diff_album).all.must_equal [ar]
1062
1062
 
1063
1063
  Artist.one_to_one :first_album, :clone=>:first_album do |ads| ads.where(:albums__name=>diff_album.name) end
1064
1064
  ar.add_album(diff_album)
1065
- ds.where(:first_album=>[@album, diff_album]).all.should == [ar]
1066
- ds.exclude(:first_album=>[@album, diff_album]).all.should == [@artist]
1065
+ ds.where(:first_album=>[@album, diff_album]).all.must_equal [ar]
1066
+ ds.exclude(:first_album=>[@album, diff_album]).all.must_equal [@artist]
1067
1067
  end
1068
1068
  end
1069
1069
 
1070
- shared_examples_for "filter by associations singular association limit strategies" do
1071
- it_should_behave_like "filter by associations one_to_one limit strategies"
1070
+ FilterByAssociationsSingularLimitStrategies = shared_description do
1071
+ include FilterByAssociationsOneToOneLimitStrategies
1072
1072
 
1073
- specify "dataset associations with limited one_to_one associations should work correctly" do
1073
+ it "dataset associations with limited one_to_one associations should work correctly" do
1074
1074
  Artist.one_to_one :first_album, {:clone=>:first_album}.merge(@els)
1075
1075
  Artist.one_to_one :last_album, {:clone=>:last_album}.merge(@els)
1076
1076
  Artist.one_to_one :second_album, {:clone=>:second_album}.merge(@els) if @els[:eager_limit_strategy] != :distinct_on
@@ -1079,20 +1079,20 @@ shared_examples_for "filter by associations singular association limit strategie
1079
1079
  ar = @pr.call[1]
1080
1080
  ds = Artist
1081
1081
 
1082
- ds.where(@artist.pk_hash).first_albums.all.should == [@album]
1083
- ds.where(@artist.pk_hash).second_albums.all.should == [diff_album]
1084
- ds.where(@artist.pk_hash).last_albums.all.should == [diff_album]
1085
- ds.where(ar.pk_hash).first_albums.all.should == []
1086
- ds.where(ar.pk_hash).second_albums.all.should == []
1087
- ds.where(ar.pk_hash).last_albums.all.should == []
1082
+ ds.where(@artist.pk_hash).first_albums.all.must_equal [@album]
1083
+ ds.where(@artist.pk_hash).second_albums.all.must_equal [diff_album]
1084
+ ds.where(@artist.pk_hash).last_albums.all.must_equal [diff_album]
1085
+ ds.where(ar.pk_hash).first_albums.all.must_equal []
1086
+ ds.where(ar.pk_hash).second_albums.all.must_equal []
1087
+ ds.where(ar.pk_hash).last_albums.all.must_equal []
1088
1088
 
1089
1089
  Artist.one_to_one :first_album, :clone=>:first_album do |ads| ads.where(:albums__name=>diff_album.name) end
1090
1090
  ar.add_album(diff_album)
1091
- ds.where(@artist.pk_hash).first_albums.all.should == []
1092
- ds.where(ar.pk_hash).first_albums.all.should == [diff_album]
1091
+ ds.where(@artist.pk_hash).first_albums.all.must_equal []
1092
+ ds.where(ar.pk_hash).first_albums.all.must_equal [diff_album]
1093
1093
  end
1094
1094
 
1095
- specify "filter by associations with limited one_through_one associations should work correctly" do
1095
+ it "filter by associations with limited one_through_one associations should work correctly" do
1096
1096
  Album.one_through_one :first_tag, {:clone=>:first_tag}.merge(@els)
1097
1097
  Album.one_through_one :second_tag, {:clone=>:second_tag}.merge(@els) if @els[:eager_limit_strategy] != :distinct_on
1098
1098
  Album.one_through_one :last_tag, {:clone=>:last_tag}.merge(@els)
@@ -1101,39 +1101,39 @@ shared_examples_for "filter by associations singular association limit strategie
1101
1101
  ds = Album.order(:name)
1102
1102
  al.add_tag(tu)
1103
1103
 
1104
- ds.where(:first_tag=>@tag).all.should == [@album]
1105
- ds.where(:first_tag=>tu).all.should == [al]
1106
- ds.where(:first_tag=>tv).all.should == []
1107
- ds.exclude(:first_tag=>@tag).all.should == [al]
1108
- ds.exclude(:first_tag=>tu).all.should == [@album]
1109
- ds.exclude(:first_tag=>tv).all.should == [@album, al]
1110
-
1111
- ds.where(:second_tag=>@tag).all.should == []
1112
- ds.where(:second_tag=>tu).all.should == [@album]
1113
- ds.where(:second_tag=>tv).all.should == []
1114
- ds.exclude(:second_tag=>@tag).all.should == [@album, al]
1115
- ds.exclude(:second_tag=>tu).all.should == [al]
1116
- ds.exclude(:second_tag=>tv).all.should == [@album, al]
1117
-
1118
- ds.where(:last_tag=>@tag).all.should == []
1119
- ds.where(:last_tag=>tu).all.should == [al]
1120
- ds.where(:last_tag=>tv).all.should == [@album]
1121
- ds.exclude(:last_tag=>@tag).all.should == [@album, al]
1122
- ds.exclude(:last_tag=>tu).all.should == [@album]
1123
- ds.exclude(:last_tag=>tv).all.should == [al]
1104
+ ds.where(:first_tag=>@tag).all.must_equal [@album]
1105
+ ds.where(:first_tag=>tu).all.must_equal [al]
1106
+ ds.where(:first_tag=>tv).all.must_equal []
1107
+ ds.exclude(:first_tag=>@tag).all.must_equal [al]
1108
+ ds.exclude(:first_tag=>tu).all.must_equal [@album]
1109
+ ds.exclude(:first_tag=>tv).all.must_equal [@album, al]
1110
+
1111
+ ds.where(:second_tag=>@tag).all.must_equal []
1112
+ ds.where(:second_tag=>tu).all.must_equal [@album]
1113
+ ds.where(:second_tag=>tv).all.must_equal []
1114
+ ds.exclude(:second_tag=>@tag).all.must_equal [@album, al]
1115
+ ds.exclude(:second_tag=>tu).all.must_equal [al]
1116
+ ds.exclude(:second_tag=>tv).all.must_equal [@album, al]
1117
+
1118
+ ds.where(:last_tag=>@tag).all.must_equal []
1119
+ ds.where(:last_tag=>tu).all.must_equal [al]
1120
+ ds.where(:last_tag=>tv).all.must_equal [@album]
1121
+ ds.exclude(:last_tag=>@tag).all.must_equal [@album, al]
1122
+ ds.exclude(:last_tag=>tu).all.must_equal [@album]
1123
+ ds.exclude(:last_tag=>tv).all.must_equal [al]
1124
1124
 
1125
1125
  Album.one_through_one :first_tag, :clone=>:first_tag do |ads| ads.where(:tags__name=>tu.name) end
1126
1126
  Album.one_through_one :second_tag, :clone=>:second_tag do |ads| ads.where(:tags__name=>[tu.name, tv.name]) end
1127
1127
 
1128
- ds.where(:first_tag=>[@tag, tu]).all.should == [@album, al]
1129
- ds.exclude(:first_tag=>[@tag, tu]).all.should == []
1128
+ ds.where(:first_tag=>[@tag, tu]).all.must_equal [@album, al]
1129
+ ds.exclude(:first_tag=>[@tag, tu]).all.must_equal []
1130
1130
 
1131
1131
  al.add_tag(tv)
1132
- ds.where(:second_tag=>[tv, tu]).all.should == [@album, al]
1133
- ds.exclude(:second_tag=>[tv, tu]).all.should == []
1132
+ ds.where(:second_tag=>[tv, tu]).all.must_equal [@album, al]
1133
+ ds.exclude(:second_tag=>[tv, tu]).all.must_equal []
1134
1134
  end
1135
1135
 
1136
- specify "dataset associations with limited one_through_one associations should work correctly" do
1136
+ it "dataset associations with limited one_through_one associations should work correctly" do
1137
1137
  Album.one_through_one :first_tag, {:clone=>:first_tag}.merge(@els)
1138
1138
  Album.one_through_one :second_tag, {:clone=>:second_tag}.merge(@els) if @els[:eager_limit_strategy] != :distinct_on
1139
1139
  Album.one_through_one :last_tag, {:clone=>:last_tag}.merge(@els)
@@ -1142,29 +1142,29 @@ shared_examples_for "filter by associations singular association limit strategie
1142
1142
  ds = Album
1143
1143
  al.add_tag(tu)
1144
1144
 
1145
- ds.where(@album.pk_hash).first_tags.all.should == [@tag]
1146
- ds.where(@album.pk_hash).second_tags.all.should == [tu]
1147
- ds.where(@album.pk_hash).last_tags.all.should == [tv]
1148
- ds.where(al.pk_hash).first_tags.all.should == [tu]
1149
- ds.where(al.pk_hash).second_tags.all.should == []
1150
- ds.where(al.pk_hash).last_tags.all.should == [tu]
1145
+ ds.where(@album.pk_hash).first_tags.all.must_equal [@tag]
1146
+ ds.where(@album.pk_hash).second_tags.all.must_equal [tu]
1147
+ ds.where(@album.pk_hash).last_tags.all.must_equal [tv]
1148
+ ds.where(al.pk_hash).first_tags.all.must_equal [tu]
1149
+ ds.where(al.pk_hash).second_tags.all.must_equal []
1150
+ ds.where(al.pk_hash).last_tags.all.must_equal [tu]
1151
1151
 
1152
1152
  Album.one_through_one :first_tag, :clone=>:first_tag do |ads| ads.where(:tags__name=>tu.name) end
1153
1153
  Album.one_through_one :second_tag, :clone=>:second_tag do |ads| ads.where(:tags__name=>[tu.name, tv.name]) end
1154
1154
 
1155
- ds.where(@album.pk_hash).first_tags.all.should == [tu]
1156
- ds.where(@album.pk_hash).second_tags.all.should == [tv]
1157
- ds.where(al.pk_hash).first_tags.all.should == [tu]
1158
- ds.where(al.pk_hash).second_tags.all.should == []
1155
+ ds.where(@album.pk_hash).first_tags.all.must_equal [tu]
1156
+ ds.where(@album.pk_hash).second_tags.all.must_equal [tv]
1157
+ ds.where(al.pk_hash).first_tags.all.must_equal [tu]
1158
+ ds.where(al.pk_hash).second_tags.all.must_equal []
1159
1159
 
1160
1160
  al.add_tag(tv)
1161
- ds.where(@album.pk_hash).first_tags.all.should == [tu]
1162
- ds.where(@album.pk_hash).second_tags.all.should == [tv]
1163
- ds.where(al.pk_hash).first_tags.all.should == [tu]
1164
- ds.where(al.pk_hash).second_tags.all.should == [tv]
1161
+ ds.where(@album.pk_hash).first_tags.all.must_equal [tu]
1162
+ ds.where(@album.pk_hash).second_tags.all.must_equal [tv]
1163
+ ds.where(al.pk_hash).first_tags.all.must_equal [tu]
1164
+ ds.where(al.pk_hash).second_tags.all.must_equal [tv]
1165
1165
  end
1166
1166
 
1167
- specify "filter by associations with limited one_through_many associations should work correctly" do
1167
+ it "filter by associations with limited one_through_many associations should work correctly" do
1168
1168
  Artist.one_through_many :first_tag, {:clone=>:first_tag}.merge(@els)
1169
1169
  Artist.one_through_many :second_tag, {:clone=>:second_tag}.merge(@els) if @els[:eager_limit_strategy] != :distinct_on
1170
1170
  Artist.one_through_many :last_tag, {:clone=>:last_tag}.merge(@els)
@@ -1175,39 +1175,39 @@ shared_examples_for "filter by associations singular association limit strategie
1175
1175
  al.add_tag(tu)
1176
1176
  ds = Artist.order(:name)
1177
1177
 
1178
- ds.where(:first_tag=>@tag).all.should == [@artist]
1179
- ds.where(:first_tag=>tu).all.should == [ar]
1180
- ds.where(:first_tag=>tv).all.should == []
1181
- ds.exclude(:first_tag=>@tag).all.should == [ar]
1182
- ds.exclude(:first_tag=>tu).all.should == [@artist]
1183
- ds.exclude(:first_tag=>tv).all.should == [@artist, ar]
1184
-
1185
- ds.where(:second_tag=>@tag).all.should == []
1186
- ds.where(:second_tag=>tu).all.should == [@artist]
1187
- ds.where(:second_tag=>tv).all.should == []
1188
- ds.exclude(:second_tag=>@tag).all.should == [@artist, ar]
1189
- ds.exclude(:second_tag=>tu).all.should == [ar]
1190
- ds.exclude(:second_tag=>tv).all.should == [@artist, ar]
1191
-
1192
- ds.where(:last_tag=>@tag).all.should == []
1193
- ds.where(:last_tag=>tu).all.should == [ar]
1194
- ds.where(:last_tag=>tv).all.should == [@artist]
1195
- ds.exclude(:last_tag=>@tag).all.should == [@artist, ar]
1196
- ds.exclude(:last_tag=>tu).all.should == [@artist]
1197
- ds.exclude(:last_tag=>tv).all.should == [ar]
1178
+ ds.where(:first_tag=>@tag).all.must_equal [@artist]
1179
+ ds.where(:first_tag=>tu).all.must_equal [ar]
1180
+ ds.where(:first_tag=>tv).all.must_equal []
1181
+ ds.exclude(:first_tag=>@tag).all.must_equal [ar]
1182
+ ds.exclude(:first_tag=>tu).all.must_equal [@artist]
1183
+ ds.exclude(:first_tag=>tv).all.must_equal [@artist, ar]
1184
+
1185
+ ds.where(:second_tag=>@tag).all.must_equal []
1186
+ ds.where(:second_tag=>tu).all.must_equal [@artist]
1187
+ ds.where(:second_tag=>tv).all.must_equal []
1188
+ ds.exclude(:second_tag=>@tag).all.must_equal [@artist, ar]
1189
+ ds.exclude(:second_tag=>tu).all.must_equal [ar]
1190
+ ds.exclude(:second_tag=>tv).all.must_equal [@artist, ar]
1191
+
1192
+ ds.where(:last_tag=>@tag).all.must_equal []
1193
+ ds.where(:last_tag=>tu).all.must_equal [ar]
1194
+ ds.where(:last_tag=>tv).all.must_equal [@artist]
1195
+ ds.exclude(:last_tag=>@tag).all.must_equal [@artist, ar]
1196
+ ds.exclude(:last_tag=>tu).all.must_equal [@artist]
1197
+ ds.exclude(:last_tag=>tv).all.must_equal [ar]
1198
1198
 
1199
1199
  Artist.one_through_many :first_tag, :clone=>:first_tag do |ads| ads.where(:tags__name=>tu.name) end
1200
1200
  Artist.one_through_many :second_tag, :clone=>:second_tag do |ads| ads.where(:tags__name=>[tu.name, tv.name]) end
1201
1201
 
1202
- ds.where(:first_tag=>[@tag, tu]).all.should == [@artist, ar]
1203
- ds.exclude(:first_tag=>[@tag, tu]).all.should == []
1202
+ ds.where(:first_tag=>[@tag, tu]).all.must_equal [@artist, ar]
1203
+ ds.exclude(:first_tag=>[@tag, tu]).all.must_equal []
1204
1204
 
1205
1205
  al.add_tag(tv)
1206
- ds.where(:second_tag=>[tv, tu]).all.should == [@artist, ar]
1207
- ds.exclude(:second_tag=>[tv, tu]).all.should == []
1206
+ ds.where(:second_tag=>[tv, tu]).all.must_equal [@artist, ar]
1207
+ ds.exclude(:second_tag=>[tv, tu]).all.must_equal []
1208
1208
  end
1209
1209
 
1210
- specify "dataset associations with limited one_through_many associations should work correctly" do
1210
+ it "dataset associations with limited one_through_many associations should work correctly" do
1211
1211
  Artist.one_through_many :first_tag, {:clone=>:first_tag}.merge(@els)
1212
1212
  Artist.one_through_many :second_tag, {:clone=>:second_tag}.merge(@els) if @els[:eager_limit_strategy] != :distinct_on
1213
1213
  Artist.one_through_many :last_tag, {:clone=>:last_tag}.merge(@els)
@@ -1218,31 +1218,31 @@ shared_examples_for "filter by associations singular association limit strategie
1218
1218
  al.add_tag(tu)
1219
1219
  ds = Artist.order(:name)
1220
1220
 
1221
- ds.where(@artist.pk_hash).first_tags.all.should == [@tag]
1222
- ds.where(@artist.pk_hash).second_tags.all.should == [tu]
1223
- ds.where(@artist.pk_hash).last_tags.all.should == [tv]
1224
- ds.where(ar.pk_hash).first_tags.all.should == [tu]
1225
- ds.where(ar.pk_hash).second_tags.all.should == []
1226
- ds.where(ar.pk_hash).last_tags.all.should == [tu]
1221
+ ds.where(@artist.pk_hash).first_tags.all.must_equal [@tag]
1222
+ ds.where(@artist.pk_hash).second_tags.all.must_equal [tu]
1223
+ ds.where(@artist.pk_hash).last_tags.all.must_equal [tv]
1224
+ ds.where(ar.pk_hash).first_tags.all.must_equal [tu]
1225
+ ds.where(ar.pk_hash).second_tags.all.must_equal []
1226
+ ds.where(ar.pk_hash).last_tags.all.must_equal [tu]
1227
1227
 
1228
1228
  Artist.one_through_many :first_tag, :clone=>:first_tag do |ads| ads.where(:tags__name=>tu.name) end
1229
1229
  Artist.one_through_many :second_tag, :clone=>:second_tag do |ads| ads.where(:tags__name=>[tu.name, tv.name]) end
1230
1230
 
1231
- ds.where(@artist.pk_hash).first_tags.all.should == [tu]
1232
- ds.where(@artist.pk_hash).second_tags.all.should == [tv]
1233
- ds.where(ar.pk_hash).first_tags.all.should == [tu]
1234
- ds.where(ar.pk_hash).second_tags.all.should == []
1231
+ ds.where(@artist.pk_hash).first_tags.all.must_equal [tu]
1232
+ ds.where(@artist.pk_hash).second_tags.all.must_equal [tv]
1233
+ ds.where(ar.pk_hash).first_tags.all.must_equal [tu]
1234
+ ds.where(ar.pk_hash).second_tags.all.must_equal []
1235
1235
 
1236
1236
  al.add_tag(tv)
1237
- ds.where(@artist.pk_hash).first_tags.all.should == [tu]
1238
- ds.where(@artist.pk_hash).second_tags.all.should == [tv]
1239
- ds.where(ar.pk_hash).first_tags.all.should == [tu]
1240
- ds.where(ar.pk_hash).second_tags.all.should == [tv]
1237
+ ds.where(@artist.pk_hash).first_tags.all.must_equal [tu]
1238
+ ds.where(@artist.pk_hash).second_tags.all.must_equal [tv]
1239
+ ds.where(ar.pk_hash).first_tags.all.must_equal [tu]
1240
+ ds.where(ar.pk_hash).second_tags.all.must_equal [tv]
1241
1241
  end
1242
1242
  end
1243
1243
 
1244
- shared_examples_for "filter by associations one_to_many limit strategies" do
1245
- specify "filter by associations with limited one_to_many associations should work correctly" do
1244
+ FilterByAssociationsOneToManyLimitStrategies = shared_description do
1245
+ it "filter by associations with limited one_to_many associations should work correctly" do
1246
1246
  Artist.one_to_many :first_two_albums, {:clone=>:first_two_albums}.merge(@els)
1247
1247
  Artist.one_to_many :second_two_albums, {:clone=>:second_two_albums}.merge(@els)
1248
1248
  Artist.one_to_many :not_first_albums, {:clone=>:not_first_albums}.merge(@els)
@@ -1253,12 +1253,12 @@ shared_examples_for "filter by associations one_to_many limit strategies" do
1253
1253
  ar = @pr.call[1]
1254
1254
  ds = Artist.order(:name)
1255
1255
 
1256
- ds.where(:first_two_albums=>@album).all.should == [@artist]
1257
- ds.where(:first_two_albums=>middle_album).all.should == [@artist]
1258
- ds.where(:first_two_albums=>diff_album).all.should == []
1259
- ds.exclude(:first_two_albums=>@album).all.should == [ar]
1260
- ds.exclude(:first_two_albums=>middle_album).all.should == [ar]
1261
- ds.exclude(:first_two_albums=>diff_album).all.should == [@artist, ar]
1256
+ ds.where(:first_two_albums=>@album).all.must_equal [@artist]
1257
+ ds.where(:first_two_albums=>middle_album).all.must_equal [@artist]
1258
+ ds.where(:first_two_albums=>diff_album).all.must_equal []
1259
+ ds.exclude(:first_two_albums=>@album).all.must_equal [ar]
1260
+ ds.exclude(:first_two_albums=>middle_album).all.must_equal [ar]
1261
+ ds.exclude(:first_two_albums=>diff_album).all.must_equal [@artist, ar]
1262
1262
 
1263
1263
  assocs = if @els[:eager_limit_strategy] != :correlated_subquery || Album.dataset.supports_offsets_in_correlated_subqueries?
1264
1264
  [:second_two_albums, :not_first_albums, :last_two_albums]
@@ -1267,26 +1267,26 @@ shared_examples_for "filter by associations one_to_many limit strategies" do
1267
1267
  end
1268
1268
 
1269
1269
  assocs.each do |a|
1270
- ds.where(a=>@album).all.should == []
1271
- ds.where(a=>middle_album).all.should == [@artist]
1272
- ds.where(a=>diff_album).all.should == [@artist]
1273
- ds.exclude(a=>@album).all.should == [@artist, ar]
1274
- ds.exclude(a=>middle_album).all.should == [ar]
1275
- ds.exclude(a=>diff_album).all.should == [ar]
1270
+ ds.where(a=>@album).all.must_equal []
1271
+ ds.where(a=>middle_album).all.must_equal [@artist]
1272
+ ds.where(a=>diff_album).all.must_equal [@artist]
1273
+ ds.exclude(a=>@album).all.must_equal [@artist, ar]
1274
+ ds.exclude(a=>middle_album).all.must_equal [ar]
1275
+ ds.exclude(a=>diff_album).all.must_equal [ar]
1276
1276
  end
1277
1277
 
1278
1278
  Artist.one_to_one :first_two_albums, :clone=>:first_two_albums do |ads| ads.where(:albums__name=>diff_album.name) end
1279
1279
  ar.add_album(diff_album)
1280
- ds.where(:first_two_albums=>[@album, diff_album]).all.should == [ar]
1281
- ds.exclude(:first_two_albums=>[@album, diff_album]).all.should == [@artist]
1280
+ ds.where(:first_two_albums=>[@album, diff_album]).all.must_equal [ar]
1281
+ ds.exclude(:first_two_albums=>[@album, diff_album]).all.must_equal [@artist]
1282
1282
  end
1283
1283
  end
1284
1284
 
1285
- shared_examples_for "filter by associations limit strategies" do
1286
- it_should_behave_like "filter by associations singular association limit strategies"
1287
- it_should_behave_like "filter by associations one_to_many limit strategies"
1285
+ FilterByAssociationsLimitStrategies = shared_description do
1286
+ include FilterByAssociationsSingularLimitStrategies
1287
+ include FilterByAssociationsOneToManyLimitStrategies
1288
1288
 
1289
- specify "dataset associations with limited one_to_many associations should work correctly" do
1289
+ it "dataset associations with limited one_to_many associations should work correctly" do
1290
1290
  Artist.one_to_many :first_two_albums, {:clone=>:first_two_albums}.merge(@els)
1291
1291
  Artist.one_to_many :second_two_albums, {:clone=>:second_two_albums}.merge(@els)
1292
1292
  Artist.one_to_many :not_first_albums, {:clone=>:not_first_albums}.merge(@els)
@@ -1297,22 +1297,22 @@ shared_examples_for "filter by associations limit strategies" do
1297
1297
  ar = @pr.call[1]
1298
1298
  ds = Artist.order(:name)
1299
1299
 
1300
- ds.where(@artist.pk_hash).first_two_albums.all.should == [@album, middle_album]
1301
- ds.where(@artist.pk_hash).second_two_albums.all.should == [middle_album, diff_album]
1302
- ds.where(@artist.pk_hash).not_first_albums.all.should == [middle_album, diff_album]
1303
- ds.where(@artist.pk_hash).last_two_albums.all.should == [diff_album, middle_album]
1304
- ds.where(ar.pk_hash).first_two_albums.all.should == []
1305
- ds.where(ar.pk_hash).second_two_albums.all.should == []
1306
- ds.where(ar.pk_hash).not_first_albums.all.should == []
1307
- ds.where(ar.pk_hash).last_two_albums.all.should == []
1300
+ ds.where(@artist.pk_hash).first_two_albums.all.must_equal [@album, middle_album]
1301
+ ds.where(@artist.pk_hash).second_two_albums.all.must_equal [middle_album, diff_album]
1302
+ ds.where(@artist.pk_hash).not_first_albums.all.must_equal [middle_album, diff_album]
1303
+ ds.where(@artist.pk_hash).last_two_albums.all.must_equal [diff_album, middle_album]
1304
+ ds.where(ar.pk_hash).first_two_albums.all.must_equal []
1305
+ ds.where(ar.pk_hash).second_two_albums.all.must_equal []
1306
+ ds.where(ar.pk_hash).not_first_albums.all.must_equal []
1307
+ ds.where(ar.pk_hash).last_two_albums.all.must_equal []
1308
1308
 
1309
1309
  Artist.one_to_one :first_two_albums, :clone=>:first_two_albums do |ads| ads.where(:albums__name=>[diff_album.name, middle_album.name]) end
1310
1310
  ar.add_album(diff_album)
1311
- ds.where(@artist.pk_hash).first_two_albums.all.should == [middle_album]
1312
- ds.where(ar.pk_hash).first_two_albums.all.should == [diff_album]
1311
+ ds.where(@artist.pk_hash).first_two_albums.all.must_equal [middle_album]
1312
+ ds.where(ar.pk_hash).first_two_albums.all.must_equal [diff_album]
1313
1313
  end
1314
1314
 
1315
- specify "filter by associations with limited many_to_many associations should work correctly" do
1315
+ it "filter by associations with limited many_to_many associations should work correctly" do
1316
1316
  Album.send :many_to_many, :first_two_tags, {:clone=>:first_two_tags}.merge(@els)
1317
1317
  Album.send :many_to_many, :second_two_tags, {:clone=>:second_two_tags}.merge(@els)
1318
1318
  Album.send :many_to_many, :not_first_tags, {:clone=>:not_first_tags}.merge(@els)
@@ -1322,46 +1322,46 @@ shared_examples_for "filter by associations limit strategies" do
1322
1322
  al.add_tag(tu)
1323
1323
  ds = Album.order(:name)
1324
1324
 
1325
- ds.where(:first_two_tags=>@tag).all.should == [@album]
1326
- ds.where(:first_two_tags=>tu).all.should == [@album, al]
1327
- ds.where(:first_two_tags=>tv).all.should == []
1328
- ds.exclude(:first_two_tags=>@tag).all.should == [al]
1329
- ds.exclude(:first_two_tags=>tu).all.should == []
1330
- ds.exclude(:first_two_tags=>tv).all.should == [@album, al]
1331
-
1332
- ds.where(:second_two_tags=>@tag).all.should == []
1333
- ds.where(:second_two_tags=>tu).all.should == [@album]
1334
- ds.where(:second_two_tags=>tv).all.should == [@album]
1335
- ds.exclude(:second_two_tags=>@tag).all.should == [@album, al]
1336
- ds.exclude(:second_two_tags=>tu).all.should == [al]
1337
- ds.exclude(:second_two_tags=>tv).all.should == [al]
1338
-
1339
- ds.where(:not_first_tags=>@tag).all.should == []
1340
- ds.where(:not_first_tags=>tu).all.should == [@album]
1341
- ds.where(:not_first_tags=>tv).all.should == [@album]
1342
- ds.exclude(:not_first_tags=>@tag).all.should == [@album, al]
1343
- ds.exclude(:not_first_tags=>tu).all.should == [al]
1344
- ds.exclude(:not_first_tags=>tv).all.should == [al]
1345
-
1346
- ds.where(:last_two_tags=>@tag).all.should == []
1347
- ds.where(:last_two_tags=>tu).all.should == [@album, al]
1348
- ds.where(:last_two_tags=>tv).all.should == [@album]
1349
- ds.exclude(:last_two_tags=>@tag).all.should == [@album, al]
1350
- ds.exclude(:last_two_tags=>tu).all.should == []
1351
- ds.exclude(:last_two_tags=>tv).all.should == [al]
1325
+ ds.where(:first_two_tags=>@tag).all.must_equal [@album]
1326
+ ds.where(:first_two_tags=>tu).all.must_equal [@album, al]
1327
+ ds.where(:first_two_tags=>tv).all.must_equal []
1328
+ ds.exclude(:first_two_tags=>@tag).all.must_equal [al]
1329
+ ds.exclude(:first_two_tags=>tu).all.must_equal []
1330
+ ds.exclude(:first_two_tags=>tv).all.must_equal [@album, al]
1331
+
1332
+ ds.where(:second_two_tags=>@tag).all.must_equal []
1333
+ ds.where(:second_two_tags=>tu).all.must_equal [@album]
1334
+ ds.where(:second_two_tags=>tv).all.must_equal [@album]
1335
+ ds.exclude(:second_two_tags=>@tag).all.must_equal [@album, al]
1336
+ ds.exclude(:second_two_tags=>tu).all.must_equal [al]
1337
+ ds.exclude(:second_two_tags=>tv).all.must_equal [al]
1338
+
1339
+ ds.where(:not_first_tags=>@tag).all.must_equal []
1340
+ ds.where(:not_first_tags=>tu).all.must_equal [@album]
1341
+ ds.where(:not_first_tags=>tv).all.must_equal [@album]
1342
+ ds.exclude(:not_first_tags=>@tag).all.must_equal [@album, al]
1343
+ ds.exclude(:not_first_tags=>tu).all.must_equal [al]
1344
+ ds.exclude(:not_first_tags=>tv).all.must_equal [al]
1345
+
1346
+ ds.where(:last_two_tags=>@tag).all.must_equal []
1347
+ ds.where(:last_two_tags=>tu).all.must_equal [@album, al]
1348
+ ds.where(:last_two_tags=>tv).all.must_equal [@album]
1349
+ ds.exclude(:last_two_tags=>@tag).all.must_equal [@album, al]
1350
+ ds.exclude(:last_two_tags=>tu).all.must_equal []
1351
+ ds.exclude(:last_two_tags=>tv).all.must_equal [al]
1352
1352
 
1353
1353
  Album.many_to_many :first_two_tags, :clone=>:first_two_tags do |ads| ads.where(:tags__name=>tu.name) end
1354
1354
  Album.many_to_many :second_two_tags, :clone=>:second_two_tags do |ads| ads.where(:tags__name=>[tu.name, tv.name]) end
1355
1355
 
1356
- ds.where(:first_two_tags=>[@tag, tu]).all.should == [@album, al]
1357
- ds.exclude(:first_two_tags=>[@tag, tu]).all.should == []
1356
+ ds.where(:first_two_tags=>[@tag, tu]).all.must_equal [@album, al]
1357
+ ds.exclude(:first_two_tags=>[@tag, tu]).all.must_equal []
1358
1358
 
1359
1359
  al.add_tag(tv)
1360
- ds.where(:second_two_tags=>[tv, tu]).all.should == [@album, al]
1361
- ds.exclude(:second_two_tags=>[tv, tu]).all.should == []
1360
+ ds.where(:second_two_tags=>[tv, tu]).all.must_equal [@album, al]
1361
+ ds.exclude(:second_two_tags=>[tv, tu]).all.must_equal []
1362
1362
  end
1363
1363
 
1364
- specify "dataset associations with limited many_to_many associations should work correctly" do
1364
+ it "dataset associations with limited many_to_many associations should work correctly" do
1365
1365
  Album.send :many_to_many, :first_two_tags, {:clone=>:first_two_tags}.merge(@els)
1366
1366
  Album.send :many_to_many, :second_two_tags, {:clone=>:second_two_tags}.merge(@els)
1367
1367
  Album.send :many_to_many, :not_first_tags, {:clone=>:not_first_tags}.merge(@els)
@@ -1371,31 +1371,31 @@ shared_examples_for "filter by associations limit strategies" do
1371
1371
  al.add_tag(tu)
1372
1372
  ds = Album.order(:name)
1373
1373
 
1374
- ds.where(@album.pk_hash).first_two_tags.all.should == [@tag, tu]
1375
- ds.where(@album.pk_hash).second_two_tags.all.should == [tu, tv]
1376
- ds.where(@album.pk_hash).not_first_tags.all.should == [tu, tv]
1377
- ds.where(@album.pk_hash).last_two_tags.all.should == [tv, tu]
1378
- ds.where(al.pk_hash).first_two_tags.all.should == [tu]
1379
- ds.where(al.pk_hash).second_two_tags.all.should == []
1380
- ds.where(al.pk_hash).not_first_tags.all.should == []
1381
- ds.where(al.pk_hash).last_two_tags.all.should == [tu]
1374
+ ds.where(@album.pk_hash).first_two_tags.all.must_equal [@tag, tu]
1375
+ ds.where(@album.pk_hash).second_two_tags.all.must_equal [tu, tv]
1376
+ ds.where(@album.pk_hash).not_first_tags.all.must_equal [tu, tv]
1377
+ ds.where(@album.pk_hash).last_two_tags.all.must_equal [tv, tu]
1378
+ ds.where(al.pk_hash).first_two_tags.all.must_equal [tu]
1379
+ ds.where(al.pk_hash).second_two_tags.all.must_equal []
1380
+ ds.where(al.pk_hash).not_first_tags.all.must_equal []
1381
+ ds.where(al.pk_hash).last_two_tags.all.must_equal [tu]
1382
1382
 
1383
1383
  Album.many_to_many :first_two_tags, :clone=>:first_two_tags do |ads| ads.where(:tags__name=>tu.name) end
1384
1384
  Album.many_to_many :second_two_tags, :clone=>:second_two_tags do |ads| ads.where(:tags__name=>[tu.name, tv.name]) end
1385
1385
 
1386
- ds.where(@album.pk_hash).first_two_tags.all.should == [tu]
1387
- ds.where(@album.pk_hash).second_two_tags.all.should == [tv]
1388
- ds.where(al.pk_hash).first_two_tags.all.should == [tu]
1389
- ds.where(al.pk_hash).second_two_tags.all.should == []
1386
+ ds.where(@album.pk_hash).first_two_tags.all.must_equal [tu]
1387
+ ds.where(@album.pk_hash).second_two_tags.all.must_equal [tv]
1388
+ ds.where(al.pk_hash).first_two_tags.all.must_equal [tu]
1389
+ ds.where(al.pk_hash).second_two_tags.all.must_equal []
1390
1390
 
1391
1391
  al.add_tag(tv)
1392
- ds.where(@album.pk_hash).first_two_tags.all.should == [tu]
1393
- ds.where(@album.pk_hash).second_two_tags.all.should == [tv]
1394
- ds.where(al.pk_hash).first_two_tags.all.should == [tu]
1395
- ds.where(al.pk_hash).second_two_tags.all.should == [tv]
1392
+ ds.where(@album.pk_hash).first_two_tags.all.must_equal [tu]
1393
+ ds.where(@album.pk_hash).second_two_tags.all.must_equal [tv]
1394
+ ds.where(al.pk_hash).first_two_tags.all.must_equal [tu]
1395
+ ds.where(al.pk_hash).second_two_tags.all.must_equal [tv]
1396
1396
  end
1397
1397
 
1398
- specify "filter by associations with limited many_through_many associations should work correctly" do
1398
+ it "filter by associations with limited many_through_many associations should work correctly" do
1399
1399
  Artist.many_through_many :first_two_tags, {:clone=>:first_two_tags}.merge(@els)
1400
1400
  Artist.many_through_many :second_two_tags, {:clone=>:second_two_tags}.merge(@els)
1401
1401
  Artist.many_through_many :not_first_tags, {:clone=>:not_first_tags}.merge(@els)
@@ -1407,46 +1407,46 @@ shared_examples_for "filter by associations limit strategies" do
1407
1407
  al.add_tag(tu)
1408
1408
  ds = Artist.order(:name)
1409
1409
 
1410
- ds.where(:first_two_tags=>@tag).all.should == [@artist]
1411
- ds.where(:first_two_tags=>tu).all.should == [@artist, ar]
1412
- ds.where(:first_two_tags=>tv).all.should == []
1413
- ds.exclude(:first_two_tags=>@tag).all.should == [ar]
1414
- ds.exclude(:first_two_tags=>tu).all.should == []
1415
- ds.exclude(:first_two_tags=>tv).all.should == [@artist, ar]
1416
-
1417
- ds.where(:second_two_tags=>@tag).all.should == []
1418
- ds.where(:second_two_tags=>tu).all.should == [@artist]
1419
- ds.where(:second_two_tags=>tv).all.should == [@artist]
1420
- ds.exclude(:second_two_tags=>@tag).all.should == [@artist, ar]
1421
- ds.exclude(:second_two_tags=>tu).all.should == [ar]
1422
- ds.exclude(:second_two_tags=>tv).all.should == [ar]
1423
-
1424
- ds.where(:not_first_tags=>@tag).all.should == []
1425
- ds.where(:not_first_tags=>tu).all.should == [@artist]
1426
- ds.where(:not_first_tags=>tv).all.should == [@artist]
1427
- ds.exclude(:not_first_tags=>@tag).all.should == [@artist, ar]
1428
- ds.exclude(:not_first_tags=>tu).all.should == [ar]
1429
- ds.exclude(:not_first_tags=>tv).all.should == [ar]
1430
-
1431
- ds.where(:last_two_tags=>@tag).all.should == []
1432
- ds.where(:last_two_tags=>tu).all.should == [@artist, ar]
1433
- ds.where(:last_two_tags=>tv).all.should == [@artist]
1434
- ds.exclude(:last_two_tags=>@tag).all.should == [@artist, ar]
1435
- ds.exclude(:last_two_tags=>tu).all.should == []
1436
- ds.exclude(:last_two_tags=>tv).all.should == [ar]
1410
+ ds.where(:first_two_tags=>@tag).all.must_equal [@artist]
1411
+ ds.where(:first_two_tags=>tu).all.must_equal [@artist, ar]
1412
+ ds.where(:first_two_tags=>tv).all.must_equal []
1413
+ ds.exclude(:first_two_tags=>@tag).all.must_equal [ar]
1414
+ ds.exclude(:first_two_tags=>tu).all.must_equal []
1415
+ ds.exclude(:first_two_tags=>tv).all.must_equal [@artist, ar]
1416
+
1417
+ ds.where(:second_two_tags=>@tag).all.must_equal []
1418
+ ds.where(:second_two_tags=>tu).all.must_equal [@artist]
1419
+ ds.where(:second_two_tags=>tv).all.must_equal [@artist]
1420
+ ds.exclude(:second_two_tags=>@tag).all.must_equal [@artist, ar]
1421
+ ds.exclude(:second_two_tags=>tu).all.must_equal [ar]
1422
+ ds.exclude(:second_two_tags=>tv).all.must_equal [ar]
1423
+
1424
+ ds.where(:not_first_tags=>@tag).all.must_equal []
1425
+ ds.where(:not_first_tags=>tu).all.must_equal [@artist]
1426
+ ds.where(:not_first_tags=>tv).all.must_equal [@artist]
1427
+ ds.exclude(:not_first_tags=>@tag).all.must_equal [@artist, ar]
1428
+ ds.exclude(:not_first_tags=>tu).all.must_equal [ar]
1429
+ ds.exclude(:not_first_tags=>tv).all.must_equal [ar]
1430
+
1431
+ ds.where(:last_two_tags=>@tag).all.must_equal []
1432
+ ds.where(:last_two_tags=>tu).all.must_equal [@artist, ar]
1433
+ ds.where(:last_two_tags=>tv).all.must_equal [@artist]
1434
+ ds.exclude(:last_two_tags=>@tag).all.must_equal [@artist, ar]
1435
+ ds.exclude(:last_two_tags=>tu).all.must_equal []
1436
+ ds.exclude(:last_two_tags=>tv).all.must_equal [ar]
1437
1437
 
1438
1438
  Artist.many_through_many :first_two_tags, :clone=>:first_tag do |ads| ads.where(:tags__name=>tu.name) end
1439
1439
  Artist.many_through_many :second_two_tags, :clone=>:first_tag do |ads| ads.where(:tags__name=>[tv.name, tu.name]) end
1440
1440
 
1441
- ds.where(:first_two_tags=>[@tag, tu]).all.should == [@artist, ar]
1442
- ds.exclude(:first_two_tags=>[@tag, tu]).all.should == []
1441
+ ds.where(:first_two_tags=>[@tag, tu]).all.must_equal [@artist, ar]
1442
+ ds.exclude(:first_two_tags=>[@tag, tu]).all.must_equal []
1443
1443
 
1444
1444
  al.add_tag(tv)
1445
- ds.where(:second_two_tags=>[tv, tu]).all.should == [@artist, ar]
1446
- ds.exclude(:second_two_tags=>[tv, tu]).all.should == []
1445
+ ds.where(:second_two_tags=>[tv, tu]).all.must_equal [@artist, ar]
1446
+ ds.exclude(:second_two_tags=>[tv, tu]).all.must_equal []
1447
1447
  end
1448
1448
 
1449
- specify "dataset associations with limited many_through_many associations should work correctly" do
1449
+ it "dataset associations with limited many_through_many associations should work correctly" do
1450
1450
  Artist.many_through_many :first_two_tags, {:clone=>:first_two_tags}.merge(@els)
1451
1451
  Artist.many_through_many :second_two_tags, {:clone=>:second_two_tags}.merge(@els)
1452
1452
  Artist.many_through_many :not_first_tags, {:clone=>:not_first_tags}.merge(@els)
@@ -1458,42 +1458,52 @@ shared_examples_for "filter by associations limit strategies" do
1458
1458
  al.add_tag(tu)
1459
1459
  ds = Artist.order(:name)
1460
1460
 
1461
- ds.where(@artist.pk_hash).first_two_tags.all.should == [@tag, tu]
1462
- ds.where(@artist.pk_hash).second_two_tags.all.should == [tu, tv]
1463
- ds.where(@artist.pk_hash).not_first_tags.all.should == [tu, tv]
1464
- ds.where(@artist.pk_hash).last_two_tags.all.should == [tv, tu]
1465
- ds.where(ar.pk_hash).first_two_tags.all.should == [tu]
1466
- ds.where(ar.pk_hash).second_two_tags.all.should == []
1467
- ds.where(ar.pk_hash).not_first_tags.all.should == []
1468
- ds.where(ar.pk_hash).last_two_tags.all.should == [tu]
1461
+ ds.where(@artist.pk_hash).first_two_tags.all.must_equal [@tag, tu]
1462
+ ds.where(@artist.pk_hash).second_two_tags.all.must_equal [tu, tv]
1463
+ ds.where(@artist.pk_hash).not_first_tags.all.must_equal [tu, tv]
1464
+ ds.where(@artist.pk_hash).last_two_tags.all.must_equal [tv, tu]
1465
+ ds.where(ar.pk_hash).first_two_tags.all.must_equal [tu]
1466
+ ds.where(ar.pk_hash).second_two_tags.all.must_equal []
1467
+ ds.where(ar.pk_hash).not_first_tags.all.must_equal []
1468
+ ds.where(ar.pk_hash).last_two_tags.all.must_equal [tu]
1469
1469
 
1470
1470
  Artist.many_through_many :first_two_tags, :clone=>:first_two_tags do |ads| ads.where(:tags__name=>tu.name) end
1471
1471
  Artist.many_through_many :second_two_tags, :clone=>:second_two_tags do |ads| ads.where(:tags__name=>[tu.name, tv.name]) end
1472
1472
 
1473
- ds.where(@artist.pk_hash).first_two_tags.all.should == [tu]
1474
- ds.where(@artist.pk_hash).second_two_tags.all.should == [tv]
1475
- ds.where(ar.pk_hash).first_two_tags.all.should == [tu]
1476
- ds.where(ar.pk_hash).second_two_tags.all.should == []
1473
+ ds.where(@artist.pk_hash).first_two_tags.all.must_equal [tu]
1474
+ ds.where(@artist.pk_hash).second_two_tags.all.must_equal [tv]
1475
+ ds.where(ar.pk_hash).first_two_tags.all.must_equal [tu]
1476
+ ds.where(ar.pk_hash).second_two_tags.all.must_equal []
1477
1477
 
1478
1478
  al.add_tag(tv)
1479
- ds.where(@artist.pk_hash).first_two_tags.all.should == [tu]
1480
- ds.where(@artist.pk_hash).second_two_tags.all.should == [tv]
1481
- ds.where(ar.pk_hash).first_two_tags.all.should == [tu]
1482
- ds.where(ar.pk_hash).second_two_tags.all.should == [tv]
1479
+ ds.where(@artist.pk_hash).first_two_tags.all.must_equal [tu]
1480
+ ds.where(@artist.pk_hash).second_two_tags.all.must_equal [tv]
1481
+ ds.where(ar.pk_hash).first_two_tags.all.must_equal [tu]
1482
+ ds.where(ar.pk_hash).second_two_tags.all.must_equal [tv]
1483
1483
  end
1484
1484
  end
1485
1485
 
1486
- shared_examples_for "basic regular and composite key associations" do
1487
- specify "should return no objects if none are associated" do
1488
- @album.artist.should == nil
1489
- @artist.first_album.should == nil
1490
- @artist.albums.should == []
1491
- @album.tags.should == []
1492
- @album.alias_tags.should == []
1493
- @tag.albums.should == []
1486
+ BasicRegularAndCompositeKeyAssociations = shared_description do
1487
+ describe "when filtering/excluding by associations" do
1488
+ before do
1489
+ @Artist = Artist.dataset
1490
+ @Album = Album.dataset
1491
+ @Tag = Tag.dataset
1492
+ end
1493
+
1494
+ include FilterByAssociations
1495
+ end
1496
+
1497
+ it "should return no objects if none are associated" do
1498
+ @album.artist.must_equal nil
1499
+ @artist.first_album.must_equal nil
1500
+ @artist.albums.must_equal []
1501
+ @album.tags.must_equal []
1502
+ @album.alias_tags.must_equal []
1503
+ @tag.albums.must_equal []
1494
1504
  end
1495
1505
 
1496
- specify "should have add and set methods work any associated objects" do
1506
+ it "should have add and set methods work any associated objects" do
1497
1507
  @album.update(:artist => @artist)
1498
1508
  @album.add_tag(@tag)
1499
1509
 
@@ -1501,15 +1511,15 @@ shared_examples_for "basic regular and composite key associations" do
1501
1511
  @artist.reload
1502
1512
  @tag.reload
1503
1513
 
1504
- @album.artist.should == @artist
1505
- @artist.first_album.should == @album
1506
- @artist.albums.should == [@album]
1507
- @album.tags.should == [@tag]
1508
- @album.alias_tags.should == [@tag]
1509
- @tag.albums.should == [@album]
1514
+ @album.artist.must_equal @artist
1515
+ @artist.first_album.must_equal @album
1516
+ @artist.albums.must_equal [@album]
1517
+ @album.tags.must_equal [@tag]
1518
+ @album.alias_tags.must_equal [@tag]
1519
+ @tag.albums.must_equal [@album]
1510
1520
  end
1511
1521
 
1512
- specify "should work correctly with prepared_statements_association plugin" do
1522
+ it "should work correctly with prepared_statements_association plugin" do
1513
1523
  @album.update(:artist => @artist)
1514
1524
  @album.add_tag(@tag)
1515
1525
 
@@ -1518,78 +1528,78 @@ shared_examples_for "basic regular and composite key associations" do
1518
1528
  @tag.reload
1519
1529
 
1520
1530
  [Tag, Album, Artist].each{|x| x.plugin :prepared_statements_associations}
1521
- @album.artist.should == @artist
1522
- @artist.first_album.should == @album
1523
- @artist.albums.should == [@album]
1524
- @album.tags.should == [@tag]
1525
- @album.alias_tags.should == [@tag]
1526
- @tag.albums.should == [@album]
1531
+ @album.artist.must_equal @artist
1532
+ @artist.first_album.must_equal @album
1533
+ @artist.albums.must_equal [@album]
1534
+ @album.tags.must_equal [@tag]
1535
+ @album.alias_tags.must_equal [@tag]
1536
+ @tag.albums.must_equal [@album]
1527
1537
  end
1528
1538
 
1529
- specify "should have working dataset associations" do
1539
+ it "should have working dataset associations" do
1530
1540
  album, artist, tag = @pr.call
1531
1541
 
1532
- Tag.albums.all.should == []
1533
- Album.artists.all.should == []
1534
- Album.tags.all.should == []
1535
- Album.alias_tags.all.should == []
1536
- Artist.albums.all.should == []
1542
+ Tag.albums.all.must_equal []
1543
+ Album.artists.all.must_equal []
1544
+ Album.tags.all.must_equal []
1545
+ Album.alias_tags.all.must_equal []
1546
+ Artist.albums.all.must_equal []
1537
1547
  unless @no_many_through_many
1538
- Album.first_tags.all.should == []
1539
- Artist.tags.all.should == []
1540
- Artist.first_tags.all.should == []
1548
+ Album.first_tags.all.must_equal []
1549
+ Artist.tags.all.must_equal []
1550
+ Artist.first_tags.all.must_equal []
1541
1551
  end
1542
- Artist.albums.tags.all.should == []
1552
+ Artist.albums.tags.all.must_equal []
1543
1553
 
1544
1554
  @album.update(:artist => @artist)
1545
1555
  @album.add_tag(@tag)
1546
1556
 
1547
- Tag.albums.all.should == [@album]
1548
- Album.artists.all.should == [@artist]
1549
- Album.tags.all.should == [@tag]
1550
- Album.alias_tags.all.should == [@tag]
1551
- Artist.albums.all.should == [@album]
1557
+ Tag.albums.all.must_equal [@album]
1558
+ Album.artists.all.must_equal [@artist]
1559
+ Album.tags.all.must_equal [@tag]
1560
+ Album.alias_tags.all.must_equal [@tag]
1561
+ Artist.albums.all.must_equal [@album]
1552
1562
  unless @no_many_through_many
1553
- Album.first_tags.all.should == [@tag]
1554
- Artist.tags.all.should == [@tag]
1555
- Artist.first_tags.all.should == [@tag]
1563
+ Album.first_tags.all.must_equal [@tag]
1564
+ Artist.tags.all.must_equal [@tag]
1565
+ Artist.first_tags.all.must_equal [@tag]
1556
1566
  end
1557
- Artist.albums.tags.all.should == [@tag]
1567
+ Artist.albums.tags.all.must_equal [@tag]
1558
1568
 
1559
1569
  album.add_tag(tag)
1560
1570
  album.update(:artist => artist)
1561
1571
 
1562
- Tag.albums.order(:name).all.should == [@album, album]
1563
- Album.artists.order(:name).all.should == [@artist, artist]
1564
- Album.tags.order(:name).all.should == [@tag, tag]
1565
- Album.alias_tags.order(:name).all.should == [@tag, tag]
1566
- Artist.albums.order(:name).all.should == [@album, album]
1572
+ Tag.albums.order(:name).all.must_equal [@album, album]
1573
+ Album.artists.order(:name).all.must_equal [@artist, artist]
1574
+ Album.tags.order(:name).all.must_equal [@tag, tag]
1575
+ Album.alias_tags.order(:name).all.must_equal [@tag, tag]
1576
+ Artist.albums.order(:name).all.must_equal [@album, album]
1567
1577
  unless @no_many_through_many
1568
- Album.first_tags.order(:name).all.should == [@tag, tag]
1569
- Artist.tags.order(:name).all.should == [@tag, tag]
1570
- Artist.first_tags.order(:name).all.should == [@tag, tag]
1578
+ Album.first_tags.order(:name).all.must_equal [@tag, tag]
1579
+ Artist.tags.order(:name).all.must_equal [@tag, tag]
1580
+ Artist.first_tags.order(:name).all.must_equal [@tag, tag]
1571
1581
  end
1572
- Artist.albums.tags.order(:name).all.should == [@tag, tag]
1582
+ Artist.albums.tags.order(:name).all.must_equal [@tag, tag]
1573
1583
 
1574
- Tag.filter(Tag.qualified_primary_key_hash(tag.pk)).albums.all.should == [album]
1575
- Album.filter(Album.qualified_primary_key_hash(album.pk)).artists.all.should == [artist]
1576
- Album.filter(Album.qualified_primary_key_hash(album.pk)).tags.all.should == [tag]
1577
- Album.filter(Album.qualified_primary_key_hash(album.pk)).alias_tags.all.should == [tag]
1578
- Artist.filter(Artist.qualified_primary_key_hash(artist.pk)).albums.all.should == [album]
1584
+ Tag.filter(Tag.qualified_primary_key_hash(tag.pk)).albums.all.must_equal [album]
1585
+ Album.filter(Album.qualified_primary_key_hash(album.pk)).artists.all.must_equal [artist]
1586
+ Album.filter(Album.qualified_primary_key_hash(album.pk)).tags.all.must_equal [tag]
1587
+ Album.filter(Album.qualified_primary_key_hash(album.pk)).alias_tags.all.must_equal [tag]
1588
+ Artist.filter(Artist.qualified_primary_key_hash(artist.pk)).albums.all.must_equal [album]
1579
1589
  unless @no_many_through_many
1580
- Album.filter(Album.qualified_primary_key_hash(album.pk)).first_tags.all.should == [tag]
1581
- Artist.filter(Artist.qualified_primary_key_hash(artist.pk)).tags.all.should == [tag]
1582
- Artist.filter(Artist.qualified_primary_key_hash(artist.pk)).first_tags.all.should == [tag]
1590
+ Album.filter(Album.qualified_primary_key_hash(album.pk)).first_tags.all.must_equal [tag]
1591
+ Artist.filter(Artist.qualified_primary_key_hash(artist.pk)).tags.all.must_equal [tag]
1592
+ Artist.filter(Artist.qualified_primary_key_hash(artist.pk)).first_tags.all.must_equal [tag]
1583
1593
  end
1584
- Artist.filter(Artist.qualified_primary_key_hash(artist.pk)).albums.tags.all.should == [tag]
1594
+ Artist.filter(Artist.qualified_primary_key_hash(artist.pk)).albums.tags.all.must_equal [tag]
1585
1595
 
1586
- Artist.filter(Artist.qualified_primary_key_hash(artist.pk)).albums.filter(Album.qualified_primary_key_hash(album.pk)).tags.all.should == [tag]
1587
- Artist.filter(Artist.qualified_primary_key_hash(@artist.pk)).albums.filter(Album.qualified_primary_key_hash(@album.pk)).tags.all.should == [@tag]
1588
- Artist.filter(Artist.qualified_primary_key_hash(@artist.pk)).albums.filter(Album.qualified_primary_key_hash(album.pk)).tags.all.should == []
1589
- Artist.filter(Artist.qualified_primary_key_hash(artist.pk)).albums.filter(Album.qualified_primary_key_hash(@album.pk)).tags.all.should == []
1596
+ Artist.filter(Artist.qualified_primary_key_hash(artist.pk)).albums.filter(Album.qualified_primary_key_hash(album.pk)).tags.all.must_equal [tag]
1597
+ Artist.filter(Artist.qualified_primary_key_hash(@artist.pk)).albums.filter(Album.qualified_primary_key_hash(@album.pk)).tags.all.must_equal [@tag]
1598
+ Artist.filter(Artist.qualified_primary_key_hash(@artist.pk)).albums.filter(Album.qualified_primary_key_hash(album.pk)).tags.all.must_equal []
1599
+ Artist.filter(Artist.qualified_primary_key_hash(artist.pk)).albums.filter(Album.qualified_primary_key_hash(@album.pk)).tags.all.must_equal []
1590
1600
  end
1591
1601
 
1592
- specify "should have remove methods work" do
1602
+ it "should have remove methods work" do
1593
1603
  @album.update(:artist => @artist)
1594
1604
  @album.add_tag(@tag)
1595
1605
 
@@ -1603,19 +1613,19 @@ shared_examples_for "basic regular and composite key associations" do
1603
1613
  @artist.reload
1604
1614
  @tag.reload
1605
1615
 
1606
- @album.artist.should == nil
1607
- @artist.albums.should == []
1608
- @album.tags.should == []
1609
- @tag.albums.should == []
1616
+ @album.artist.must_equal nil
1617
+ @artist.albums.must_equal []
1618
+ @album.tags.must_equal []
1619
+ @tag.albums.must_equal []
1610
1620
 
1611
1621
  @album.add_alias_tag(@tag)
1612
1622
  @album.remove_alias_tag(@tag)
1613
1623
 
1614
1624
  @album.reload
1615
- @album.alias_tags.should == []
1625
+ @album.alias_tags.must_equal []
1616
1626
  end
1617
1627
 
1618
- specify "should have remove_all methods work" do
1628
+ it "should have remove_all methods work" do
1619
1629
  @artist.add_album(@album)
1620
1630
  @album.add_tag(@tag)
1621
1631
 
@@ -1626,65 +1636,55 @@ shared_examples_for "basic regular and composite key associations" do
1626
1636
  @artist.reload
1627
1637
  @tag.reload
1628
1638
 
1629
- @album.artist.should == nil
1630
- @artist.albums.should == []
1631
- @album.tags.should == []
1632
- @tag.albums.should == []
1639
+ @album.artist.must_equal nil
1640
+ @artist.albums.must_equal []
1641
+ @album.tags.must_equal []
1642
+ @tag.albums.must_equal []
1633
1643
 
1634
1644
  @album.add_alias_tag(@tag)
1635
1645
  @album.remove_all_alias_tags
1636
1646
 
1637
1647
  @album.reload
1638
- @album.alias_tags.should == []
1648
+ @album.alias_tags.must_equal []
1639
1649
  end
1640
1650
 
1641
- specify "should eager load via eager correctly" do
1651
+ it "should eager load via eager correctly" do
1642
1652
  @album.update(:artist => @artist)
1643
1653
  @album.add_tag(@tag)
1644
1654
 
1645
1655
  a = Artist.eager(:albums=>[:tags, :alias_tags]).eager(:first_album).all
1646
- a.should == [@artist]
1647
- a.first.albums.should == [@album]
1648
- a.first.first_album.should == @album
1649
- a.first.albums.first.tags.should == [@tag]
1650
- a.first.albums.first.alias_tags.should == [@tag]
1656
+ a.must_equal [@artist]
1657
+ a.first.albums.must_equal [@album]
1658
+ a.first.first_album.must_equal @album
1659
+ a.first.albums.first.tags.must_equal [@tag]
1660
+ a.first.albums.first.alias_tags.must_equal [@tag]
1651
1661
 
1652
1662
  a = Tag.eager(:albums=>:artist).all
1653
- a.should == [@tag]
1654
- a.first.albums.should == [@album]
1655
- a.first.albums.first.artist.should == @artist
1663
+ a.must_equal [@tag]
1664
+ a.first.albums.must_equal [@album]
1665
+ a.first.albums.first.artist.must_equal @artist
1656
1666
  end
1657
1667
 
1658
- specify "should eager load via eager_graph correctly" do
1668
+ it "should eager load via eager_graph correctly" do
1659
1669
  @album.update(:artist => @artist)
1660
1670
  @album.add_tag(@tag)
1661
1671
 
1662
1672
  a = Artist.eager_graph(:albums=>[:tags, :alias_tags]).eager_graph(:first_album).all
1663
- a.should == [@artist]
1664
- a.first.albums.should == [@album]
1665
- a.first.first_album.should == @album
1666
- a.first.albums.first.tags.should == [@tag]
1667
- a.first.albums.first.alias_tags.should == [@tag]
1673
+ a.must_equal [@artist]
1674
+ a.first.albums.must_equal [@album]
1675
+ a.first.first_album.must_equal @album
1676
+ a.first.albums.first.tags.must_equal [@tag]
1677
+ a.first.albums.first.alias_tags.must_equal [@tag]
1668
1678
 
1669
1679
  a = Tag.eager_graph(:albums=>:artist).all
1670
- a.should == [@tag]
1671
- a.first.albums.should == [@album]
1672
- a.first.albums.first.artist.should == @artist
1673
- end
1674
-
1675
- describe "when filtering/excluding by associations" do
1676
- before do
1677
- @Artist = Artist.dataset
1678
- @Album = Album.dataset
1679
- @Tag = Tag.dataset
1680
- end
1681
-
1682
- it_should_behave_like "filtering/excluding by associations"
1680
+ a.must_equal [@tag]
1681
+ a.first.albums.must_equal [@album]
1682
+ a.first.albums.first.artist.must_equal @artist
1683
1683
  end
1684
1684
  end
1685
1685
 
1686
- shared_examples_for "regular and composite key associations" do
1687
- it_should_behave_like "basic regular and composite key associations"
1686
+ RegularAndCompositeKeyAssociations = shared_description do
1687
+ include BasicRegularAndCompositeKeyAssociations
1688
1688
 
1689
1689
  describe "when filtering/excluding by associations when joining" do
1690
1690
  def self_join(c)
@@ -1697,47 +1697,48 @@ shared_examples_for "regular and composite key associations" do
1697
1697
  @Tag = self_join(Tag)
1698
1698
  end
1699
1699
 
1700
- it_should_behave_like "filtering/excluding by associations"
1700
+ include FilterByAssociations
1701
1701
  end
1702
1702
 
1703
1703
  describe "with default/union :eager_limit_strategy" do
1704
1704
  before do
1705
1705
  @els = {}
1706
1706
  end
1707
- it_should_behave_like "eager limit strategies"
1707
+ include EagerLimitStrategies
1708
1708
  end
1709
1709
 
1710
1710
  describe "with :eager_limit_strategy=>:ruby" do
1711
1711
  before do
1712
1712
  @els = {:eager_limit_strategy=>:ruby}
1713
1713
  end
1714
- it_should_behave_like "eager limit strategies"
1715
- it_should_behave_like "eager_graph limit strategies"
1714
+ include EagerLimitStrategies
1715
+ include EagerGraphLimitStrategies
1716
1716
  end
1717
1717
 
1718
1718
  describe "with :eager_limit_strategy=>:distinct_on" do
1719
1719
  before do
1720
1720
  @els = {:eager_limit_strategy=>:distinct_on}
1721
1721
  end
1722
- it_should_behave_like "one_to_one eager limit strategies"
1723
- it_should_behave_like "one_through_one eager limit strategies"
1724
- it_should_behave_like "one_through_many eager limit strategies"
1725
- it_should_behave_like "one_to_one eager_graph limit strategies"
1726
- it_should_behave_like "one_through_one eager_graph limit strategies"
1727
- it_should_behave_like "one_through_many eager_graph limit strategies"
1728
- it_should_behave_like "filter by associations singular association limit strategies"
1722
+
1723
+ include OneToOneEagerLimitStrategies
1724
+ include OneThroughOneEagerLimitStrategies
1725
+ include OneThroughManyEagerLimitStrategies
1726
+ include OneToOneEagerGraphLimitStrategies
1727
+ include OneThroughOneEagerGraphLimitStrategies
1728
+ include OneThroughManyEagerGraphLimitStrategies
1729
+ include FilterByAssociationsSingularLimitStrategies
1729
1730
  end if DB.dataset.supports_ordered_distinct_on?
1730
1731
 
1731
1732
  describe "with :eager_limit_strategy=>:window_function" do
1732
1733
  before do
1733
1734
  @els = {:eager_limit_strategy=>:window_function}
1734
1735
  end
1735
- it_should_behave_like "eager limit strategies"
1736
- it_should_behave_like "eager_graph limit strategies"
1737
- it_should_behave_like "filter by associations limit strategies"
1736
+ include EagerLimitStrategies
1737
+ include EagerGraphLimitStrategies
1738
+ include FilterByAssociationsLimitStrategies
1738
1739
  end if DB.dataset.supports_window_functions?
1739
1740
 
1740
- specify "should work with a many_through_many association" do
1741
+ it "should work with a many_through_many association" do
1741
1742
  @album.update(:artist => @artist)
1742
1743
  @album.add_tag(@tag)
1743
1744
 
@@ -1745,28 +1746,28 @@ shared_examples_for "regular and composite key associations" do
1745
1746
  @artist.reload
1746
1747
  @tag.reload
1747
1748
 
1748
- @album.tags.should == [@tag]
1749
+ @album.tags.must_equal [@tag]
1749
1750
 
1750
1751
  a = Artist.eager(:tags).all
1751
- a.should == [@artist]
1752
- a.first.tags.should == [@tag]
1752
+ a.must_equal [@artist]
1753
+ a.first.tags.must_equal [@tag]
1753
1754
 
1754
1755
  a = Artist.eager_graph(:tags).all
1755
- a.should == [@artist]
1756
- a.first.tags.should == [@tag]
1756
+ a.must_equal [@artist]
1757
+ a.first.tags.must_equal [@tag]
1757
1758
 
1758
1759
  a = Album.eager(:artist=>:tags).all
1759
- a.should == [@album]
1760
- a.first.artist.should == @artist
1761
- a.first.artist.tags.should == [@tag]
1760
+ a.must_equal [@album]
1761
+ a.first.artist.must_equal @artist
1762
+ a.first.artist.tags.must_equal [@tag]
1762
1763
 
1763
1764
  a = Album.eager_graph(:artist=>:tags).all
1764
- a.should == [@album]
1765
- a.first.artist.should == @artist
1766
- a.first.artist.tags.should == [@tag]
1765
+ a.must_equal [@album]
1766
+ a.first.artist.must_equal @artist
1767
+ a.first.artist.tags.must_equal [@tag]
1767
1768
  end
1768
1769
 
1769
- specify "should work with a one_through_many association" do
1770
+ it "should work with a one_through_many association" do
1770
1771
  @album.update(:artist => @artist)
1771
1772
  @album.add_tag(@tag)
1772
1773
 
@@ -1774,25 +1775,25 @@ shared_examples_for "regular and composite key associations" do
1774
1775
  @artist.reload
1775
1776
  @tag.reload
1776
1777
 
1777
- @album.tags.should == [@tag]
1778
+ @album.tags.must_equal [@tag]
1778
1779
 
1779
1780
  a = Artist.eager(:first_tag).all
1780
- a.should == [@artist]
1781
- a.first.first_tag.should == @tag
1781
+ a.must_equal [@artist]
1782
+ a.first.first_tag.must_equal @tag
1782
1783
 
1783
1784
  a = Artist.eager_graph(:first_tag).all
1784
- a.should == [@artist]
1785
- a.first.first_tag.should == @tag
1785
+ a.must_equal [@artist]
1786
+ a.first.first_tag.must_equal @tag
1786
1787
 
1787
1788
  a = Album.eager(:artist=>:first_tag).all
1788
- a.should == [@album]
1789
- a.first.artist.should == @artist
1790
- a.first.artist.first_tag.should == @tag
1789
+ a.must_equal [@album]
1790
+ a.first.artist.must_equal @artist
1791
+ a.first.artist.first_tag.must_equal @tag
1791
1792
 
1792
1793
  a = Album.eager_graph(:artist=>:first_tag).all
1793
- a.should == [@album]
1794
- a.first.artist.should == @artist
1795
- a.first.artist.first_tag.should == @tag
1794
+ a.must_equal [@album]
1795
+ a.first.artist.must_equal @artist
1796
+ a.first.artist.first_tag.must_equal @tag
1796
1797
  end
1797
1798
  end
1798
1799
 
@@ -1883,52 +1884,52 @@ describe "Sequel::Model Simple Associations" do
1883
1884
  @db.drop_table?(:albums_tags, :tags, :albums, :artists)
1884
1885
  end
1885
1886
 
1886
- it_should_behave_like "regular and composite key associations"
1887
+ include RegularAndCompositeKeyAssociations
1887
1888
 
1888
1889
  describe "with :correlated_subquery limit strategy" do
1889
1890
  before do
1890
1891
  @els = {:eager_limit_strategy=>:correlated_subquery}
1891
1892
  end
1892
1893
 
1893
- it_should_behave_like "one_to_one eager_graph limit strategies"
1894
- it_should_behave_like "one_to_many eager_graph limit strategies"
1895
- it_should_behave_like "filter by associations one_to_one limit strategies"
1896
- it_should_behave_like "filter by associations one_to_many limit strategies"
1894
+ include OneToOneEagerGraphLimitStrategies
1895
+ include OneToManyEagerGraphLimitStrategies
1896
+ include FilterByAssociationsOneToOneLimitStrategies
1897
+ include FilterByAssociationsOneToManyLimitStrategies
1897
1898
  end if DB.dataset.supports_limits_in_correlated_subqueries?
1898
1899
 
1899
- specify "should handle eager loading limited associations for many objects" do
1900
+ it "should handle eager loading limited associations for many objects" do
1900
1901
  @db[:artists].import([:name], (1..99).map{|i| [i.to_s]})
1901
1902
  artists = Artist.eager(:albums).all
1902
- artists.length.should == 100
1903
- artists.each{|a| a.albums.should == []}
1903
+ artists.length.must_equal 100
1904
+ artists.each{|a| a.albums.must_equal []}
1904
1905
  artists = Artist.eager(:first_two_albums).all
1905
- artists.length.should == 100
1906
- artists.each{|a| a.first_two_albums.should == []}
1906
+ artists.length.must_equal 100
1907
+ artists.each{|a| a.first_two_albums.must_equal []}
1907
1908
  @db[:albums].insert([:artist_id], @db[:artists].select(:id))
1908
1909
  artists = Artist.eager(:albums).all
1909
- artists.length.should == 100
1910
- artists.each{|a| a.albums.length.should == 1}
1910
+ artists.length.must_equal 100
1911
+ artists.each{|a| a.albums.length.must_equal 1}
1911
1912
  artists = Artist.eager(:first_two_albums).all
1912
- artists.length.should == 100
1913
- artists.each{|a| a.first_two_albums.length.should == 1}
1913
+ artists.length.must_equal 100
1914
+ artists.each{|a| a.first_two_albums.length.must_equal 1}
1914
1915
  end
1915
1916
 
1916
- specify "should handle many_to_one associations with same name as :key" do
1917
+ it "should handle many_to_one associations with same name as :key" do
1917
1918
  Album.def_column_alias(:artist_id_id, :artist_id)
1918
1919
  Album.many_to_one :artist_id, :key_column =>:artist_id, :class=>Artist
1919
1920
  @album.update(:artist_id_id => @artist.id)
1920
- @album.artist_id.should == @artist
1921
+ @album.artist_id.must_equal @artist
1921
1922
 
1922
1923
  as = Album.eager(:artist_id).all
1923
- as.should == [@album]
1924
- as.map{|a| a.artist_id}.should == [@artist]
1924
+ as.must_equal [@album]
1925
+ as.map{|a| a.artist_id}.must_equal [@artist]
1925
1926
 
1926
1927
  as = Album.eager_graph(:artist_id).all
1927
- as.should == [@album]
1928
- as.map{|a| a.artist_id}.should == [@artist]
1928
+ as.must_equal [@album]
1929
+ as.map{|a| a.artist_id}.must_equal [@artist]
1929
1930
  end
1930
1931
 
1931
- specify "should handle aliased tables when eager_graphing" do
1932
+ it "should handle aliased tables when eager_graphing" do
1932
1933
  @album.update(:artist => @artist)
1933
1934
  @album.add_tag(@tag)
1934
1935
 
@@ -1941,93 +1942,93 @@ describe "Sequel::Model Simple Associations" do
1941
1942
  Tag.many_to_many :balbums, :class=>Album, :join_table=>:albums_tags, :right_key=>:album_id
1942
1943
 
1943
1944
  a = Artist.eager_graph(:balbums=>:btags).all
1944
- a.should == [@artist]
1945
- a.first.balbums.should == [@album]
1946
- a.first.balbums.first.btags.should == [@tag]
1945
+ a.must_equal [@artist]
1946
+ a.first.balbums.must_equal [@album]
1947
+ a.first.balbums.first.btags.must_equal [@tag]
1947
1948
 
1948
1949
  a = Tag.eager_graph(:balbums=>:bartist).all
1949
- a.should == [@tag]
1950
- a.first.balbums.should == [@album]
1951
- a.first.balbums.first.bartist.should == @artist
1950
+ a.must_equal [@tag]
1951
+ a.first.balbums.must_equal [@album]
1952
+ a.first.balbums.first.bartist.must_equal @artist
1952
1953
  end
1953
1954
 
1954
- specify "should have add method accept hashes and create new records" do
1955
+ it "should have add method accept hashes and create new records" do
1955
1956
  @artist.remove_all_albums
1956
1957
  Album.dataset.delete
1957
1958
  @album = @artist.add_album(:name=>'Al2')
1958
- Album.first[:name].should == 'Al2'
1959
- @artist.albums_dataset.first[:name].should == 'Al2'
1959
+ Album.first[:name].must_equal 'Al2'
1960
+ @artist.albums_dataset.first[:name].must_equal 'Al2'
1960
1961
 
1961
1962
  @album.remove_all_tags
1962
1963
  Tag.dataset.delete
1963
1964
  @album.add_tag(:name=>'T2')
1964
- Tag.first[:name].should == 'T2'
1965
- @album.tags_dataset.first[:name].should == 'T2'
1965
+ Tag.first[:name].must_equal 'T2'
1966
+ @album.tags_dataset.first[:name].must_equal 'T2'
1966
1967
  end
1967
1968
 
1968
- specify "should have add method accept primary key and add related records" do
1969
+ it "should have add method accept primary key and add related records" do
1969
1970
  @artist.remove_all_albums
1970
1971
  @artist.add_album(@album.id)
1971
- @artist.albums_dataset.first[:id].should == @album.id
1972
+ @artist.albums_dataset.first[:id].must_equal @album.id
1972
1973
 
1973
1974
  @album.remove_all_tags
1974
1975
  @album.add_tag(@tag.id)
1975
- @album.tags_dataset.first[:id].should == @tag.id
1976
+ @album.tags_dataset.first[:id].must_equal @tag.id
1976
1977
  end
1977
1978
 
1978
- specify "should have remove method accept primary key and remove related album" do
1979
+ it "should have remove method accept primary key and remove related album" do
1979
1980
  @artist.add_album(@album)
1980
1981
  @artist.reload.remove_album(@album.id)
1981
- @artist.reload.albums.should == []
1982
+ @artist.reload.albums.must_equal []
1982
1983
 
1983
1984
  @album.add_tag(@tag)
1984
1985
  @album.reload.remove_tag(@tag.id)
1985
- @tag.reload.albums.should == []
1986
+ @tag.reload.albums.must_equal []
1986
1987
  end
1987
1988
 
1988
- specify "should handle dynamic callbacks for regular loading" do
1989
+ it "should handle dynamic callbacks for regular loading" do
1989
1990
  @artist.add_album(@album)
1990
1991
 
1991
- @artist.albums.should == [@album]
1992
- @artist.albums(proc{|ds| ds.exclude(:id=>@album.id)}).should == []
1993
- @artist.albums(proc{|ds| ds.filter(:id=>@album.id)}).should == [@album]
1992
+ @artist.albums.must_equal [@album]
1993
+ @artist.albums(proc{|ds| ds.exclude(:id=>@album.id)}).must_equal []
1994
+ @artist.albums(proc{|ds| ds.filter(:id=>@album.id)}).must_equal [@album]
1994
1995
 
1995
- @album.artist.should == @artist
1996
- @album.artist(proc{|ds| ds.exclude(:id=>@artist.id)}).should == nil
1997
- @album.artist(proc{|ds| ds.filter(:id=>@artist.id)}).should == @artist
1996
+ @album.artist.must_equal @artist
1997
+ @album.artist(proc{|ds| ds.exclude(:id=>@artist.id)}).must_equal nil
1998
+ @album.artist(proc{|ds| ds.filter(:id=>@artist.id)}).must_equal @artist
1998
1999
 
1999
- @artist.albums{|ds| ds.exclude(:id=>@album.id)}.should == []
2000
- @artist.albums{|ds| ds.filter(:id=>@album.id)}.should == [@album]
2001
- @album.artist{|ds| ds.exclude(:id=>@artist.id)}.should == nil
2002
- @album.artist{|ds| ds.filter(:id=>@artist.id)}.should == @artist
2000
+ @artist.albums{|ds| ds.exclude(:id=>@album.id)}.must_equal []
2001
+ @artist.albums{|ds| ds.filter(:id=>@album.id)}.must_equal [@album]
2002
+ @album.artist{|ds| ds.exclude(:id=>@artist.id)}.must_equal nil
2003
+ @album.artist{|ds| ds.filter(:id=>@artist.id)}.must_equal @artist
2003
2004
  end
2004
2005
 
2005
- specify "should handle dynamic callbacks for eager loading via eager and eager_graph" do
2006
+ it "should handle dynamic callbacks for eager loading via eager and eager_graph" do
2006
2007
  @artist.add_album(@album)
2007
2008
  @album.add_tag(@tag)
2008
2009
  album2 = @artist.add_album(:name=>'Foo')
2009
2010
  tag2 = album2.add_tag(:name=>'T2')
2010
2011
 
2011
2012
  artist = Artist.eager(:albums=>:tags).all.first
2012
- artist.albums.should == [@album, album2]
2013
- artist.albums.map{|x| x.tags}.should == [[@tag], [tag2]]
2013
+ artist.albums.must_equal [@album, album2]
2014
+ artist.albums.map{|x| x.tags}.must_equal [[@tag], [tag2]]
2014
2015
 
2015
2016
  artist = Artist.eager_graph(:albums=>:tags).all.first
2016
- artist.albums.should == [@album, album2]
2017
- artist.albums.map{|x| x.tags}.should == [[@tag], [tag2]]
2017
+ artist.albums.must_equal [@album, album2]
2018
+ artist.albums.map{|x| x.tags}.must_equal [[@tag], [tag2]]
2018
2019
 
2019
2020
  artist = Artist.eager(:albums=>{proc{|ds| ds.where(:id=>album2.id)}=>:tags}).all.first
2020
- artist.albums.should == [album2]
2021
- artist.albums.first.tags.should == [tag2]
2021
+ artist.albums.must_equal [album2]
2022
+ artist.albums.first.tags.must_equal [tag2]
2022
2023
 
2023
2024
  artist = Artist.eager_graph(:albums=>{proc{|ds| ds.where(:id=>album2.id)}=>:tags}).all.first
2024
- artist.albums.should == [album2]
2025
- artist.albums.first.tags.should == [tag2]
2025
+ artist.albums.must_equal [album2]
2026
+ artist.albums.first.tags.must_equal [tag2]
2026
2027
  end
2027
2028
 
2028
- specify "should have remove method raise an error for one_to_many records if the object isn't already associated" do
2029
- proc{@artist.remove_album(@album.id)}.should raise_error(Sequel::Error)
2030
- proc{@artist.remove_album(@album)}.should raise_error(Sequel::Error)
2029
+ it "should have remove method raise an error for one_to_many records if the object isn't already associated" do
2030
+ proc{@artist.remove_album(@album.id)}.must_raise(Sequel::Error)
2031
+ proc{@artist.remove_album(@album)}.must_raise(Sequel::Error)
2031
2032
  end
2032
2033
  end
2033
2034
 
@@ -2136,56 +2137,56 @@ describe "Sequel::Model Composite Key Associations" do
2136
2137
  @db.drop_table?(:albums_tags, :tags, :albums, :artists)
2137
2138
  end
2138
2139
 
2139
- it_should_behave_like "regular and composite key associations"
2140
+ include RegularAndCompositeKeyAssociations
2140
2141
 
2141
2142
  describe "with :correlated_subquery limit strategy" do
2142
2143
  before do
2143
2144
  @els = {:eager_limit_strategy=>:correlated_subquery}
2144
2145
  end
2145
2146
 
2146
- it_should_behave_like "one_to_one eager_graph limit strategies"
2147
- it_should_behave_like "one_to_many eager_graph limit strategies"
2148
- it_should_behave_like "filter by associations one_to_one limit strategies"
2149
- it_should_behave_like "filter by associations one_to_many limit strategies"
2147
+ include OneToOneEagerGraphLimitStrategies
2148
+ include OneToManyEagerGraphLimitStrategies
2149
+ include FilterByAssociationsOneToOneLimitStrategies
2150
+ include FilterByAssociationsOneToManyLimitStrategies
2150
2151
  end if DB.dataset.supports_limits_in_correlated_subqueries? && DB.dataset.supports_multiple_column_in?
2151
2152
 
2152
- specify "should have add method accept hashes and create new records" do
2153
+ it "should have add method accept hashes and create new records" do
2153
2154
  @artist.remove_all_albums
2154
2155
  Album.dataset.delete
2155
2156
  @artist.add_album(:id1=>1, :id2=>2, :name=>'Al2')
2156
- Album.first[:name].should == 'Al2'
2157
- @artist.albums_dataset.first[:name].should == 'Al2'
2157
+ Album.first[:name].must_equal 'Al2'
2158
+ @artist.albums_dataset.first[:name].must_equal 'Al2'
2158
2159
 
2159
2160
  @album.remove_all_tags
2160
2161
  Tag.dataset.delete
2161
2162
  @album.add_tag(:id1=>1, :id2=>2, :name=>'T2')
2162
- Tag.first[:name].should == 'T2'
2163
- @album.tags_dataset.first[:name].should == 'T2'
2163
+ Tag.first[:name].must_equal 'T2'
2164
+ @album.tags_dataset.first[:name].must_equal 'T2'
2164
2165
  end
2165
2166
 
2166
- specify "should have add method accept primary key and add related records" do
2167
+ it "should have add method accept primary key and add related records" do
2167
2168
  @artist.remove_all_albums
2168
2169
  @artist.add_album([@album.id1, @album.id2])
2169
- @artist.albums_dataset.first.pk.should == [@album.id1, @album.id2]
2170
+ @artist.albums_dataset.first.pk.must_equal [@album.id1, @album.id2]
2170
2171
 
2171
2172
  @album.remove_all_tags
2172
2173
  @album.add_tag([@tag.id1, @tag.id2])
2173
- @album.tags_dataset.first.pk.should == [@tag.id1, @tag.id2]
2174
+ @album.tags_dataset.first.pk.must_equal [@tag.id1, @tag.id2]
2174
2175
  end
2175
2176
 
2176
- specify "should have remove method accept primary key and remove related album" do
2177
+ it "should have remove method accept primary key and remove related album" do
2177
2178
  @artist.add_album(@album)
2178
2179
  @artist.reload.remove_album([@album.id1, @album.id2])
2179
- @artist.reload.albums.should == []
2180
+ @artist.reload.albums.must_equal []
2180
2181
 
2181
2182
  @album.add_tag(@tag)
2182
2183
  @album.reload.remove_tag([@tag.id1, @tag.id2])
2183
- @tag.reload.albums.should == []
2184
+ @tag.reload.albums.must_equal []
2184
2185
  end
2185
2186
 
2186
- specify "should have remove method raise an error for one_to_many records if the object isn't already associated" do
2187
- proc{@artist.remove_album([@album.id1, @album.id2])}.should raise_error(Sequel::Error)
2188
- proc{@artist.remove_album(@album)}.should raise_error(Sequel::Error)
2187
+ it "should have remove method raise an error for one_to_many records if the object isn't already associated" do
2188
+ proc{@artist.remove_album([@album.id1, @album.id2])}.must_raise(Sequel::Error)
2189
+ proc{@artist.remove_album(@album)}.must_raise(Sequel::Error)
2189
2190
  end
2190
2191
  end
2191
2192
 
@@ -2256,10 +2257,10 @@ describe "Sequel::Model pg_array_to_many" do
2256
2257
  after(:all) do
2257
2258
  @db.drop_table?(:tags, :albums, :artists)
2258
2259
  end
2259
-
2260
- it_should_behave_like "basic regular and composite key associations"
2261
- it_should_behave_like "many_to_many eager limit strategies"
2262
- it_should_behave_like "many_to_many eager_graph limit strategies"
2260
+
2261
+ include BasicRegularAndCompositeKeyAssociations
2262
+ include ManyToManyEagerLimitStrategies
2263
+ include ManyToManyEagerGraphLimitStrategies
2263
2264
 
2264
2265
  it "should handle adding and removing entries in array" do
2265
2266
  a = Album.create
@@ -2338,9 +2339,9 @@ describe "Sequel::Model many_to_pg_array" do
2338
2339
  @db.drop_table?(:tags, :albums, :artists)
2339
2340
  end
2340
2341
 
2341
- it_should_behave_like "basic regular and composite key associations"
2342
- it_should_behave_like "many_to_many eager limit strategies"
2343
- it_should_behave_like "many_to_many eager_graph limit strategies"
2342
+ include BasicRegularAndCompositeKeyAssociations
2343
+ include ManyToManyEagerLimitStrategies
2344
+ include ManyToManyEagerGraphLimitStrategies
2344
2345
 
2345
2346
  it "should handle adding and removing entries in array" do
2346
2347
  a = Album.create
@@ -2389,30 +2390,30 @@ describe "Sequel::Model Associations with clashing column names" do
2389
2390
  end
2390
2391
 
2391
2392
  it "should have working regular association methods" do
2392
- @Bar.first.foo.should == @foo
2393
- @Foo.first.bars.should == [@bar]
2394
- @Foo.first.bar.should == @bar
2395
- @Foo.first.mtmbars.should == [@bar]
2396
- @Foo.first.mtmbar.should == @bar
2397
- @Bar.first.mtmfoos.should == [@foo]
2393
+ @Bar.first.foo.must_equal @foo
2394
+ @Foo.first.bars.must_equal [@bar]
2395
+ @Foo.first.bar.must_equal @bar
2396
+ @Foo.first.mtmbars.must_equal [@bar]
2397
+ @Foo.first.mtmbar.must_equal @bar
2398
+ @Bar.first.mtmfoos.must_equal [@foo]
2398
2399
  end
2399
2400
 
2400
2401
  it "should have working eager loading methods" do
2401
- @Bar.eager(:foo).all.map{|o| [o, o.foo]}.should == [[@bar, @foo]]
2402
- @Foo.eager(:bars).all.map{|o| [o, o.bars]}.should == [[@foo, [@bar]]]
2403
- @Foo.eager(:bar).all.map{|o| [o, o.bar]}.should == [[@foo, @bar]]
2404
- @Foo.eager(:mtmbars).all.map{|o| [o, o.mtmbars]}.should == [[@foo, [@bar]]]
2405
- @Foo.eager(:mtmbar).all.map{|o| [o, o.mtmbar]}.should == [[@foo, @bar]]
2406
- @Bar.eager(:mtmfoos).all.map{|o| [o, o.mtmfoos]}.should == [[@bar, [@foo]]]
2402
+ @Bar.eager(:foo).all.map{|o| [o, o.foo]}.must_equal [[@bar, @foo]]
2403
+ @Foo.eager(:bars).all.map{|o| [o, o.bars]}.must_equal [[@foo, [@bar]]]
2404
+ @Foo.eager(:bar).all.map{|o| [o, o.bar]}.must_equal [[@foo, @bar]]
2405
+ @Foo.eager(:mtmbars).all.map{|o| [o, o.mtmbars]}.must_equal [[@foo, [@bar]]]
2406
+ @Foo.eager(:mtmbar).all.map{|o| [o, o.mtmbar]}.must_equal [[@foo, @bar]]
2407
+ @Bar.eager(:mtmfoos).all.map{|o| [o, o.mtmfoos]}.must_equal [[@bar, [@foo]]]
2407
2408
  end
2408
2409
 
2409
2410
  it "should have working eager graphing methods" do
2410
- @Bar.eager_graph(:foo).all.map{|o| [o, o.foo]}.should == [[@bar, @foo]]
2411
- @Foo.eager_graph(:bars).all.map{|o| [o, o.bars]}.should == [[@foo, [@bar]]]
2412
- @Foo.eager_graph(:bar).all.map{|o| [o, o.bar]}.should == [[@foo, @bar]]
2413
- @Foo.eager_graph(:mtmbars).all.map{|o| [o, o.mtmbars]}.should == [[@foo, [@bar]]]
2414
- @Foo.eager_graph(:mtmbar).all.map{|o| [o, o.mtmbar]}.should == [[@foo, @bar]]
2415
- @Bar.eager_graph(:mtmfoos).all.map{|o| [o, o.mtmfoos]}.should == [[@bar, [@foo]]]
2411
+ @Bar.eager_graph(:foo).all.map{|o| [o, o.foo]}.must_equal [[@bar, @foo]]
2412
+ @Foo.eager_graph(:bars).all.map{|o| [o, o.bars]}.must_equal [[@foo, [@bar]]]
2413
+ @Foo.eager_graph(:bar).all.map{|o| [o, o.bar]}.must_equal [[@foo, @bar]]
2414
+ @Foo.eager_graph(:mtmbars).all.map{|o| [o, o.mtmbars]}.must_equal [[@foo, [@bar]]]
2415
+ @Foo.eager_graph(:mtmbar).all.map{|o| [o, o.mtmbar]}.must_equal [[@foo, @bar]]
2416
+ @Bar.eager_graph(:mtmfoos).all.map{|o| [o, o.mtmfoos]}.must_equal [[@bar, [@foo]]]
2416
2417
  end
2417
2418
 
2418
2419
  it "should have working modification methods" do
@@ -2420,34 +2421,34 @@ describe "Sequel::Model Associations with clashing column names" do
2420
2421
  f = @Foo.create(:obj_id=>3)
2421
2422
 
2422
2423
  @bar.foo = f
2423
- @bar.obj_id.should == 3
2424
+ @bar.obj_id.must_equal 3
2424
2425
  @foo.bar = @bar
2425
- @bar.obj_id.should == 2
2426
+ @bar.obj_id.must_equal 2
2426
2427
 
2427
2428
  @foo.add_bar(b)
2428
- @foo.bars.sort_by{|x| x.id}.should == [@bar, b]
2429
+ @foo.bars.sort_by{|x| x.id}.must_equal [@bar, b]
2429
2430
  @foo.remove_bar(b)
2430
- @foo.bars.should == [@bar]
2431
+ @foo.bars.must_equal [@bar]
2431
2432
  @foo.remove_all_bars
2432
- @foo.bars.should == []
2433
+ @foo.bars.must_equal []
2433
2434
 
2434
2435
  @bar.refresh.update(:obj_id=>2)
2435
2436
  b.refresh.update(:obj_id=>3)
2436
- @foo.mtmbars.should == [@bar]
2437
+ @foo.mtmbars.must_equal [@bar]
2437
2438
  @foo.remove_all_mtmbars
2438
- @foo.mtmbars.should == []
2439
+ @foo.mtmbars.must_equal []
2439
2440
  @foo.add_mtmbar(b)
2440
- @foo.mtmbars.should == [b]
2441
+ @foo.mtmbars.must_equal [b]
2441
2442
  @foo.remove_mtmbar(b)
2442
- @foo.mtmbars.should == []
2443
+ @foo.mtmbars.must_equal []
2443
2444
 
2444
2445
  @bar.add_mtmfoo(f)
2445
- @bar.mtmfoos.should == [f]
2446
+ @bar.mtmfoos.must_equal [f]
2446
2447
  @bar.remove_all_mtmfoos
2447
- @bar.mtmfoos.should == []
2448
+ @bar.mtmfoos.must_equal []
2448
2449
  @bar.add_mtmfoo(f)
2449
- @bar.mtmfoos.should == [f]
2450
+ @bar.mtmfoos.must_equal [f]
2450
2451
  @bar.remove_mtmfoo(f)
2451
- @bar.mtmfoos.should == []
2452
+ @bar.mtmfoos.must_equal []
2452
2453
  end
2453
2454
  end