Last active
December 16, 2015 13:39
-
-
Save poetix/5443366 to your computer and use it in GitHub Desktop.
Demonstrating a Map matcher with improved failure reporting
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
package com.youdevise.matchless | |
import org.specs2.matcher.MustMatchers._ | |
import com.youdevise.matchless.Collections._ | |
object HasThePairsWorksheet { | |
val testMap = Map( | |
"a" -> "Apple", | |
"b" -> "Banana", | |
"c" -> "Carrot" | |
) //> testMap : scala.collection.immutable.Map[java.lang.String,java.lang.String] | |
//| = Map(a -> Apple, b -> Banana, c -> Carrot) | |
(testMap must haveThePairs( | |
"a" -> "Apple", | |
"b" -> "Banana", | |
"c" -> "Cactus", | |
"d" -> "Dragonfruit" | |
)).message //> res0: String = some of the expected key/value pairs were not present in the | |
//| collection: | |
//| | |
//| a: Apple | |
//| b: Banana | |
//| * c: 'Carrot' is not equal to 'Cactus' | |
//| * d: <missing value> | |
(testMap must havePairsLike( | |
"a" -> contain("pp"), | |
"b" -> contain("anana"), | |
"c" -> contain("actus") | |
)).message //> res1: String = some of the expected key/value pairs were not present in the | |
//| collection: | |
//| | |
//| a: Apple | |
//| b: Banana | |
//| * c: 'Carrot' doesn't contain 'actus' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment