Created
March 15, 2012 14:04
-
-
Save d6y/2044351 to your computer and use it in GitHub Desktop.
cigar
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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