WIP
This commit is contained in:
parent
1fc0848d62
commit
3d007a2b0e
|
@ -134,7 +134,8 @@ module Shoulda
|
|||
elsif expects_strict?
|
||||
message << 'However, no such exception was raised.'
|
||||
else
|
||||
message << 'However, no such error was found.'
|
||||
message << 'However, no such error was found on '
|
||||
message << ":#{attribute_to_check_message_against}."
|
||||
end
|
||||
elsif validator.captured_validation_exception?
|
||||
message << 'The record was invalid, but it'
|
||||
|
@ -153,18 +154,20 @@ module Shoulda
|
|||
def negative_aberration_description
|
||||
validator = result.validator
|
||||
|
||||
description = 'However, '
|
||||
# description = 'However, '
|
||||
|
||||
if validator.captured_validation_exception?
|
||||
description << ' it raised a validation exception with the message '
|
||||
description << validator.validation_exception_message.inspect
|
||||
description << '.'
|
||||
else
|
||||
description << " it produced these validation errors:\n\n"
|
||||
description << validator.all_formatted_validation_error_messages
|
||||
end
|
||||
# if validator.captured_validation_exception?
|
||||
# description << ' it raised a validation exception with the message '
|
||||
# description << validator.validation_exception_message.inspect
|
||||
# description << '.'
|
||||
# else
|
||||
# description << " it produced these validation errors:\n\n"
|
||||
# description << validator.all_formatted_validation_error_messages
|
||||
# end
|
||||
|
||||
description
|
||||
# description
|
||||
|
||||
"However, it did."
|
||||
end
|
||||
|
||||
def expectation_clauses_for_values_to_preset
|
||||
|
|
|
@ -312,15 +312,20 @@ module Shoulda
|
|||
def expectation
|
||||
error_type_clause =
|
||||
if expects_strict?
|
||||
'raise a validation exception'
|
||||
'raising an exception'
|
||||
else
|
||||
'produce the validation error'
|
||||
'placing the error'
|
||||
end
|
||||
|
||||
if expected_message
|
||||
preface =
|
||||
"not to fail validation by #{error_type_clause} " +
|
||||
"#{expected_message.inspect} on " +
|
||||
":#{attribute_to_check_message_against}"
|
||||
|
||||
ValidationMatcher::BuildExpectation.call(
|
||||
self,
|
||||
"not to #{error_type_clause} #{expected_message.inspect}",
|
||||
preface,
|
||||
state: :valid,
|
||||
)
|
||||
else
|
||||
|
|
|
@ -10,15 +10,20 @@ module Shoulda
|
|||
def expectation
|
||||
error_type_clause =
|
||||
if expects_strict?
|
||||
'raise a validation exception'
|
||||
'raising an exception'
|
||||
else
|
||||
'produce the validation error'
|
||||
'placing the error'
|
||||
end
|
||||
|
||||
if expected_message
|
||||
preface =
|
||||
"to fail validation by #{error_type_clause} " +
|
||||
"#{expected_message.inspect} on " +
|
||||
":#{attribute_to_check_message_against}"
|
||||
|
||||
ValidationMatcher::BuildExpectation.call(
|
||||
self,
|
||||
"to #{error_type_clause} #{expected_message.inspect}",
|
||||
preface,
|
||||
state: :invalid,
|
||||
)
|
||||
else
|
||||
|
|
|
@ -62,8 +62,9 @@ Your test expecting Example to validate absence of :attr didn't pass.
|
|||
The matcher ran the following subtests. Those indicated with ✘ failed
|
||||
when they should have passed:
|
||||
|
||||
✘ Expected Example to be invalid with :attr set to ‹"an arbitrary
|
||||
value"›. However, it was valid.
|
||||
✘ Expected Example to fail validation by placing the error "must be
|
||||
blank" on :attr with :attr set to ‹"an arbitrary value"›. However, no
|
||||
such error was found on :attr.
|
||||
MESSAGE
|
||||
|
||||
assertion = lambda do
|
||||
|
@ -105,8 +106,9 @@ Your test expecting Example to validate absence of :attr didn't pass.
|
|||
The matcher ran the following subtests. Those indicated with ✘ failed
|
||||
when they should have passed:
|
||||
|
||||
✘ Expected Example to be invalid with :attr set to ‹"an arbitrary
|
||||
value"›. However, it was valid.
|
||||
✘ Expected Example to fail validation by placing the error "must be
|
||||
blank" on :attr with :attr set to ‹"an arbitrary value"›. However, no
|
||||
such error was found on :attr.
|
||||
MESSAGE
|
||||
|
||||
assertion = lambda do
|
||||
|
@ -173,8 +175,9 @@ Your test expecting Parent to validate absence of :children didn't pass.
|
|||
The matcher ran the following subtests. Those indicated with ✘ failed
|
||||
when they should have passed:
|
||||
|
||||
✘ Expected Parent to be invalid with :children set to ‹[#<Child id:
|
||||
nil>]›. However, it was valid.
|
||||
✘ Expected Parent to fail validation by placing the error "must be
|
||||
blank" on :children with :children set to ‹[#<Child id: nil>]›.
|
||||
However, no such error was found on :children.
|
||||
MESSAGE
|
||||
|
||||
assertion = lambda do
|
||||
|
|
|
@ -26,8 +26,9 @@ Your test expecting Example to validate acceptance of :attr didn't pass.
|
|||
The matcher ran the following subtests. Those indicated with ✘ failed
|
||||
when they should have passed:
|
||||
|
||||
✘ Expected Example to be invalid with :attr set to ‹false› (which was
|
||||
read back as ‹nil›). However, it was valid.
|
||||
✘ Expected Example to fail validation by placing the error "must be
|
||||
accepted" on :attr with :attr set to ‹false› (which was read back as
|
||||
‹nil›). However, no such error was found on :attr.
|
||||
|
||||
As indicated above, :attr seems to be changing certain values as they
|
||||
are set, and this could have something to do with why this matcher is
|
||||
|
|
|
@ -42,17 +42,20 @@ pass.
|
|||
The matcher ran the following subtests. Those indicated with ✘ failed
|
||||
when they should have passed:
|
||||
|
||||
✔︎ Expected Example to be invalid with :password_confirmation set to
|
||||
‹"some value"› and :password set to ‹"different value"› (which was
|
||||
read back as ‹"different valuf"›).
|
||||
✘ Expected Example to be valid with :password_confirmation set to ‹"same
|
||||
value"› and :password set to ‹"same value"› (which was read back as
|
||||
‹"same valuf"›). However, it produced these validation errors:
|
||||
✔︎ Expected Example to fail validation by placing the error "doesn't
|
||||
match Password" on :password_confirmation with :password_confirmation
|
||||
set to ‹"some value"› and :password set to ‹"different value"› (which
|
||||
was read back as ‹"different valuf"›).
|
||||
|
||||
* password_confirmation: ["doesn't match Password"]
|
||||
✔︎ Expected Example to be valid with :password_confirmation set to ‹nil›
|
||||
and :password set to ‹"any value"› (which was read back as ‹"any
|
||||
valuf"›).
|
||||
✘ Expected Example not to fail validation by placing the error "doesn't
|
||||
match Password" on :password_confirmation with :password_confirmation
|
||||
set to ‹"same value"› and :password set to ‹"same value"› (which was
|
||||
read back as ‹"same valuf"›). However, it did.
|
||||
|
||||
✔︎ Expected Example not to fail validation by placing the error "doesn't
|
||||
match Password" on :password_confirmation with :password_confirmation
|
||||
set to ‹nil› and :password set to ‹"any value"› (which was read back
|
||||
as ‹"any valuf"›).
|
||||
|
||||
As indicated above, :password seems to be changing certain values as
|
||||
they are set, and this could have something to do with why this matcher
|
||||
|
@ -123,13 +126,21 @@ Your test expecting Example to validate confirmation of
|
|||
The matcher ran the following subtests. Those indicated with ✘ failed
|
||||
when they should have passed:
|
||||
|
||||
✘ Expected Example to be invalid with :attribute_to_confirm_confirmation
|
||||
set to ‹"some value"› and :attribute_to_confirm set to ‹"different
|
||||
value"›. However, it was valid.
|
||||
✔︎ Expected Example to be valid with :attribute_to_confirm_confirmation
|
||||
set to ‹"same value"› and :attribute_to_confirm set to ‹"same value"›.
|
||||
✔︎ Expected Example to be valid with :attribute_to_confirm_confirmation
|
||||
set to ‹nil› and :attribute_to_confirm set to ‹"any value"›.
|
||||
✘ Expected Example to fail validation by placing the error "doesn't
|
||||
match Attribute to confirm" on :attribute_to_confirm_confirmation with
|
||||
:attribute_to_confirm_confirmation set to ‹"some value"› and
|
||||
:attribute_to_confirm set to ‹"different value"›. However, no such
|
||||
error was found on :attribute_to_confirm_confirmation.
|
||||
|
||||
✔︎ Expected Example not to fail validation by placing the error "doesn't
|
||||
match Attribute to confirm" on :attribute_to_confirm_confirmation with
|
||||
:attribute_to_confirm_confirmation set to ‹"same value"› and
|
||||
:attribute_to_confirm set to ‹"same value"›.
|
||||
|
||||
✔︎ Expected Example not to fail validation by placing the error "doesn't
|
||||
match Attribute to confirm" on :attribute_to_confirm_confirmation with
|
||||
:attribute_to_confirm_confirmation set to ‹nil› and
|
||||
:attribute_to_confirm set to ‹"any value"›.
|
||||
MESSAGE
|
||||
|
||||
expect(&assertion).to fail_with_message(message)
|
||||
|
|
|
@ -31,19 +31,19 @@ range ‹2› to ‹5› didn't pass.
|
|||
The matcher ran the following subtests. Those indicated with ✘ failed
|
||||
when they should have passed:
|
||||
|
||||
✘ Expected Example to be valid with :attr set to ‹1› (which was read
|
||||
back as ‹2›). However, it produced these validation errors:
|
||||
✘ Expected Example not to fail validation by placing the error "is
|
||||
reserved" on :attr with :attr set to ‹1› (which was read back as ‹2›).
|
||||
However, it did.
|
||||
|
||||
* attr: ["is reserved"]
|
||||
✔︎ Expected Example to fail validation by placing the error "is reserved"
|
||||
on :attr with :attr set to ‹2› (which was read back as ‹3›).
|
||||
|
||||
✔︎ Expected Example to be invalid with :attr set to ‹2› (which was read
|
||||
back as ‹3›).
|
||||
✔︎ Expected Example not to fail validation by placing the error "is
|
||||
reserved" on :attr with :attr set to ‹6› (which was read back as ‹7›).
|
||||
|
||||
✔︎ Expected Example to be valid with :attr set to ‹6› (which was read
|
||||
back as ‹7›).
|
||||
|
||||
✘ Expected Example to be invalid with :attr set to ‹5› (which was read
|
||||
back as ‹6›). However, it was valid.
|
||||
✘ Expected Example to fail validation by placing the error "is reserved"
|
||||
on :attr with :attr set to ‹5› (which was read back as ‹6›). However,
|
||||
no such error was found on :attr.
|
||||
|
||||
As indicated above, :attr seems to be changing certain values as they
|
||||
are set, and this could have something to do with why this matcher is
|
||||
|
@ -179,11 +179,13 @@ nor ‹"two"› didn't pass.
|
|||
The matcher ran the following subtests. Those indicated with ✘ failed
|
||||
when they should have passed:
|
||||
|
||||
✘ Expected Example to be invalid with :attr set to ‹"one"› (which was
|
||||
read back as ‹"onf"›). However, it was valid.
|
||||
✘ Expected Example to fail validation by placing the error "is reserved"
|
||||
on :attr with :attr set to ‹"one"› (which was read back as ‹"onf"›).
|
||||
However, no such error was found on :attr.
|
||||
|
||||
✘ Expected Example to be invalid with :attr set to ‹"two"› (which was
|
||||
read back as ‹"twp"›). However, it was valid.
|
||||
✘ Expected Example to fail validation by placing the error "is reserved"
|
||||
on :attr with :attr set to ‹"two"› (which was read back as ‹"twp"›).
|
||||
However, no such error was found on :attr.
|
||||
|
||||
As indicated above, :attr seems to be changing certain values as they
|
||||
are set, and this could have something to do with why this matcher is
|
||||
|
|
|
@ -39,13 +39,13 @@ least 4 didn't pass.
|
|||
The matcher ran the following subtests. Those indicated with ✘ failed
|
||||
when they should have passed:
|
||||
|
||||
✘ Expected Example to produce the validation error "is too short
|
||||
(minimum is 4 characters)" with :attr set to ‹"xxx"› (which was read
|
||||
back as ‹"xxxa"›). However, no such error was found.
|
||||
✘ Expected Example to fail validation by placing the error "is too short
|
||||
(minimum is 4 characters)" on :attr with :attr set to ‹"xxx"› (which
|
||||
was read back as ‹"xxxa"›). However, no such error was found on :attr.
|
||||
|
||||
✔︎ Expected Example not to produce the validation error "is too short
|
||||
(minimum is 4 characters)" with :attr set to ‹"xxxx"› (which was read
|
||||
back as ‹"xxxxa"›).
|
||||
✔︎ Expected Example not to fail validation by placing the error "is too
|
||||
short (minimum is 4 characters)" on :attr with :attr set to ‹"xxxx"›
|
||||
(which was read back as ‹"xxxxa"›).
|
||||
|
||||
As indicated above, :attr seems to be changing certain values as they
|
||||
are set, and this could have something to do with why this matcher is
|
||||
|
@ -111,13 +111,13 @@ most 4 didn't pass.
|
|||
The matcher ran the following subtests. Those indicated with ✘ failed
|
||||
when they should have passed:
|
||||
|
||||
✘ Expected Example to produce the validation error "is too long (maximum
|
||||
is 4 characters)" with :attr set to ‹"xxxxx"› (which was read back as
|
||||
‹"xxxx"›). However, no such error was found.
|
||||
✘ Expected Example to fail validation by placing the error "is too long
|
||||
(maximum is 4 characters)" on :attr with :attr set to ‹"xxxxx"› (which
|
||||
was read back as ‹"xxxx"›). However, no such error was found on :attr.
|
||||
|
||||
✔︎ Expected Example not to produce the validation error "is too long
|
||||
(maximum is 4 characters)" with :attr set to ‹"xxxx"› (which was read
|
||||
back as ‹"xxx"›).
|
||||
✔︎ Expected Example not to fail validation by placing the error "is too
|
||||
long (maximum is 4 characters)" on :attr with :attr set to ‹"xxxx"›
|
||||
(which was read back as ‹"xxx"›).
|
||||
|
||||
As indicated above, :attr seems to be changing certain values as they
|
||||
are set, and this could have something to do with why this matcher is
|
||||
|
@ -176,27 +176,22 @@ didn't pass.
|
|||
The matcher ran the following subtests. Those indicated with ✘ failed
|
||||
when they should have passed:
|
||||
|
||||
✘ Expected Example to produce the validation error "is the wrong length
|
||||
(should be 4 characters)" with :attr set to ‹"xxx"› (which was read
|
||||
back as ‹"xxxa"›). However, no such error was found.
|
||||
✘ Expected Example to fail validation by placing the error "is the wrong
|
||||
length (should be 4 characters)" on :attr with :attr set to ‹"xxx"›
|
||||
(which was read back as ‹"xxxa"›). However, no such error was found on
|
||||
:attr.
|
||||
|
||||
✘ Expected Example not to produce the validation error "is the wrong
|
||||
length (should be 4 characters)" with :attr set to ‹"xxxx"› (which was
|
||||
read back as ‹"xxxxa"›). However, it produced these validation
|
||||
errors:
|
||||
✘ Expected Example not to fail validation by placing the error "is the
|
||||
wrong length (should be 4 characters)" on :attr with :attr set to
|
||||
‹"xxxx"› (which was read back as ‹"xxxxa"›). However, it did.
|
||||
|
||||
* attr: ["is the wrong length (should be 4 characters)"]
|
||||
✔︎ Expected Example to fail validation by placing the error "is the wrong
|
||||
length (should be 4 characters)" on :attr with :attr set to ‹"xxxxx"›
|
||||
(which was read back as ‹"xxxxxa"›).
|
||||
|
||||
✔︎ Expected Example to produce the validation error "is the wrong length
|
||||
(should be 4 characters)" with :attr set to ‹"xxxxx"› (which was read
|
||||
back as ‹"xxxxxa"›).
|
||||
|
||||
✘ Expected Example not to produce the validation error "is the wrong
|
||||
length (should be 4 characters)" with :attr set to ‹"xxxx"› (which was
|
||||
read back as ‹"xxxxa"›). However, it produced these validation
|
||||
errors:
|
||||
|
||||
* attr: ["is the wrong length (should be 4 characters)"]
|
||||
✘ Expected Example not to fail validation by placing the error "is the
|
||||
wrong length (should be 4 characters)" on :attr with :attr set to
|
||||
‹"xxxx"› (which was read back as ‹"xxxxa"›). However, it did.
|
||||
|
||||
As indicated above, :attr seems to be changing certain values as they
|
||||
are set, and this could have something to do with why this matcher is
|
||||
|
|
Loading…
Reference in New Issue