shoulda-matchers 2.2.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +3 -0
- data/Gemfile.lock +1 -1
- data/NEWS.md +25 -1
- data/README.md +1 -2
- data/gemfiles/3.0.gemfile.lock +1 -1
- data/gemfiles/3.1.gemfile.lock +1 -1
- data/gemfiles/3.2.gemfile.lock +1 -1
- data/lib/shoulda/matchers/action_controller.rb +1 -0
- data/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +81 -0
- data/lib/shoulda/matchers/active_model/comparison_matcher.rb +1 -1
- data/lib/shoulda/matchers/active_model/disallow_value_matcher.rb +5 -0
- data/lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb +15 -1
- data/lib/shoulda/matchers/active_model/validate_acceptance_of_matcher.rb +1 -1
- data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +1 -1
- data/lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb +2 -8
- data/lib/shoulda/matchers/active_model/validation_matcher.rb +2 -0
- data/lib/shoulda/matchers/active_record.rb +5 -0
- data/lib/shoulda/matchers/active_record/association_matcher.rb +90 -113
- data/lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb +35 -0
- data/lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb +35 -0
- data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +37 -0
- data/lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb +35 -0
- data/lib/shoulda/matchers/active_record/association_matchers/through_matcher.rb +57 -0
- data/lib/shoulda/matchers/version.rb +1 -1
- data/spec/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb +63 -0
- data/spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb +1 -1
- data/spec/shoulda/matchers/active_model/comparison_matcher_spec.rb +5 -0
- data/spec/shoulda/matchers/active_model/disallow_value_matcher_spec.rb +18 -0
- data/spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb +10 -0
- data/spec/shoulda/matchers/active_model/ensure_length_of_matcher_spec.rb +3 -3
- data/spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +13 -0
- data/spec/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb +14 -0
- data/spec/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb +49 -1
- data/spec/shoulda/matchers/active_record/association_matcher_spec.rb +39 -4
- metadata +11 -3
@@ -46,6 +46,25 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher do
|
|
46
46
|
belonging_to_parent.should_not belong_to(:parent).dependent(:destroy)
|
47
47
|
end
|
48
48
|
|
49
|
+
it 'accepts an association with a valid :counter_cache option' do
|
50
|
+
belonging_to_parent(:counter_cache => :attribute_count).
|
51
|
+
should belong_to(:parent).counter_cache(:attribute_count)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'defaults :counter_cache to true' do
|
55
|
+
belonging_to_parent(:counter_cache => true).
|
56
|
+
should belong_to(:parent).counter_cache
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'rejects an association with a bad :counter_cache option' do
|
60
|
+
belonging_to_parent(:counter_cache => :attribute_count).
|
61
|
+
should_not belong_to(:parent).counter_cache(true)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'rejects an association that has no :counter_cache option' do
|
65
|
+
belonging_to_parent.should_not belong_to(:parent).counter_cache
|
66
|
+
end
|
67
|
+
|
49
68
|
it 'accepts an association with a valid :conditions option' do
|
50
69
|
define_model :parent, :adopter => :boolean
|
51
70
|
define_model :child, :parent_id => :integer do
|
@@ -256,7 +275,11 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher do
|
|
256
275
|
end
|
257
276
|
|
258
277
|
it 'rejects an association with a bad :dependent option' do
|
259
|
-
|
278
|
+
matcher = have_many(:children).dependent(:destroy)
|
279
|
+
|
280
|
+
having_many_children.should_not matcher
|
281
|
+
|
282
|
+
matcher.failure_message_for_should.should =~ /children should have destroy dependency/
|
260
283
|
end
|
261
284
|
|
262
285
|
it 'accepts an association with a valid :order option' do
|
@@ -265,7 +288,11 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher do
|
|
265
288
|
end
|
266
289
|
|
267
290
|
it 'rejects an association with a bad :order option' do
|
268
|
-
|
291
|
+
matcher = have_many(:children).order(:id)
|
292
|
+
|
293
|
+
having_many_children.should_not matcher
|
294
|
+
|
295
|
+
matcher.failure_message_for_should.should =~ /children should be ordered by id/
|
269
296
|
end
|
270
297
|
|
271
298
|
it 'accepts an association with a valid :conditions option' do
|
@@ -401,7 +428,11 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher do
|
|
401
428
|
end
|
402
429
|
|
403
430
|
it 'rejects an association with a bad :dependent option' do
|
404
|
-
|
431
|
+
matcher = have_one(:detail).dependent(:destroy)
|
432
|
+
|
433
|
+
having_one_detail.should_not matcher
|
434
|
+
|
435
|
+
matcher.failure_message_for_should.should =~ /detail should have destroy dependency/
|
405
436
|
end
|
406
437
|
|
407
438
|
it 'accepts an association with a valid :order option' do
|
@@ -409,7 +440,11 @@ describe Shoulda::Matchers::ActiveRecord::AssociationMatcher do
|
|
409
440
|
end
|
410
441
|
|
411
442
|
it 'rejects an association with a bad :order option' do
|
412
|
-
|
443
|
+
matcher = have_one(:detail).order(:id)
|
444
|
+
|
445
|
+
having_one_detail.should_not matcher
|
446
|
+
|
447
|
+
matcher.failure_message_for_should.should =~ /detail should be ordered by id/
|
413
448
|
end
|
414
449
|
|
415
450
|
it 'accepts an association with a valid :conditions option' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shoulda-matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2013-
|
17
|
+
date: 2013-08-16 00:00:00.000000000 Z
|
18
18
|
dependencies:
|
19
19
|
- !ruby/object:Gem::Dependency
|
20
20
|
name: activesupport
|
@@ -208,6 +208,7 @@ files:
|
|
208
208
|
- lib/shoulda/matchers/action_controller/redirect_to_matcher.rb
|
209
209
|
- lib/shoulda/matchers/action_controller/render_template_matcher.rb
|
210
210
|
- lib/shoulda/matchers/action_controller/render_with_layout_matcher.rb
|
211
|
+
- lib/shoulda/matchers/action_controller/rescue_from_matcher.rb
|
211
212
|
- lib/shoulda/matchers/action_controller/respond_with_matcher.rb
|
212
213
|
- lib/shoulda/matchers/action_controller/route_matcher.rb
|
213
214
|
- lib/shoulda/matchers/action_controller/set_session_matcher.rb
|
@@ -235,6 +236,11 @@ files:
|
|
235
236
|
- lib/shoulda/matchers/active_record.rb
|
236
237
|
- lib/shoulda/matchers/active_record/accept_nested_attributes_for_matcher.rb
|
237
238
|
- lib/shoulda/matchers/active_record/association_matcher.rb
|
239
|
+
- lib/shoulda/matchers/active_record/association_matchers/counter_cache_matcher.rb
|
240
|
+
- lib/shoulda/matchers/active_record/association_matchers/dependent_matcher.rb
|
241
|
+
- lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb
|
242
|
+
- lib/shoulda/matchers/active_record/association_matchers/order_matcher.rb
|
243
|
+
- lib/shoulda/matchers/active_record/association_matchers/through_matcher.rb
|
238
244
|
- lib/shoulda/matchers/active_record/have_db_column_matcher.rb
|
239
245
|
- lib/shoulda/matchers/active_record/have_db_index_matcher.rb
|
240
246
|
- lib/shoulda/matchers/active_record/have_readonly_attribute_matcher.rb
|
@@ -249,6 +255,7 @@ files:
|
|
249
255
|
- spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
|
250
256
|
- spec/shoulda/matchers/action_controller/render_template_matcher_spec.rb
|
251
257
|
- spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
|
258
|
+
- spec/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb
|
252
259
|
- spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
|
253
260
|
- spec/shoulda/matchers/action_controller/route_matcher_spec.rb
|
254
261
|
- spec/shoulda/matchers/action_controller/set_session_matcher_spec.rb
|
@@ -306,7 +313,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
306
313
|
version: '0'
|
307
314
|
segments:
|
308
315
|
- 0
|
309
|
-
hash:
|
316
|
+
hash: 1901679853552928105
|
310
317
|
requirements: []
|
311
318
|
rubyforge_project:
|
312
319
|
rubygems_version: 1.8.23
|
@@ -322,6 +329,7 @@ test_files:
|
|
322
329
|
- spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb
|
323
330
|
- spec/shoulda/matchers/action_controller/render_template_matcher_spec.rb
|
324
331
|
- spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb
|
332
|
+
- spec/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb
|
325
333
|
- spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb
|
326
334
|
- spec/shoulda/matchers/action_controller/route_matcher_spec.rb
|
327
335
|
- spec/shoulda/matchers/action_controller/set_session_matcher_spec.rb
|