This method enables the following syntax:
This method enables the following syntax:
"hi" should not have (length (3)) ^
This reason ResultOfLengthWordApplication
is a HavePropertyMatcher[AnyRef, Long]
is
so that you don't have to remember whether length
needs to be surrounded by parentheses when following
have
. Only length
and size
can be used without parentheses: everything else
needs the parentheses. So this approach means that if you use the unneeded parentheses with length
and
size
, it will still work. This apply
method uses reflection to find and access the length
property on the passed objectWithProperty
. Therefore if the object does not have the appropriate structure, the expression
will compile, but at will produce a TestFailedException
at runtime.
the object with the property against which to match
the HavePropertyMatchResult
that represents the result of the match
This class is part of the ScalaTest matchers DSL. Please see the documentation for
ShouldMatchers
orMustMatchers
for an overview of the matchers DSL.