shoulda-matchers 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +8 -7
- data/.travis.yml +4 -0
- data/Appraisals +8 -0
- data/CONTRIBUTING.md +1 -1
- data/Gemfile +1 -1
- data/Gemfile.lock +77 -66
- data/MIT-LICENSE +1 -1
- data/NEWS.md +63 -1
- data/README.md +189 -33
- data/Rakefile +6 -5
- data/features/rails_integration.feature +1 -1
- data/features/step_definitions/rails_steps.rb +7 -6
- data/gemfiles/3.0.gemfile +2 -2
- data/gemfiles/3.0.gemfile.lock +14 -5
- data/gemfiles/3.1.gemfile +2 -2
- data/gemfiles/3.1.gemfile.lock +14 -5
- data/gemfiles/3.2.gemfile +2 -2
- data/gemfiles/3.2.gemfile.lock +16 -7
- data/gemfiles/4.0.0.gemfile +2 -2
- data/gemfiles/4.0.0.gemfile.lock +15 -6
- data/gemfiles/4.0.1.gemfile +2 -2
- data/gemfiles/4.0.1.gemfile.lock +15 -6
- data/gemfiles/4.1.gemfile +19 -0
- data/gemfiles/4.1.gemfile.lock +176 -0
- data/lib/shoulda/matchers.rb +17 -1
- data/lib/shoulda/matchers/action_controller.rb +4 -2
- data/lib/shoulda/matchers/action_controller/callback_matcher.rb +100 -0
- data/lib/shoulda/matchers/action_controller/redirect_to_matcher.rb +1 -1
- data/lib/shoulda/matchers/action_controller/render_template_matcher.rb +4 -4
- data/lib/shoulda/matchers/action_controller/rescue_from_matcher.rb +1 -1
- data/lib/shoulda/matchers/action_controller/route_matcher.rb +12 -12
- data/lib/shoulda/matchers/action_controller/route_params.rb +1 -1
- data/lib/shoulda/matchers/action_controller/set_the_flash_matcher.rb +2 -1
- data/lib/shoulda/matchers/action_controller/strong_parameters_matcher.rb +167 -0
- data/lib/shoulda/matchers/active_model.rb +4 -2
- data/lib/shoulda/matchers/active_model/allow_value_matcher.rb +23 -5
- data/lib/shoulda/matchers/active_model/disallow_value_matcher.rb +0 -4
- data/lib/shoulda/matchers/active_model/ensure_inclusion_of_matcher.rb +66 -14
- data/lib/shoulda/matchers/active_model/ensure_length_of_matcher.rb +8 -8
- data/lib/shoulda/matchers/active_model/errors.rb +40 -0
- data/lib/shoulda/matchers/active_model/helpers.rb +6 -6
- data/lib/shoulda/matchers/active_model/numericality_matchers/comparison_matcher.rb +33 -14
- data/lib/shoulda/matchers/active_model/numericality_matchers/even_number_matcher.rb +26 -0
- data/lib/shoulda/matchers/active_model/numericality_matchers/{odd_even_number_matcher.rb → numeric_type_matcher.rb} +9 -20
- data/lib/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher.rb +26 -0
- data/lib/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher.rb +5 -21
- data/lib/shoulda/matchers/active_model/validate_confirmation_of_matcher.rb +1 -1
- data/lib/shoulda/matchers/active_model/validate_numericality_of_matcher.rb +71 -22
- data/lib/shoulda/matchers/active_model/validate_presence_of_matcher.rb +6 -1
- data/lib/shoulda/matchers/active_model/validate_uniqueness_of_matcher.rb +25 -6
- data/lib/shoulda/matchers/active_record.rb +1 -0
- data/lib/shoulda/matchers/active_record/association_matcher.rb +67 -13
- data/lib/shoulda/matchers/active_record/association_matchers/inverse_of_matcher.rb +40 -0
- data/lib/shoulda/matchers/active_record/association_matchers/model_reflection.rb +24 -1
- data/lib/shoulda/matchers/active_record/association_matchers/model_reflector.rb +1 -1
- data/lib/shoulda/matchers/active_record/have_db_column_matcher.rb +1 -1
- data/lib/shoulda/matchers/active_record/have_db_index_matcher.rb +1 -1
- data/lib/shoulda/matchers/assertion_error.rb +7 -2
- data/lib/shoulda/matchers/error.rb +24 -0
- data/lib/shoulda/matchers/independent.rb +10 -0
- data/lib/shoulda/matchers/independent/delegate_matcher.rb +157 -0
- data/lib/shoulda/matchers/independent/delegate_matcher/stubbed_target.rb +34 -0
- data/lib/shoulda/matchers/integrations/nunit_test_case_detection.rb +36 -0
- data/lib/shoulda/matchers/integrations/rspec.rb +13 -14
- data/lib/shoulda/matchers/integrations/test_unit.rb +11 -9
- data/lib/shoulda/matchers/version.rb +1 -1
- data/lib/shoulda/matchers/warn.rb +7 -0
- data/shoulda-matchers.gemspec +2 -1
- data/spec/shoulda/matchers/action_controller/callback_matcher_spec.rb +79 -0
- data/spec/shoulda/matchers/action_controller/filter_param_matcher_spec.rb +3 -3
- data/spec/shoulda/matchers/action_controller/redirect_to_matcher_spec.rb +11 -11
- data/spec/shoulda/matchers/action_controller/render_template_matcher_spec.rb +21 -21
- data/spec/shoulda/matchers/action_controller/render_with_layout_matcher_spec.rb +10 -10
- data/spec/shoulda/matchers/action_controller/rescue_from_matcher_spec.rb +45 -18
- data/spec/shoulda/matchers/action_controller/respond_with_matcher_spec.rb +8 -8
- data/spec/shoulda/matchers/action_controller/route_matcher_spec.rb +19 -19
- data/spec/shoulda/matchers/action_controller/route_params_spec.rb +6 -6
- data/spec/shoulda/matchers/action_controller/set_session_matcher_spec.rb +11 -11
- data/spec/shoulda/matchers/action_controller/set_the_flash_matcher_spec.rb +44 -44
- data/spec/shoulda/matchers/action_controller/strong_parameters_matcher_spec.rb +205 -0
- data/spec/shoulda/matchers/active_model/allow_mass_assignment_of_matcher_spec.rb +24 -24
- data/spec/shoulda/matchers/active_model/allow_value_matcher_spec.rb +37 -37
- data/spec/shoulda/matchers/active_model/disallow_value_matcher_spec.rb +17 -21
- data/spec/shoulda/matchers/active_model/ensure_exclusion_of_matcher_spec.rb +24 -24
- data/spec/shoulda/matchers/active_model/ensure_inclusion_of_matcher_spec.rb +173 -67
- data/spec/shoulda/matchers/active_model/ensure_length_of_matcher_spec.rb +40 -40
- data/spec/shoulda/matchers/active_model/exception_message_finder_spec.rb +20 -20
- data/spec/shoulda/matchers/active_model/helpers_spec.rb +27 -25
- data/spec/shoulda/matchers/active_model/numericality_matchers/comparison_matcher_spec.rb +126 -13
- data/spec/shoulda/matchers/active_model/numericality_matchers/even_number_matcher_spec.rb +59 -0
- data/spec/shoulda/matchers/active_model/numericality_matchers/odd_number_matcher_spec.rb +59 -0
- data/spec/shoulda/matchers/active_model/numericality_matchers/only_integer_matcher_spec.rb +27 -26
- data/spec/shoulda/matchers/active_model/validate_absence_of_matcher_spec.rb +15 -15
- data/spec/shoulda/matchers/active_model/validate_acceptance_of_matcher_spec.rb +8 -8
- data/spec/shoulda/matchers/active_model/validate_confirmation_of_matcher_spec.rb +9 -9
- data/spec/shoulda/matchers/active_model/validate_numericality_of_matcher_spec.rb +229 -44
- data/spec/shoulda/matchers/active_model/validate_presence_of_matcher_spec.rb +44 -25
- data/spec/shoulda/matchers/active_model/validate_uniqueness_of_matcher_spec.rb +110 -62
- data/spec/shoulda/matchers/active_model/validation_message_finder_spec.rb +19 -19
- data/spec/shoulda/matchers/active_record/accept_nested_attributes_for_matcher_spec.rb +30 -30
- data/spec/shoulda/matchers/active_record/association_matcher_spec.rb +378 -192
- data/spec/shoulda/matchers/active_record/association_matchers/model_reflection_spec.rb +4 -0
- data/spec/shoulda/matchers/active_record/have_db_column_matcher_spec.rb +33 -33
- data/spec/shoulda/matchers/active_record/have_db_index_matcher_spec.rb +21 -17
- data/spec/shoulda/matchers/active_record/have_readonly_attributes_matcher_spec.rb +8 -8
- data/spec/shoulda/matchers/active_record/serialize_matcher_spec.rb +14 -14
- data/spec/shoulda/matchers/independent/delegate_matcher/stubbed_target_spec.rb +43 -0
- data/spec/shoulda/matchers/independent/delegate_matcher_spec.rb +184 -0
- data/spec/spec_helper.rb +4 -0
- data/spec/support/activemodel_helpers.rb +2 -2
- data/spec/support/capture_helpers.rb +19 -0
- data/spec/support/controller_builder.rb +22 -3
- data/spec/support/fail_with_message_including_matcher.rb +33 -0
- data/spec/support/model_builder.rb +1 -1
- data/spec/support/shared_examples/numerical_submatcher.rb +19 -0
- data/spec/support/shared_examples/numerical_type_submatcher.rb +17 -0
- data/spec/support/test_application.rb +23 -0
- metadata +90 -22
- checksums.yaml +0 -7
- data/spec/shoulda/matchers/active_model/numericality_matchers/odd_even_number_matcher_spec.rb +0 -97
- data/spec/support/shared_examples/numerical_submatcher_spec.rb +0 -23
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 4336f4036fb8ecbaa4ec14d3a8fbd5658164c45c
|
4
|
-
data.tar.gz: 89085b77428f146b6d4aec6d5a024ee58e34e538
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: b5d48666690f5f108abd1925b7c157ac1e89aa73c6fa8310307f0f305811cac5539761c2ed5ebee3eaecee704740ec4adbc578614db088112b98f26cb2ca47df
|
7
|
-
data.tar.gz: dcbacdcb84ae3851a0f38f292d2b7318beab73b7b73bea4d99895a9e00d0cec027da60bd99bc2ca9405c5d311cbd97da6b5d034d0f0f5e0f26aa6b16958b029c
|
data/spec/shoulda/matchers/active_model/numericality_matchers/odd_even_number_matcher_spec.rb
DELETED
@@ -1,97 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Shoulda::Matchers::ActiveModel::NumericalityMatchers::OddEvenNumberMatcher do
|
4
|
-
it_behaves_like 'a numerical submatcher' do
|
5
|
-
subject { described_class.new(:attr) }
|
6
|
-
end
|
7
|
-
|
8
|
-
context 'given an attribute that only allows odd number values' do
|
9
|
-
it 'matches' do
|
10
|
-
validating_odd_number.should new_odd_matcher
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'returns itself when given a message' do
|
14
|
-
matcher = new_odd_matcher
|
15
|
-
matcher.with_message('some message').should eq matcher
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
context 'given an attribute that only allows even number values' do
|
20
|
-
it 'matches' do
|
21
|
-
validating_even_number.should new_even_matcher
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'returns itself when given a message' do
|
25
|
-
matcher = new_even_matcher
|
26
|
-
matcher.with_message('some message').should eq matcher
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
context 'given an attribute that only allows odd number values with a custom validation message' do
|
31
|
-
it 'only accepts odd number values for that attribute with that message' do
|
32
|
-
validating_odd_number(:message => 'custom').should new_odd_matcher.with_message(/custom/)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'rejects odd number values for that attribute with another message' do
|
36
|
-
validating_odd_number(:message => 'custom').should_not new_odd_matcher.with_message(/wrong/)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
context 'given an attribute that only allows even number values with a custom validation message' do
|
41
|
-
it 'only accepts even number values for that attribute with that message' do
|
42
|
-
validating_even_number(:message => 'custom').should new_even_matcher.with_message(/custom/)
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'rejects even number values for that attribute with another message' do
|
46
|
-
validating_even_number(:message => 'custom').should_not new_even_matcher.with_message(/wrong/)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
context 'when the model does not have an odd validation' do
|
51
|
-
it 'does not match' do
|
52
|
-
define_model(:example, :attr => :string).new.should_not new_odd_matcher
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'fails with the ActiveRecord :odd message' do
|
56
|
-
matcher = new_odd_matcher
|
57
|
-
|
58
|
-
matcher.matches?(define_model(:example, :attr => :string).new)
|
59
|
-
|
60
|
-
matcher.failure_message.should include 'Expected errors to include "must be odd"'
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'when the model does not have an even validation' do
|
65
|
-
it 'does not match' do
|
66
|
-
define_model(:example, :attr => :string).new.should_not new_even_matcher
|
67
|
-
end
|
68
|
-
|
69
|
-
it 'fails with the ActiveRecord :even message' do
|
70
|
-
matcher = new_even_matcher
|
71
|
-
|
72
|
-
matcher.matches?(define_model(:example, :attr => :string).new)
|
73
|
-
|
74
|
-
matcher.failure_message.should include 'Expected errors to include "must be even"'
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def new_odd_matcher
|
79
|
-
described_class.new(:attr, :odd => true)
|
80
|
-
end
|
81
|
-
|
82
|
-
def new_even_matcher
|
83
|
-
described_class.new(:attr, :even => true)
|
84
|
-
end
|
85
|
-
|
86
|
-
def validating_odd_number(options = {})
|
87
|
-
define_model :example, :attr => :string do
|
88
|
-
validates_numericality_of :attr, { :odd => true }.merge(options)
|
89
|
-
end.new
|
90
|
-
end
|
91
|
-
|
92
|
-
def validating_even_number(options = {})
|
93
|
-
define_model :example, :attr => :string do
|
94
|
-
validates_numericality_of :attr, { :even => true }.merge(options)
|
95
|
-
end.new
|
96
|
-
end
|
97
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
shared_examples 'a numerical submatcher' do
|
4
|
-
it 'implements the with_message method' do
|
5
|
-
subject.should respond_to(:with_message).with(1).arguments
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'implements the allowed_types method' do
|
9
|
-
subject.should respond_to(:allowed_types).with(0).arguments
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'implements the matches? method' do
|
13
|
-
subject.should respond_to(:matches?).with(1).arguments
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'implements the failure_message method' do
|
17
|
-
subject.should respond_to(:failure_message).with(0).arguments
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'implements the failure_message_when_negated method' do
|
21
|
-
subject.should respond_to(:failure_message_when_negated).with(0).arguments
|
22
|
-
end
|
23
|
-
end
|