mirror of
https://github.com/thoughtbot/shoulda-matchers.git
synced 2022-11-09 12:01:38 -05:00
allow_value: Inspect values more clearly
Modify descriptions and failure messages for all matchers by way of allow_value and put small angle brackets around inspected values. This is to visually distinguish an inspected value from the rest of the text, and is especially noticeable for complex values such as an array that contains an object, particularly if the inspected version of the value wraps onto another line. It's a little easier to see: When attempting to set :attr on Example to ‹[#<Child id: nil>]›... rather than: When attempting to set :attr on Example to [#<Child id: nil>]...
This commit is contained in:
parent
417f289a86
commit
6b3253147a
17 changed files with 200 additions and 169 deletions
|
@ -463,10 +463,13 @@ module Shoulda
|
|||
end
|
||||
|
||||
if expected_message.is_a?(Regexp)
|
||||
message << ' matching'
|
||||
end
|
||||
|
||||
message << ' matching '
|
||||
message << Shoulda::Matchers::Util.inspect_value(
|
||||
expected_message
|
||||
)
|
||||
else
|
||||
message << " #{expected_message.inspect}"
|
||||
end
|
||||
|
||||
unless validator.captured_validation_exception?
|
||||
message << " on :#{attribute_to_check_message_against}"
|
||||
|
@ -577,14 +580,10 @@ module Shoulda
|
|||
end
|
||||
|
||||
def inspected_values_to_set
|
||||
if values_to_set.size > 1
|
||||
values_to_set.map(&:inspect).to_sentence(
|
||||
Shoulda::Matchers::Util.inspect_values(values_to_set).to_sentence(
|
||||
two_words_connector: " or ",
|
||||
last_word_connector: ", or"
|
||||
)
|
||||
else
|
||||
values_to_set.first.inspect
|
||||
end
|
||||
end
|
||||
|
||||
def default_expected_message
|
||||
|
|
|
@ -25,11 +25,13 @@ module Shoulda
|
|||
end
|
||||
|
||||
def description
|
||||
description = ":#{attribute_name} to #{value_written.inspect}"
|
||||
description = ":#{attribute_name} to "
|
||||
description << Shoulda::Matchers::Util.inspect_value(value_written)
|
||||
|
||||
if attribute_changed_value?
|
||||
description << " -- which was read back as "
|
||||
description << "#{value_read.inspect} --"
|
||||
description << Shoulda::Matchers::Util.inspect_value(value_read)
|
||||
description << " --"
|
||||
end
|
||||
|
||||
description
|
||||
|
|
|
@ -141,17 +141,15 @@ module Shoulda
|
|||
|
||||
def simple_description
|
||||
if @range
|
||||
"validate that :#{@attribute} lies outside the range #{@range.inspect}"
|
||||
"validate that :#{@attribute} lies outside the range " +
|
||||
Shoulda::Matchers::Util.inspect_range(@range)
|
||||
else
|
||||
description = "validate that :#{@attribute}"
|
||||
|
||||
if @array.many?
|
||||
description << " is neither " + @array.map(&:inspect).to_sentence(
|
||||
two_words_connector: " nor ",
|
||||
last_word_connector: ", nor "
|
||||
)
|
||||
description << " is neither #{inspected_array}"
|
||||
else
|
||||
description << " is not #{@array.first.inspect}"
|
||||
description << " is not #{inspected_array}"
|
||||
end
|
||||
|
||||
description
|
||||
|
@ -202,6 +200,13 @@ module Shoulda
|
|||
@array.inspect
|
||||
end
|
||||
end
|
||||
|
||||
def inspected_array
|
||||
Shoulda::Matchers::Util.inspect_values(@array).to_sentence(
|
||||
two_words_connector: " nor ",
|
||||
last_word_connector: ", nor "
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -352,17 +352,15 @@ EOT
|
|||
|
||||
def simple_description
|
||||
if @range
|
||||
"validate that :#{@attribute} lies inside the range #{@range.inspect}"
|
||||
"validate that :#{@attribute} lies inside the range " +
|
||||
Shoulda::Matchers::Util.inspect_range(@range)
|
||||
else
|
||||
description = "validate that :#{@attribute}"
|
||||
|
||||
if @array.many?
|
||||
description << " is either " + @array.map(&:inspect).to_sentence(
|
||||
two_words_connector: " or ",
|
||||
last_word_connector: ", or "
|
||||
)
|
||||
description << " is either #{inspected_array}"
|
||||
else
|
||||
description << " is #{@array.first.inspect}"
|
||||
description << " is #{inspected_array}"
|
||||
end
|
||||
|
||||
description
|
||||
|
@ -552,6 +550,13 @@ EOT
|
|||
else :unknown
|
||||
end
|
||||
end
|
||||
|
||||
def inspected_array
|
||||
Shoulda::Matchers::Util.inspect_values(@array).to_sentence(
|
||||
two_words_connector: " or ",
|
||||
last_word_connector: ", or "
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -682,27 +682,35 @@ module Shoulda
|
|||
|
||||
if @existing_record_created
|
||||
prefix << "After taking the given #{model.name},"
|
||||
prefix << " setting its :#{attribute} to"
|
||||
prefix << " #{existing_value.inspect},"
|
||||
prefix << " and saving it as the existing record,"
|
||||
prefix << " setting its :#{attribute} to "
|
||||
prefix << Shoulda::Matchers::Util.inspect_value(existing_value)
|
||||
prefix << ", and saving it as the existing record,"
|
||||
prefix << " then"
|
||||
elsif @original_existing_value != existing_value
|
||||
prefix << "Given an existing #{model.name},"
|
||||
prefix << " after setting its :#{attribute} to"
|
||||
prefix << " #{existing_value.inspect}, then"
|
||||
prefix << " after setting its :#{attribute} to "
|
||||
prefix << Shoulda::Matchers::Util.inspect_value(existing_value)
|
||||
prefix << ", then"
|
||||
else
|
||||
prefix << "Given an existing #{model.name} whose :#{attribute}"
|
||||
prefix << " is #{existing_value.inspect}, after"
|
||||
prefix << " is "
|
||||
prefix << Shoulda::Matchers::Util.inspect_value(existing_value)
|
||||
prefix << ", after"
|
||||
end
|
||||
|
||||
prefix << " making a new #{model.name} and setting its"
|
||||
prefix << " :#{attribute} to"
|
||||
prefix << " :#{attribute} to "
|
||||
|
||||
if last_value_set_on_new_record == existing_value
|
||||
prefix << " #{last_value_set_on_new_record.inspect} as well"
|
||||
prefix << Shoulda::Matchers::Util.inspect_value(
|
||||
last_value_set_on_new_record
|
||||
)
|
||||
prefix << " as well"
|
||||
else
|
||||
prefix << " a different value,"
|
||||
prefix << " #{last_value_set_on_new_record.inspect}"
|
||||
prefix << " a different value, "
|
||||
prefix << Shoulda::Matchers::Util.inspect_value(
|
||||
last_value_set_on_new_record
|
||||
)
|
||||
end
|
||||
|
||||
prefix << ", the matcher expected the new #{model.name} to be"
|
||||
|
|
|
@ -38,6 +38,18 @@ module Shoulda
|
|||
"a #{next_word}"
|
||||
end
|
||||
end
|
||||
|
||||
def self.inspect_value(value)
|
||||
"‹#{value.inspect}›"
|
||||
end
|
||||
|
||||
def self.inspect_values(values)
|
||||
values.map { |value| inspect_value(value) }
|
||||
end
|
||||
|
||||
def self.inspect_range(range)
|
||||
"#{inspect_value(range.first)} to #{inspect_value(range.last)}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,14 +14,14 @@ describe Shoulda::Matchers::ActiveModel::AllowValueMatcher, type: :model do
|
|||
matcher = allow_value('foo', 'bar').for(:baz)
|
||||
|
||||
expect(matcher.description).to eq(
|
||||
'allow :baz to be "foo" or "bar"'
|
||||
'allow :baz to be ‹"foo"› or ‹"bar"›'
|
||||
)
|
||||
end
|
||||
|
||||
it 'describes itself with a single value' do
|
||||
matcher = allow_value('foo').for(:baz)
|
||||
|
||||
expect(matcher.description).to eq 'allow :baz to be "foo"'
|
||||
expect(matcher.description).to eq 'allow :baz to be ‹"foo"›'
|
||||
end
|
||||
|
||||
if active_model_3_2?
|
||||
|
@ -29,7 +29,7 @@ describe Shoulda::Matchers::ActiveModel::AllowValueMatcher, type: :model do
|
|||
strict_matcher = allow_value('xyz').for(:attr).strict
|
||||
|
||||
expect(strict_matcher.description).to eq(
|
||||
'allow :attr to be "xyz", raising a validation exception on failure'
|
||||
'allow :attr to be ‹"xyz"›, raising a validation exception on failure'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -56,7 +56,7 @@ describe Shoulda::Matchers::ActiveModel::AllowValueMatcher, type: :model do
|
|||
|
||||
it 'rejects a bad value with an appropriate failure message' do
|
||||
message = <<-MESSAGE
|
||||
After setting :attr to "xyz", the matcher expected the Example to be
|
||||
After setting :attr to ‹"xyz"›, the matcher expected the Example to be
|
||||
valid, but it was invalid instead, producing these validation errors:
|
||||
|
||||
* attr: ["is invalid"]
|
||||
|
@ -84,7 +84,7 @@ valid, but it was invalid instead, producing these validation errors:
|
|||
|
||||
it 'produces an appropriate failure message' do
|
||||
message = <<-MESSAGE
|
||||
After setting :attr to "zyx", the matcher expected the Example to be
|
||||
After setting :attr to ‹"zyx"›, the matcher expected the Example to be
|
||||
valid, but it was invalid instead, producing these validation errors:
|
||||
|
||||
* attr: ["is invalid"]
|
||||
|
@ -110,7 +110,7 @@ valid, but it was invalid instead, producing these validation errors:
|
|||
|
||||
it 'rejects a bad value with an appropriate failure message' do
|
||||
message = <<-MESSAGE
|
||||
After setting :attr to "xyz", the matcher expected the Example to be
|
||||
After setting :attr to ‹"xyz"›, the matcher expected the Example to be
|
||||
valid, but it was invalid instead, producing these validation errors:
|
||||
|
||||
* attr: ["bad value"]
|
||||
|
@ -127,10 +127,10 @@ valid, but it was invalid instead, producing these validation errors:
|
|||
context 'when the custom messages do not match' do
|
||||
it 'rejects with an appropriate failure message' do
|
||||
message = <<-MESSAGE
|
||||
After setting :attr to "xyz", the matcher expected the Example to be
|
||||
invalid and to produce a validation error matching /different/ on :attr.
|
||||
The record was indeed invalid, but it produced these validation errors
|
||||
instead:
|
||||
After setting :attr to ‹"xyz"›, the matcher expected the Example to be
|
||||
invalid and to produce a validation error matching ‹/different/› on
|
||||
:attr. The record was indeed invalid, but it produced these validation
|
||||
errors instead:
|
||||
|
||||
* attr: ["bad value"]
|
||||
MESSAGE
|
||||
|
@ -186,7 +186,7 @@ instead:
|
|||
end
|
||||
|
||||
message = <<-MESSAGE
|
||||
After setting :attr to "xyz", the matcher expected the Example to be
|
||||
After setting :attr to ‹"xyz"›, the matcher expected the Example to be
|
||||
invalid and to produce the validation error "must be greater than 2" on
|
||||
:attr. The record was indeed invalid, but it produced these validation
|
||||
errors instead:
|
||||
|
@ -249,7 +249,7 @@ errors instead:
|
|||
end
|
||||
|
||||
message = <<-MESSAGE
|
||||
After setting :#{builder.attribute_to_validate} to "#{invalid_value}", the
|
||||
After setting :#{builder.attribute_to_validate} to ‹"#{invalid_value}"›, the
|
||||
matcher expected the #{builder.model.name} to be invalid and to produce the validation
|
||||
error "some error" on :#{builder.attribute_that_receives_error}. The record was
|
||||
indeed invalid, but it produced these validation errors instead:
|
||||
|
@ -341,7 +341,7 @@ indeed invalid, but it produced these validation errors instead:
|
|||
|
||||
it "does not match given good values along with bad values" do
|
||||
message = <<-MESSAGE.strip_heredoc
|
||||
After setting :attr to "12345", the matcher expected the Example to be
|
||||
After setting :attr to ‹"12345"›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -375,7 +375,7 @@ invalid, but it was valid instead.
|
|||
context 'when qualified with strict' do
|
||||
it 'rejects a bad value, providing the correct failure message' do
|
||||
message = <<-MESSAGE.strip_heredoc
|
||||
After setting :attr to "xyz", the matcher expected the Example to be
|
||||
After setting :attr to ‹"xyz"›, the matcher expected the Example to be
|
||||
valid, but it was invalid instead, raising a validation exception with
|
||||
the message "Attr is invalid".
|
||||
MESSAGE
|
||||
|
@ -391,10 +391,10 @@ the message "Attr is invalid".
|
|||
context 'qualified with a custom message' do
|
||||
it 'rejects a bad value when the failure messages do not match' do
|
||||
message = <<-MESSAGE.strip_heredoc
|
||||
After setting :attr to "xyz", the matcher expected the Example to be
|
||||
invalid and to raise a validation exception with message matching /abc/.
|
||||
The record was indeed invalid, but the exception message was "Attr is
|
||||
invalid" instead.
|
||||
After setting :attr to ‹"xyz"›, the matcher expected the Example to be
|
||||
invalid and to raise a validation exception with message matching
|
||||
‹/abc/›. The record was indeed invalid, but the exception message was
|
||||
"Attr is invalid" instead.
|
||||
MESSAGE
|
||||
|
||||
assertion = lambda do
|
||||
|
|
|
@ -21,7 +21,7 @@ describe Shoulda::Matchers::ActiveModel::NumericalityMatchers::EvenNumberMatcher
|
|||
end
|
||||
|
||||
message = <<-MESSAGE.strip_heredoc
|
||||
After setting :attr to "1", the matcher expected the Example to be
|
||||
After setting :attr to ‹"1"›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ describe Shoulda::Matchers::ActiveModel::NumericalityMatchers::OddNumberMatcher
|
|||
end
|
||||
|
||||
message = <<-MESSAGE.strip_heredoc
|
||||
After setting :attr to "2", the matcher expected the Example to be
|
||||
After setting :attr to ‹"2"›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ describe Shoulda::Matchers::ActiveModel::NumericalityMatchers::OnlyIntegerMatche
|
|||
end
|
||||
|
||||
message = <<-MESSAGE
|
||||
After setting :attr to "0.1", the matcher expected the Example to be
|
||||
After setting :attr to ‹"0.1"›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
|
|
@ -42,8 +42,8 @@ describe Shoulda::Matchers::ActiveModel::ValidateAbsenceOfMatcher, type: :model
|
|||
|
||||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is empty/falsy.
|
||||
After setting :attr to "an arbitrary value", the matcher expected the
|
||||
Example to be invalid, but it was valid instead.
|
||||
After setting :attr to ‹"an arbitrary value"›, the matcher expected
|
||||
the Example to be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
assertion = lambda do
|
||||
|
@ -68,8 +68,8 @@ Example did not properly validate that :attr is empty/falsy.
|
|||
it 'rejects with the correct failure message' do
|
||||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is empty/falsy.
|
||||
After setting :attr to "an arbitrary value", the matcher expected the
|
||||
Example to be invalid, but it was valid instead.
|
||||
After setting :attr to ‹"an arbitrary value"›, the matcher expected
|
||||
the Example to be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
assertion = lambda do
|
||||
|
@ -106,7 +106,7 @@ Example did not properly validate that :attr is empty/falsy.
|
|||
|
||||
message = <<-MESSAGE
|
||||
Parent did not properly validate that :children is empty/falsy.
|
||||
After setting :children to [#<Child id: nil>], the matcher expected
|
||||
After setting :children to ‹[#<Child id: nil>]›, the matcher expected
|
||||
the Parent to be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
|
|
@ -82,8 +82,8 @@ on the Example, but that attribute does not exist.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that
|
||||
:attribute_to_confirm_confirmation matches :attribute_to_confirm.
|
||||
After setting :attribute_to_confirm_confirmation to "some value", then
|
||||
setting :attribute_to_confirm to "different value", the matcher
|
||||
After setting :attribute_to_confirm_confirmation to ‹"some value"›,
|
||||
then setting :attribute_to_confirm to ‹"different value"›, the matcher
|
||||
expected the Example to be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateExclusionOfMatcher, type: :mode
|
|||
matcher = validate_exclusion_of(:attr).in_range(1..10)
|
||||
|
||||
expect(matcher.description).to eq(
|
||||
'validate that :attr lies outside the range 1..10'
|
||||
'validate that :attr lies outside the range ‹1› to ‹10›'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -86,7 +86,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateExclusionOfMatcher, type: :mode
|
|||
context 'when there is one value' do
|
||||
it 'has correct description' do
|
||||
expect(validate_exclusion_of(:attr).in_array([true]).description).
|
||||
to eq 'validate that :attr is not true'
|
||||
to eq 'validate that :attr is not ‹true›'
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -95,7 +95,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateExclusionOfMatcher, type: :mode
|
|||
matcher = validate_exclusion_of(:attr).in_array([true, 'dog'])
|
||||
|
||||
expect(matcher.description).to eq(
|
||||
'validate that :attr is neither true nor "dog"'
|
||||
'validate that :attr is neither ‹true› nor ‹"dog"›'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -105,7 +105,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateExclusionOfMatcher, type: :mode
|
|||
matcher = validate_exclusion_of(:attr).in_array([true, 'dog', 'cat'])
|
||||
|
||||
expect(matcher.description).to eq(
|
||||
'validate that :attr is neither true, "dog", nor "cat"'
|
||||
'validate that :attr is neither ‹true›, ‹"dog"›, nor ‹"cat"›'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -686,7 +686,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
matcher = validate_inclusion_of(:attr).in_array([true])
|
||||
|
||||
expect(matcher.description).to eq(
|
||||
'validate that :attr is true'
|
||||
'validate that :attr is ‹true›'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -696,7 +696,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
matcher = validate_inclusion_of(:attr).in_array([true, 'dog'])
|
||||
|
||||
expect(matcher.description).to eq(
|
||||
'validate that :attr is either true or "dog"'
|
||||
'validate that :attr is either ‹true› or ‹"dog"›'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -706,7 +706,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
matcher = validate_inclusion_of(:attr).in_array([true, 'dog', 'cat'])
|
||||
|
||||
expect(matcher.description).to eq(
|
||||
'validate that :attr is either true, "dog", or "cat"'
|
||||
'validate that :attr is either ‹true›, ‹"dog"›, or ‹"cat"›'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
@ -717,7 +717,7 @@ describe Shoulda::Matchers::ActiveModel::ValidateInclusionOfMatcher, type: :mode
|
|||
matcher = validate_inclusion_of(:attr).in_range(1..10)
|
||||
|
||||
expect(matcher.description).to eq(
|
||||
'validate that :attr lies inside the range 1..10'
|
||||
'validate that :attr lies inside the range ‹1› to ‹10›'
|
||||
)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -172,8 +172,8 @@ describe Shoulda::Matchers::ActiveModel::ValidateNumericalityOfMatcher, type: :m
|
|||
|
||||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like a number.
|
||||
After setting :attr to "abcd", the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
After setting :attr to ‹"abcd"›, the matcher expected the Example to
|
||||
be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
expect(&assertion).to fail_with_message(message)
|
||||
|
@ -200,8 +200,8 @@ Example did not properly validate that :attr looks like a number.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like a number, but
|
||||
only if it is not nil.
|
||||
In checking that Example allows :attr to be nil, after setting :attr
|
||||
to nil, the matcher expected the Example to be valid, but it was
|
||||
In checking that Example allows :attr to be ‹nil›, after setting :attr
|
||||
to ‹nil›, the matcher expected the Example to be valid, but it was
|
||||
invalid instead, producing these validation errors:
|
||||
|
||||
* attr: ["is not a number"]
|
||||
|
@ -230,7 +230,7 @@ only if it is not nil.
|
|||
|
||||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like an integer.
|
||||
After setting :attr to "0.1", the matcher expected the Example to be
|
||||
After setting :attr to ‹"0.1"›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -290,7 +290,7 @@ Example did not properly validate that :attr looks like an integer.
|
|||
|
||||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like an odd number.
|
||||
After setting :attr to "2", the matcher expected the Example to be
|
||||
After setting :attr to ‹"2"›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -350,7 +350,7 @@ Example did not properly validate that :attr looks like an odd number.
|
|||
|
||||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like an even number.
|
||||
After setting :attr to "1", the matcher expected the Example to be
|
||||
After setting :attr to ‹"1"›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -413,7 +413,7 @@ Example did not properly validate that :attr looks like an even number.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like a number less
|
||||
than or equal to 18.
|
||||
After setting :attr to "19", the matcher expected the Example to be
|
||||
After setting :attr to ‹"19"›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -476,7 +476,7 @@ than or equal to 18.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like a number less
|
||||
than 18.
|
||||
After setting :attr to "19", the matcher expected the Example to be
|
||||
After setting :attr to ‹"19"›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -537,7 +537,7 @@ than 18.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like a number equal
|
||||
to 18.
|
||||
After setting :attr to "19", the matcher expected the Example to be
|
||||
After setting :attr to ‹"19"›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -609,7 +609,7 @@ to 18.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like a number greater
|
||||
than or equal to 18.
|
||||
After setting :attr to "17", the matcher expected the Example to be
|
||||
After setting :attr to ‹"17"›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -678,7 +678,7 @@ than or equal to 18.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like a number greater
|
||||
than 18.
|
||||
After setting :attr to "18", the matcher expected the Example to be
|
||||
After setting :attr to ‹"18"›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -706,10 +706,10 @@ than 18.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like a number,
|
||||
producing a custom validation error on failure.
|
||||
After setting :attr to "abcd", the matcher expected the Example to be
|
||||
invalid and to produce a validation error matching /wrong/ on :attr.
|
||||
The record was indeed invalid, but it produced these validation errors
|
||||
instead:
|
||||
After setting :attr to ‹"abcd"›, the matcher expected the Example to
|
||||
be invalid and to produce a validation error matching ‹/wrong/› on
|
||||
:attr. The record was indeed invalid, but it produced these validation
|
||||
errors instead:
|
||||
|
||||
* attr: ["custom"]
|
||||
MESSAGE
|
||||
|
@ -736,8 +736,8 @@ producing a custom validation error on failure.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like a number,
|
||||
producing a custom validation error on failure.
|
||||
After setting :attr to "abcd", the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
After setting :attr to ‹"abcd"›, the matcher expected the Example to
|
||||
be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
expect(&assertion).to fail_with_message(message)
|
||||
|
@ -764,9 +764,9 @@ producing a custom validation error on failure.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like a number,
|
||||
raising a validation exception on failure.
|
||||
After setting :attr to "abcd", the matcher expected the Example to be
|
||||
invalid and to raise a validation exception, but the record produced
|
||||
validation errors instead.
|
||||
After setting :attr to ‹"abcd"›, the matcher expected the Example to
|
||||
be invalid and to raise a validation exception, but the record
|
||||
produced validation errors instead.
|
||||
MESSAGE
|
||||
|
||||
expect(&assertion).to fail_with_message(message)
|
||||
|
@ -798,8 +798,8 @@ raising a validation exception on failure.
|
|||
|
||||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr looks like a number.
|
||||
After setting :attr to "abcd", the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
After setting :attr to ‹"abcd"›, the matcher expected the Example to
|
||||
be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
expect(&assertion).to fail_with_message(message)
|
||||
|
@ -837,7 +837,7 @@ Example did not properly validate that :attr looks like a number.
|
|||
Example did not properly validate that :attr looks like an integer
|
||||
greater than 18.
|
||||
In checking that Example disallows :attr from being a decimal number,
|
||||
after setting :attr to "0.1", the matcher expected the Example to be
|
||||
after setting :attr to ‹"0.1"›, the matcher expected the Example to be
|
||||
invalid and to produce the validation error "must be an integer" on
|
||||
:attr. The record was indeed invalid, but it produced these validation
|
||||
errors instead:
|
||||
|
@ -862,7 +862,7 @@ greater than 18.
|
|||
Example did not properly validate that :attr looks like an integer
|
||||
greater than 18.
|
||||
In checking that Example disallows :attr from being a decimal number,
|
||||
after setting :attr to "0.1", the matcher expected the Example to be
|
||||
after setting :attr to ‹"0.1"›, the matcher expected the Example to be
|
||||
invalid and to produce the validation error "must be an integer" on
|
||||
:attr. The record was indeed invalid, but it produced these validation
|
||||
errors instead:
|
||||
|
@ -890,8 +890,8 @@ greater than 18.
|
|||
Example did not properly validate that :attr looks like an even number
|
||||
greater than 18.
|
||||
In checking that Example disallows :attr from being a number that is
|
||||
not greater than 18, after setting :attr to "18", the matcher expected
|
||||
the Example to be invalid, but it was valid instead.
|
||||
not greater than 18, after setting :attr to ‹"18"›, the matcher
|
||||
expected the Example to be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
expect(&assertion).to fail_with_message(message)
|
||||
|
@ -914,7 +914,7 @@ greater than 18.
|
|||
Example did not properly validate that :attr looks like an even number
|
||||
greater than 18.
|
||||
In checking that Example disallows :attr from being an odd number,
|
||||
after setting :attr to "1", the matcher expected the Example to be
|
||||
after setting :attr to ‹"1"›, the matcher expected the Example to be
|
||||
invalid and to produce the validation error "must be even" on :attr.
|
||||
The record was indeed invalid, but it produced these validation errors
|
||||
instead:
|
||||
|
@ -942,7 +942,7 @@ greater than 18.
|
|||
Example did not properly validate that :attr looks like an odd number
|
||||
less than or equal to 99.
|
||||
In checking that Example disallows :attr from being a number that is
|
||||
not less than or equal to 99, after setting :attr to "101", the
|
||||
not less than or equal to 99, after setting :attr to ‹"101"›, the
|
||||
matcher expected the Example to be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -968,8 +968,8 @@ less than or equal to 99.
|
|||
Example did not properly validate that :attr looks like an integer
|
||||
greater than 18 and less than 99.
|
||||
In checking that Example disallows :attr from being a number that is
|
||||
not greater than 18, after setting :attr to "18", the matcher expected
|
||||
the Example to be invalid, but it was valid instead.
|
||||
not greater than 18, after setting :attr to ‹"18"›, the matcher
|
||||
expected the Example to be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
expect(&assertion).to fail_with_message(message)
|
||||
|
@ -995,10 +995,10 @@ greater than 18 and less than 99.
|
|||
Example did not properly validate that :attr looks like an integer
|
||||
greater than 18.
|
||||
In checking that Example disallows :attr from being a number that is
|
||||
not greater than 18, after setting :attr to "18", the matcher expected
|
||||
the Example to be invalid and to produce the validation error "must be
|
||||
greater than 18" on :attr. The record was indeed invalid, but it
|
||||
produced these validation errors instead:
|
||||
not greater than 18, after setting :attr to ‹"18"›, the matcher
|
||||
expected the Example to be invalid and to produce the validation error
|
||||
"must be greater than 18" on :attr. The record was indeed invalid, but
|
||||
it produced these validation errors instead:
|
||||
|
||||
* attr: ["must be greater than 19"]
|
||||
MESSAGE
|
||||
|
@ -1023,8 +1023,8 @@ greater than 18.
|
|||
Example did not properly validate that :attr looks like an integer
|
||||
greater than 18.
|
||||
In checking that Example disallows :attr from being a number that is
|
||||
not greater than 18, after setting :attr to "18", the matcher expected
|
||||
the Example to be invalid, but it was valid instead.
|
||||
not greater than 18, after setting :attr to ‹"18"›, the matcher
|
||||
expected the Example to be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
expect(&assertion).to fail_with_message(message)
|
||||
|
@ -1048,10 +1048,10 @@ greater than 18.
|
|||
Example did not properly validate that :attr looks like an even number
|
||||
greater than 18.
|
||||
In checking that Example disallows :attr from being a number that is
|
||||
not greater than 18, after setting :attr to "18", the matcher expected
|
||||
the Example to be invalid and to produce the validation error "must be
|
||||
greater than 18" on :attr. The record was indeed invalid, but it
|
||||
produced these validation errors instead:
|
||||
not greater than 18, after setting :attr to ‹"18"›, the matcher
|
||||
expected the Example to be invalid and to produce the validation error
|
||||
"must be greater than 18" on :attr. The record was indeed invalid, but
|
||||
it produced these validation errors instead:
|
||||
|
||||
* attr: ["must be greater than 20"]
|
||||
MESSAGE
|
||||
|
@ -1076,8 +1076,8 @@ greater than 18.
|
|||
Example did not properly validate that :attr looks like an even number
|
||||
greater than 18.
|
||||
In checking that Example disallows :attr from being a number that is
|
||||
not greater than 18, after setting :attr to "18", the matcher expected
|
||||
the Example to be invalid, but it was valid instead.
|
||||
not greater than 18, after setting :attr to ‹"18"›, the matcher
|
||||
expected the Example to be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
expect(&assertion).to fail_with_message(message)
|
||||
|
@ -1100,7 +1100,7 @@ greater than 18.
|
|||
Example did not properly validate that :attr looks like an odd number
|
||||
less than or equal to 99.
|
||||
In checking that Example disallows :attr from being a number that is
|
||||
not less than or equal to 99, after setting :attr to "101", the
|
||||
not less than or equal to 99, after setting :attr to ‹"101"›, the
|
||||
matcher expected the Example to be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -1124,7 +1124,7 @@ less than or equal to 99.
|
|||
Example did not properly validate that :attr looks like an odd number
|
||||
less than or equal to 99.
|
||||
In checking that Example disallows :attr from being a number that is
|
||||
not less than or equal to 99, after setting :attr to "101", the
|
||||
not less than or equal to 99, after setting :attr to ‹"101"›, the
|
||||
matcher expected the Example to be invalid and to produce the
|
||||
validation error "must be less than or equal to 99" on :attr. The
|
||||
record was indeed invalid, but it produced these validation errors
|
||||
|
@ -1156,10 +1156,10 @@ less than or equal to 99.
|
|||
Example did not properly validate that :attr looks like an integer
|
||||
greater than 18 and less than 99.
|
||||
In checking that Example disallows :attr from being a number that is
|
||||
not greater than 18, after setting :attr to "18", the matcher expected
|
||||
the Example to be invalid and to produce the validation error "must be
|
||||
greater than 18" on :attr. The record was indeed invalid, but it
|
||||
produced these validation errors instead:
|
||||
not greater than 18, after setting :attr to ‹"18"›, the matcher
|
||||
expected the Example to be invalid and to produce the validation error
|
||||
"must be greater than 18" on :attr. The record was indeed invalid, but
|
||||
it produced these validation errors instead:
|
||||
|
||||
* attr: ["must be greater than 19"]
|
||||
MESSAGE
|
||||
|
@ -1186,7 +1186,7 @@ greater than 18 and less than 99.
|
|||
Example did not properly validate that :attr looks like an integer
|
||||
greater than 18 and less than 99.
|
||||
In checking that Example disallows :attr from being a number that is
|
||||
not less than 99, after setting :attr to "100", the matcher expected
|
||||
not less than 99, after setting :attr to ‹"100"›, the matcher expected
|
||||
the Example to be invalid and to produce the validation error "must be
|
||||
less than 99" on :attr. The record was indeed invalid, but it produced
|
||||
these validation errors instead:
|
||||
|
|
|
@ -21,7 +21,7 @@ describe Shoulda::Matchers::ActiveModel::ValidatePresenceOfMatcher, type: :model
|
|||
|
||||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr cannot be empty/falsy.
|
||||
After setting :attr to nil, the matcher expected the Example to be
|
||||
After setting :attr to ‹nil›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -47,7 +47,7 @@ Example did not properly validate that :attr cannot be empty/falsy.
|
|||
|
||||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr cannot be empty/falsy.
|
||||
After setting :attr to nil, the matcher expected the Example to be
|
||||
After setting :attr to ‹nil›, the matcher expected the Example to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -105,7 +105,7 @@ Example did not properly validate that :attr cannot be empty/falsy.
|
|||
|
||||
message = <<-MESSAGE
|
||||
Parent did not properly validate that :children cannot be empty/falsy.
|
||||
After setting :children to [], the matcher expected the Parent to be
|
||||
After setting :children to ‹[]›, the matcher expected the Parent to be
|
||||
invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
|
@ -143,7 +143,7 @@ Parent did not properly validate that :children cannot be empty/falsy.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr cannot be empty/falsy,
|
||||
raising a validation exception on failure.
|
||||
After setting :attr to nil, the matcher expected the Example to be
|
||||
After setting :attr to ‹nil›, the matcher expected the Example to be
|
||||
invalid and to raise a validation exception, but the record produced
|
||||
validation errors instead.
|
||||
MESSAGE
|
||||
|
|
|
@ -247,9 +247,9 @@ within the scope of :non_existent1 and :non_existent2.
|
|||
|
||||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is case-sensitively unique.
|
||||
Given an existing Example whose :attr is "value", after making a new
|
||||
Example and setting its :attr to "value" as well, the matcher expected
|
||||
the new Example to be invalid, but it was valid instead.
|
||||
Given an existing Example whose :attr is ‹"value"›, after making a new
|
||||
Example and setting its :attr to ‹"value"› as well, the matcher
|
||||
expected the new Example to be invalid, but it was valid instead.
|
||||
MESSAGE
|
||||
|
||||
expect(&assertion).to fail_with_message(message)
|
||||
|
@ -347,9 +347,9 @@ within the scope of :other.
|
|||
|
||||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is case-sensitively unique.
|
||||
After taking the given Example, setting its :attr to "an arbitrary
|
||||
value", and saving it as the existing record, then making a new
|
||||
Example and setting its :attr to "an arbitrary value" as well, the
|
||||
After taking the given Example, setting its :attr to ‹"an arbitrary
|
||||
value"›, and saving it as the existing record, then making a new
|
||||
Example and setting its :attr to ‹"an arbitrary value"› as well, the
|
||||
matcher expected the new Example to be invalid and to produce the
|
||||
validation error "has already been taken" on :attr. The record was
|
||||
indeed invalid, but it produced these validation errors instead:
|
||||
|
@ -377,9 +377,9 @@ Example did not properly validate that :attr is case-sensitively unique.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is case-sensitively unique,
|
||||
producing a custom validation error on failure.
|
||||
After taking the given Example, setting its :attr to "an arbitrary
|
||||
value", and saving it as the existing record, then making a new
|
||||
Example and setting its :attr to "an arbitrary value" as well, the
|
||||
After taking the given Example, setting its :attr to ‹"an arbitrary
|
||||
value"›, and saving it as the existing record, then making a new
|
||||
Example and setting its :attr to ‹"an arbitrary value"› as well, the
|
||||
matcher expected the new Example to be invalid and to produce the
|
||||
validation error "some message" on :attr. The record was indeed
|
||||
invalid, but it produced these validation errors instead:
|
||||
|
@ -419,11 +419,11 @@ producing a custom validation error on failure.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is case-sensitively unique,
|
||||
producing a custom validation error on failure.
|
||||
After taking the given Example, setting its :attr to "an arbitrary
|
||||
value", and saving it as the existing record, then making a new
|
||||
Example and setting its :attr to "an arbitrary value" as well, the
|
||||
After taking the given Example, setting its :attr to ‹"an arbitrary
|
||||
value"›, and saving it as the existing record, then making a new
|
||||
Example and setting its :attr to ‹"an arbitrary value"› as well, the
|
||||
matcher expected the new Example to be invalid and to produce a
|
||||
validation error matching /some message/ on :attr. The record was
|
||||
validation error matching ‹/some message/› on :attr. The record was
|
||||
indeed invalid, but it produced these validation errors instead:
|
||||
|
||||
* attr: ["something else entirely"]
|
||||
|
@ -672,11 +672,11 @@ within the scope of :scope1.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is case-insensitively
|
||||
unique.
|
||||
After taking the given Example, setting its :attr to "an arbitrary
|
||||
value", and saving it as the existing record, then making a new
|
||||
Example and setting its :attr to a different value, "AN ARBITRARY
|
||||
VALUE", the matcher expected the new Example to be invalid, but it was
|
||||
valid instead.
|
||||
After taking the given Example, setting its :attr to ‹"an arbitrary
|
||||
value"›, and saving it as the existing record, then making a new
|
||||
Example and setting its :attr to a different value, ‹"AN ARBITRARY
|
||||
VALUE"›, the matcher expected the new Example to be invalid, but it
|
||||
was valid instead.
|
||||
MESSAGE
|
||||
|
||||
expect(&assertion).to fail_with_message(message)
|
||||
|
@ -698,10 +698,10 @@ unique.
|
|||
|
||||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is case-sensitively unique.
|
||||
After taking the given Example, setting its :attr to "an arbitrary
|
||||
value", and saving it as the existing record, then making a new
|
||||
Example and setting its :attr to a different value, "AN ARBITRARY
|
||||
VALUE", the matcher expected the new Example to be valid, but it was
|
||||
After taking the given Example, setting its :attr to ‹"an arbitrary
|
||||
value"›, and saving it as the existing record, then making a new
|
||||
Example and setting its :attr to a different value, ‹"AN ARBITRARY
|
||||
VALUE"›, the matcher expected the new Example to be valid, but it was
|
||||
invalid instead, producing these validation errors:
|
||||
|
||||
* attr: ["has already been taken"]
|
||||
|
@ -775,9 +775,9 @@ Example did not properly validate that :attr is case-sensitively unique.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is case-sensitively unique,
|
||||
but only if it is not nil.
|
||||
After taking the given Example, setting its :attr to nil, and saving
|
||||
After taking the given Example, setting its :attr to ‹nil›, and saving
|
||||
it as the existing record, then making a new Example and setting its
|
||||
:attr to nil as well, the matcher expected the new Example to be
|
||||
:attr to ‹nil› as well, the matcher expected the new Example to be
|
||||
valid, but it was invalid instead, producing these validation errors:
|
||||
|
||||
* attr: ["has already been taken"]
|
||||
|
@ -799,10 +799,10 @@ but only if it is not nil.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is case-sensitively unique,
|
||||
but only if it is not nil.
|
||||
Given an existing Example whose :attr is nil, after making a new
|
||||
Example and setting its :attr to nil as well, the matcher expected the
|
||||
new Example to be valid, but it was invalid instead, producing these
|
||||
validation errors:
|
||||
Given an existing Example whose :attr is ‹nil›, after making a new
|
||||
Example and setting its :attr to ‹nil› as well, the matcher expected
|
||||
the new Example to be valid, but it was invalid instead, producing
|
||||
these validation errors:
|
||||
|
||||
* attr: ["has already been taken"]
|
||||
MESSAGE
|
||||
|
@ -904,10 +904,10 @@ but only if it is not nil.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is case-sensitively unique,
|
||||
but only if it is not blank.
|
||||
After taking the given Example, setting its :attr to "", and saving it
|
||||
as the existing record, then making a new Example and setting its
|
||||
:attr to "" as well, the matcher expected the new Example to be valid,
|
||||
but it was invalid instead, producing these validation errors:
|
||||
After taking the given Example, setting its :attr to ‹""›, and saving
|
||||
it as the existing record, then making a new Example and setting its
|
||||
:attr to ‹""› as well, the matcher expected the new Example to be
|
||||
valid, but it was invalid instead, producing these validation errors:
|
||||
|
||||
* attr: ["has already been taken"]
|
||||
MESSAGE
|
||||
|
@ -928,10 +928,10 @@ but only if it is not blank.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is case-sensitively unique,
|
||||
but only if it is not blank.
|
||||
Given an existing Example, after setting its :attr to "", then making
|
||||
a new Example and setting its :attr to "" as well, the matcher
|
||||
expected the new Example to be valid, but it was invalid instead,
|
||||
producing these validation errors:
|
||||
Given an existing Example, after setting its :attr to ‹""›, then
|
||||
making a new Example and setting its :attr to ‹""› as well, the
|
||||
matcher expected the new Example to be valid, but it was invalid
|
||||
instead, producing these validation errors:
|
||||
|
||||
* attr: ["has already been taken"]
|
||||
MESSAGE
|
||||
|
@ -954,10 +954,10 @@ but only if it is not blank.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is case-sensitively unique,
|
||||
but only if it is not blank.
|
||||
After taking the given Example, setting its :attr to "", and saving it
|
||||
as the existing record, then making a new Example and setting its
|
||||
:attr to "" as well, the matcher expected the new Example to be valid,
|
||||
but it was invalid instead, producing these validation errors:
|
||||
After taking the given Example, setting its :attr to ‹""›, and saving
|
||||
it as the existing record, then making a new Example and setting its
|
||||
:attr to ‹""› as well, the matcher expected the new Example to be
|
||||
valid, but it was invalid instead, producing these validation errors:
|
||||
|
||||
* attr: ["has already been taken"]
|
||||
MESSAGE
|
||||
|
@ -980,10 +980,10 @@ but only if it is not blank.
|
|||
message = <<-MESSAGE
|
||||
Example did not properly validate that :attr is case-sensitively unique,
|
||||
but only if it is not blank.
|
||||
Given an existing Example whose :attr is "", after making a new
|
||||
Example and setting its :attr to "" as well, the matcher expected the
|
||||
new Example to be valid, but it was invalid instead, producing these
|
||||
validation errors:
|
||||
Given an existing Example whose :attr is ‹""›, after making a new
|
||||
Example and setting its :attr to ‹""› as well, the matcher expected
|
||||
the new Example to be valid, but it was invalid instead, producing
|
||||
these validation errors:
|
||||
|
||||
* attr: ["has already been taken"]
|
||||
MESSAGE
|
||||
|
|
Loading…
Reference in a new issue