-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #245 from igorkasyanchuk/243-passing-allow_blank-o…
…ption-raises [Validator] Better error message when using :allow_blank/nil with attached validator (#243)
- Loading branch information
Showing
3 changed files
with
19 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 8 additions & 1 deletion
9
test/validators/shared_examples/does_not_work_with_allow_blank_option.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module DoesNotWorkWithAllowBlankOption | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
subject { validator_test_class::WithAllowBlank.new(params) } | ||
|
||
describe 'when used with :allow_blank option' do | ||
it { is_expected_to_raise_error(ArgumentError, "You cannot pass the :allow_blank option to this validator") } | ||
it do | ||
is_expected_to_raise_error( | ||
ArgumentError, | ||
"You cannot pass the :allow_blank option to the #{validator_test_class.name.delete('::').underscore}" | ||
) | ||
end | ||
end | ||
end | ||
end |
9 changes: 8 additions & 1 deletion
9
test/validators/shared_examples/does_not_work_with_allow_nil_option.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module DoesNotWorkWithAllowNilOption | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
subject { validator_test_class::WithAllowNil.new(params) } | ||
|
||
describe 'when used with :allow_nil option' do | ||
it { is_expected_to_raise_error(ArgumentError, "You cannot pass the :allow_nil option to this validator") } | ||
it do | ||
is_expected_to_raise_error( | ||
ArgumentError, | ||
"You cannot pass the :allow_nil option to the #{validator_test_class.name.delete('::').underscore}" | ||
) | ||
end | ||
end | ||
end | ||
end |