The problem here is that a Node is a Seq[Node], so it is looking on
ResultOfHaveWordForSeq[Node] instead of Have on AnyRef, because that
implicit is more specific. Or something like that. Having Node be a
Seq[Node] is a very questionable design choice, but to deal with it
you need to say Seq[Node] not Node when you make the
HavePropertyMatcher. This compiles:
import org.scalatest.matchers._
import org.scalatest._
import scala.xml.Node
trait NodeHaveMatchers {
def completeStatus(expectedValue: Boolean):
HavePropertyMatcher[Seq[Node], Boolean] = {
new HavePropertyMatcher[Seq[Node], Boolean] {
def apply(node: Seq[Node]) = {
HavePropertyMatchResult(
(node \ "@complete").toString.toBoolean == expectedValue,
"complete",
expectedValue,
(node \ "@complete").toString.toBoolean
)
}
}
}
}
class NodeSpec extends Spec with ShouldMatchers with NodeHaveMatchers {
describe("A node") {
it("should have the complete status") {
val summary: Node = <summary complete="true" />
summary should have (
completeStatus (true)
)
}
}
}
And runs too:
scala> import org.scalatest._
import org.scalatest._
scala> run(new NodeSpec)
NodeSpec:
A node
- should have the complete status
I'll think about whether I could do anything to make this smoother.
Bill
> --
> You received this message because you are subscribed to the Google
> Groups "scalatest-users" group.
> To post to this group, send email to scalate...@googlegroups.com
> To unsubscribe from this group, send email to
> scalatest-use...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/scalatest-users?hl=en
> ScalaTest itself, and documentation, is available here:
> http://www.artima.com/scalatest
--
Bill Venners
Artima, Inc.
http://www.artima.com