Skip to content

Instantly share code, notes, and snippets.

@d6y
Created March 15, 2012 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save d6y/2044351 to your computer and use it in GitHub Desktop.
Save d6y/2044351 to your computer and use it in GitHub Desktop.
cigar
import org.specs2.runner._
import org.specs2.mutable._
import org.junit.runner._
import com.codecommit.antixml._
@RunWith(classOf[JUnitRunner])
class NoCigar extends Specification {
val anti: com.codecommit.antixml.Elem = XML.fromString("<hi>there</hi>")
val xml: scala.xml.Elem = <hi>there</hi>
"When comparing XML and Anti-MML" should {
// We know this works, but we don't like the toString
"toString should work" in {
anti.toString must_== xml.toString
}
// This is the case we'd like to pass with == rather than !=
"direct comparison doesn't work" in {
anti must_!= xml
}
// Version without toString
"Anti's convert does work" in {
anti must_== xml.convert
}
// Bringing into scope an implicit to give us as new comparison
// that knows about the different XML libraries
"Anti's convert does work" in {
implicit def matcherPimp(left: com.codecommit.antixml.Elem) = new {
def xml_==(right: com.codecommit.antixml.Elem) = left must_== right
def xml_==(right: scala.xml.Elem) = left must_== right.convert
}
anti xml_== xml
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment