diff --git a/build.sbt b/build.sbt
index 728f0e4..1a2575c 100644
--- a/build.sbt
+++ b/build.sbt
@@ -5,8 +5,8 @@ import sbtrelease.ReleasePlugin.autoImport._
inThisBuild(
Seq(
organization := "software.purpledragon.xml",
- scalaVersion := "2.13.1",
- crossScalaVersions := Seq(scalaVersion.value, "2.11.12", "2.12.10"),
+ scalaVersion := "2.13.2",
+ crossScalaVersions := Seq(scalaVersion.value, "2.11.12", "2.12.11"),
licenses += ("Apache-2.0", url("https://opensource.org/licenses/Apache-2.0")),
developers := List(
Developer("stringbean", "Michael Stringer", "@the_stringbean", url("https://github.com/stringbean"))
@@ -24,7 +24,7 @@ inThisBuild(
scalacOptions ++= Seq(s"-target:jvm-$javaVersion", "-deprecation", "-feature", "-unchecked"),
// dependencies common for all sub-projects
libraryDependencies ++= Seq(
- "org.scala-lang.modules" %% "scala-xml" % "1.2.0"
+ "org.scala-lang.modules" %% "scala-xml" % "1.3.0"
),
))
@@ -70,6 +70,7 @@ lazy val root = Project("scala-xml-compare", file("."))
),
// sbt-release settings
releaseCrossBuild := true,
+ releaseVcsSign := true,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies,
inquireVersions,
diff --git a/project/build.properties b/project/build.properties
index 8522443..654fe70 100644
--- a/project/build.properties
+++ b/project/build.properties
@@ -1 +1 @@
-sbt.version=1.3.2
+sbt.version=1.3.12
diff --git a/project/plugins.sbt b/project/plugins.sbt
index 75f26a9..5def8fc 100644
--- a/project/plugins.sbt
+++ b/project/plugins.sbt
@@ -1,17 +1,17 @@
// code style
addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0")
-addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0")
-addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.15")
-addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.0.0")
+addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
+addSbtPlugin("com.lucidchart" % "sbt-scalafmt" % "1.16")
+addSbtPlugin("de.heikoseeberger" % "sbt-header" % "5.6.0")
// artifact publishing
-addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.4")
-addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0")
-addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.11")
+addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.6")
+addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.1")
+addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
// documentation
-addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.2")
+addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3")
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.4.0")
-addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.6.5")
+addSbtPlugin("com.lightbend.paradox" % "sbt-paradox" % "0.8.0")
addSbtPlugin("com.thoughtworks.sbt-api-mappings" % "sbt-api-mappings" % "3.0.0")
diff --git a/xml-compare/build.sbt b/xml-compare/build.sbt
index 6c3a0f7..66b644e 100644
--- a/xml-compare/build.sbt
+++ b/xml-compare/build.sbt
@@ -1,5 +1,5 @@
name := "xml-compare"
libraryDependencies ++= Seq(
- "org.scalatest" %% "scalatest" % "3.0.8" % Test
+ "org.scalatest" %% "scalatest" % "3.1.2" % Test
)
diff --git a/xml-compare/src/main/scala/software/purpledragon/xml/compare/XmlCompare.scala b/xml-compare/src/main/scala/software/purpledragon/xml/compare/XmlCompare.scala
index 36e2e77..8309bf6 100644
--- a/xml-compare/src/main/scala/software/purpledragon/xml/compare/XmlCompare.scala
+++ b/xml-compare/src/main/scala/software/purpledragon/xml/compare/XmlCompare.scala
@@ -28,15 +28,10 @@ import scala.xml._
object XmlCompare {
private type Check = (Node, Node, DiffOptions, Seq[String]) => XmlDiff
- private implicit val NodeOrdering = NormalisedNodeOrdering
+ private implicit val NodeOrdering: NormalisedNodeOrdering.type = NormalisedNodeOrdering
- /**
- * Default [[software.purpledragon.xml.compare.options.DiffOption.DiffOption DiffOption]]s to use during XML comparison.
- *
- * Currently these are:
- * - [[software.purpledragon.xml.compare.options.DiffOption.IgnoreNamespacePrefix IgnoreNamespacePrefix]]
- */
- val DefaultOptions: DiffOptions = Set(IgnoreNamespacePrefix)
+ @deprecated(message = "use DiffOptions.Default", since = "2.0.0")
+ val DefaultOptions: DiffOptions = DiffOptions.default
/**
* Compares two XML documents. This will perform a recursive scan of all the nodes in each document, checking each
@@ -47,7 +42,7 @@ object XmlCompare {
* @param options configuration options to control the way the comparison is performed.
* @return results of the XML comparison.
*/
- def compare(left: Node, right: Node, options: DiffOptions = DefaultOptions): XmlDiff = {
+ def compare(left: Node, right: Node, options: DiffOptions = DiffOptions.default): XmlDiff = {
compareNodes(left, right, options, Nil)
}
@@ -72,10 +67,10 @@ object XmlCompare {
private def compareNamespace(left: Node, right: Node, options: DiffOptions, path: Seq[String]): XmlDiff = {
if (left.label != right.label) {
XmlDiffers("different label", left.label, right.label, extendPath(path, left))
- } else if (left.namespace != right.namespace && !options.contains(IgnoreNamespace)) {
+ } else if (left.namespace != right.namespace && options.isDisabled(IgnoreNamespace)) {
XmlDiffers("different namespace", left.namespace, right.namespace, extendPath(path, left))
- } else if (left.prefix != right.prefix && !options.contains(IgnoreNamespacePrefix) &&
- !options.contains(IgnoreNamespace)) {
+ } else if (left.prefix != right.prefix && options.isDisabled(IgnoreNamespacePrefix) &&
+ options.isDisabled(IgnoreNamespace)) {
XmlDiffers("different namespace prefix", left.prefix, right.prefix, extendPath(path, left))
} else {
XmlEqual
@@ -88,7 +83,7 @@ object XmlCompare {
if (leftKeys.sorted != rightKeys.sorted) {
XmlDiffers("different attribute names", leftKeys.sorted, rightKeys.sorted, extendPath(path, left))
- } else if (options.contains(StrictAttributeOrdering) && leftKeys != rightKeys) {
+ } else if (options.isEnabled(StrictAttributeOrdering) && leftKeys != rightKeys) {
XmlDiffers("different attribute ordering", leftKeys, rightKeys, extendPath(path, left))
} else {
leftKeys.sorted collectFirst {
@@ -134,7 +129,7 @@ object XmlCompare {
}
private def normalise(nodes: Seq[Node], options: DiffOptions): Seq[Node] = {
- val sort = options.contains(DiffOption.IgnoreChildOrder)
+ val sort = options.isEnabled(DiffOption.IgnoreChildOrder)
val filtered = nodes.filterNot(n => n.isInstanceOf[Atom[_]])
if (sort) {
diff --git a/xml-compare/src/main/scala/software/purpledragon/xml/compare/options/DiffOptions.scala b/xml-compare/src/main/scala/software/purpledragon/xml/compare/options/DiffOptions.scala
new file mode 100644
index 0000000..3c18302
--- /dev/null
+++ b/xml-compare/src/main/scala/software/purpledragon/xml/compare/options/DiffOptions.scala
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2017 Michael Stringer
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package software.purpledragon.xml.compare.options
+
+object DiffOptions {
+
+ /**
+ * Default [[DiffOption DiffOption]]s to use during XML comparison.
+ *
+ * Currently these are:
+ * - [[DiffOption.IgnoreNamespacePrefix IgnoreNamespacePrefix]]
+ */
+ val default: DiffOptions = DiffOptions(DiffOption.IgnoreNamespacePrefix)
+ val empty: DiffOptions = DiffOptions()
+
+ def apply(options: DiffOption.DiffOption*): DiffOptions = DiffOptions(options.toSet)
+}
+
+case class DiffOptions(options: Set[DiffOption.DiffOption]) {
+ def &(option: DiffOption.DiffOption): DiffOptions = copy(options = options + option)
+ def &!(option: DiffOption.DiffOption): DiffOptions = copy(options = options - option)
+
+ def +(option: DiffOption.DiffOption): DiffOptions = copy(options = options + option)
+ def -(option: DiffOption.DiffOption): DiffOptions = copy(options = options - option)
+
+ def isEnabled(option: DiffOption.DiffOption): Boolean = options.contains(option)
+ def isDisabled(option: DiffOption.DiffOption): Boolean = !options.contains(option)
+}
diff --git a/xml-compare/src/main/scala/software/purpledragon/xml/compare/options/package.scala b/xml-compare/src/main/scala/software/purpledragon/xml/compare/options/package.scala
deleted file mode 100644
index 5d26d97..0000000
--- a/xml-compare/src/main/scala/software/purpledragon/xml/compare/options/package.scala
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * Copyright 2017 Michael Stringer
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package software.purpledragon.xml.compare
-
-import software.purpledragon.xml.compare.options.DiffOption.DiffOption
-
-package object options {
-
- /**
- * Shorthand for a collection of [[DiffOption]]s.
- */
- type DiffOptions = Set[DiffOption]
-}
diff --git a/xml-compare/src/test/scala/software/purpledragon/xml/XmlUtilsSpec.scala b/xml-compare/src/test/scala/software/purpledragon/xml/XmlUtilsSpec.scala
index 3c876e4..5d6f601 100644
--- a/xml-compare/src/test/scala/software/purpledragon/xml/XmlUtilsSpec.scala
+++ b/xml-compare/src/test/scala/software/purpledragon/xml/XmlUtilsSpec.scala
@@ -16,9 +16,10 @@
package software.purpledragon.xml
-import org.scalatest.{FlatSpec, Matchers}
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
-class XmlUtilsSpec extends FlatSpec with Matchers {
+class XmlUtilsSpec extends AnyFlatSpec with Matchers {
"XmlUtils.extractAttributes" should "return empty values for no attributes" in {
XmlUtils.extractAttributes() shouldBe (Nil, Map.empty[String, String])
}
diff --git a/xml-compare/src/test/scala/software/purpledragon/xml/compare/NormalisedNodeOrderingSpec.scala b/xml-compare/src/test/scala/software/purpledragon/xml/compare/NormalisedNodeOrderingSpec.scala
index 508a811..faba257 100644
--- a/xml-compare/src/test/scala/software/purpledragon/xml/compare/NormalisedNodeOrderingSpec.scala
+++ b/xml-compare/src/test/scala/software/purpledragon/xml/compare/NormalisedNodeOrderingSpec.scala
@@ -16,11 +16,12 @@
package software.purpledragon.xml.compare
-import org.scalatest.{FlatSpec, Matchers}
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
import scala.xml.{Comment, Node, PCData, Text}
-class NormalisedNodeOrderingSpec extends FlatSpec with Matchers {
+class NormalisedNodeOrderingSpec extends AnyFlatSpec with Matchers {
private implicit val ordering: Ordering[Node] = NormalisedNodeOrdering
"NormalisedNodeOrdering" should "order nodes by type" in {
diff --git a/xml-compare/src/test/scala/software/purpledragon/xml/compare/XmlCompareSpec.scala b/xml-compare/src/test/scala/software/purpledragon/xml/compare/XmlCompareSpec.scala
index d498b9d..2ad8baf 100644
--- a/xml-compare/src/test/scala/software/purpledragon/xml/compare/XmlCompareSpec.scala
+++ b/xml-compare/src/test/scala/software/purpledragon/xml/compare/XmlCompareSpec.scala
@@ -16,10 +16,12 @@
package software.purpledragon.xml.compare
-import org.scalatest.{FlatSpec, Matchers}
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
import software.purpledragon.xml.compare.options.DiffOption._
+import software.purpledragon.xml.compare.options.DiffOptions
-class XmlCompareSpec extends FlatSpec with Matchers {
+class XmlCompareSpec extends AnyFlatSpec with Matchers {
"compare with defaults" should "match same empty element" in {
XmlCompare.compare(, ) shouldBe XmlEqual
@@ -152,7 +154,7 @@ class XmlCompareSpec extends FlatSpec with Matchers {
XmlCompare.compare(
,
,
- Set.empty
+ DiffOptions.empty
) shouldBe XmlDiffers("different namespace prefix", "t", "e", Seq("t:test"))
}
@@ -160,7 +162,7 @@ class XmlCompareSpec extends FlatSpec with Matchers {
XmlCompare.compare(
,
,
- Set.empty
+ DiffOptions.empty
) shouldBe XmlEqual
}
@@ -168,7 +170,7 @@ class XmlCompareSpec extends FlatSpec with Matchers {
XmlCompare.compare(
,
,
- Set(IgnoreNamespace)
+ DiffOptions(IgnoreNamespace)
) shouldBe XmlEqual
}
@@ -176,7 +178,7 @@ class XmlCompareSpec extends FlatSpec with Matchers {
XmlCompare.compare(
,
,
- Set(IgnoreNamespace)
+ DiffOptions(IgnoreNamespace)
) shouldBe XmlEqual
}
@@ -184,7 +186,7 @@ class XmlCompareSpec extends FlatSpec with Matchers {
XmlCompare.compare(
,
,
- Set(StrictAttributeOrdering)
+ DiffOptions(StrictAttributeOrdering)
) shouldBe XmlEqual
}
@@ -192,7 +194,7 @@ class XmlCompareSpec extends FlatSpec with Matchers {
XmlCompare.compare(
,
,
- Set(StrictAttributeOrdering)
+ DiffOptions(StrictAttributeOrdering)
) shouldBe XmlDiffers(
"different attribute ordering",
Seq("first", "second"),
@@ -205,7 +207,7 @@ class XmlCompareSpec extends FlatSpec with Matchers {
XmlCompare.compare(
,
,
- Set(IgnoreChildOrder)
+ DiffOptions(IgnoreChildOrder)
) shouldBe XmlEqual
}
@@ -213,7 +215,7 @@ class XmlCompareSpec extends FlatSpec with Matchers {
XmlCompare.compare(
,
,
- Set(IgnoreChildOrder)
+ DiffOptions(IgnoreChildOrder)
) shouldBe XmlEqual
}
@@ -221,7 +223,7 @@ class XmlCompareSpec extends FlatSpec with Matchers {
XmlCompare.compare(
,
,
- Set(IgnoreChildOrder)
+ DiffOptions(IgnoreChildOrder)
) shouldBe XmlEqual
}
@@ -229,7 +231,7 @@ class XmlCompareSpec extends FlatSpec with Matchers {
XmlCompare.compare(
,
,
- Set(IgnoreChildOrder)
+ DiffOptions(IgnoreChildOrder)
) shouldBe XmlEqual
}
}
diff --git a/xml-compare/src/test/scala/software/purpledragon/xml/compare/options/DiffOptionsSpec.scala b/xml-compare/src/test/scala/software/purpledragon/xml/compare/options/DiffOptionsSpec.scala
new file mode 100644
index 0000000..e7e9ad0
--- /dev/null
+++ b/xml-compare/src/test/scala/software/purpledragon/xml/compare/options/DiffOptionsSpec.scala
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2017 Michael Stringer
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package software.purpledragon.xml.compare.options
+
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
+
+class DiffOptionsSpec extends AnyFlatSpec with Matchers {
+
+ "&" should "add an option" in {
+ val options = DiffOptions(DiffOption.IgnoreNamespace) & DiffOption.IgnoreChildOrder
+ options.options shouldBe Set(DiffOption.IgnoreNamespace, DiffOption.IgnoreChildOrder)
+ }
+
+ it should "not add a duplicate option" in {
+ val options = DiffOptions(DiffOption.IgnoreNamespace) & DiffOption.IgnoreNamespace
+ options.options shouldBe Set(DiffOption.IgnoreNamespace)
+ }
+
+ "&!" should "remove an option" in {
+ val options = DiffOptions(DiffOption.IgnoreNamespace, DiffOption.IgnoreChildOrder) &! DiffOption.IgnoreChildOrder
+ options.options shouldBe Set(DiffOption.IgnoreNamespace)
+ }
+
+ it should "do nothing if option not present" in {
+ val options = DiffOptions(DiffOption.IgnoreNamespace) &! DiffOption.IgnoreChildOrder
+ options.options shouldBe Set(DiffOption.IgnoreNamespace)
+ }
+
+ "+" should "add an option" in {
+ val options = DiffOptions(DiffOption.IgnoreNamespace) + DiffOption.IgnoreChildOrder
+ options.options shouldBe Set(DiffOption.IgnoreNamespace, DiffOption.IgnoreChildOrder)
+ }
+
+ it should "not add a duplicate option" in {
+ val options = DiffOptions(DiffOption.IgnoreNamespace) + DiffOption.IgnoreNamespace
+ options.options shouldBe Set(DiffOption.IgnoreNamespace)
+ }
+
+ "-" should "remove an option" in {
+ val options = DiffOptions(DiffOption.IgnoreNamespace, DiffOption.IgnoreChildOrder) - DiffOption.IgnoreChildOrder
+ options.options shouldBe Set(DiffOption.IgnoreNamespace)
+ }
+
+ it should "do nothing if option not present" in {
+ val options = DiffOptions(DiffOption.IgnoreNamespace) - DiffOption.IgnoreChildOrder
+ options.options shouldBe Set(DiffOption.IgnoreNamespace)
+ }
+
+ "isEnabled" should "return true if an option is enabled" in {
+ val options = DiffOptions(DiffOption.IgnoreNamespace)
+ options.isEnabled(DiffOption.IgnoreNamespace) shouldBe true
+ }
+
+ it should "return false if an option is disabled" in {
+ val options = DiffOptions.empty
+ options.isEnabled(DiffOption.IgnoreNamespace) shouldBe false
+ }
+
+ "isDisabled" should "return true if an option is disabled" in {
+ val options = DiffOptions(DiffOption.IgnoreNamespace)
+ options.isDisabled(DiffOption.IgnoreNamespace) shouldBe false
+ }
+
+ it should "return false if an option is enabled" in {
+ val options = DiffOptions.empty
+ options.isDisabled(DiffOption.IgnoreNamespace) shouldBe true
+ }
+}
diff --git a/xml-scalatest/build.sbt b/xml-scalatest/build.sbt
index aeb5c25..588db11 100644
--- a/xml-scalatest/build.sbt
+++ b/xml-scalatest/build.sbt
@@ -1,5 +1,5 @@
name := "xml-scalatest"
libraryDependencies ++= Seq(
- "org.scalatest" %% "scalatest" % "3.0.8" % Provided
+ "org.scalatest" %% "scalatest" % "3.1.2" % Provided
)
diff --git a/xml-scalatest/src/main/scala/software/purpledragon/xml/scalatest/XmlMatchers.scala b/xml-scalatest/src/main/scala/software/purpledragon/xml/scalatest/XmlMatchers.scala
index 7ee7e49..78d43a8 100644
--- a/xml-scalatest/src/main/scala/software/purpledragon/xml/scalatest/XmlMatchers.scala
+++ b/xml-scalatest/src/main/scala/software/purpledragon/xml/scalatest/XmlMatchers.scala
@@ -40,19 +40,18 @@ trait XmlMatchers {
* result should beXml(1)
* }}}
*
- * If unspecified this will use [[software.purpledragon.xml.compare.XmlCompare.DefaultOptions XmlCompare.DefaultOptions]]
- * during the comparison. This can be overridden with a global implicit of
- * [[software.purpledragon.xml.compare.options.DiffOptions DiffOptions]] or on an individual basis:
+ * If unspecified this will use [[DiffOptions.default]] during the comparison. This can be overridden with a global
+ * implicit of [[DiffOptions]] or on an individual basis:
*
* {{{
- * implicit val diffOptions: DiffOptions = Set(IgnoreNamespace)
+ * implicit val diffOptions: DiffOptions = DiffOptions(IgnoreNamespace)
* result should beXml(1)
*
* // or
- * result should beXml(1)(Set.empty)
+ * result should beXml(1)(DiffOptions.empty)
* }}}
*/
- def beXml(expected: Node)(implicit options: DiffOptions = XmlCompare.DefaultOptions): Matcher[Node] =
+ def beXml(expected: Node)(implicit options: DiffOptions = DiffOptions.default): Matcher[Node] =
new XmlMatcher(expected, options)
private class XmlMatcher(expected: Node, options: DiffOptions) extends Matcher[Node] {
diff --git a/xml-scalatest/src/test/scala/software/purpledragon/xml/scalatest/XmlMatchersSpec.scala b/xml-scalatest/src/test/scala/software/purpledragon/xml/scalatest/XmlMatchersSpec.scala
index 4fb2cfb..31538d4 100644
--- a/xml-scalatest/src/test/scala/software/purpledragon/xml/scalatest/XmlMatchersSpec.scala
+++ b/xml-scalatest/src/test/scala/software/purpledragon/xml/scalatest/XmlMatchersSpec.scala
@@ -16,10 +16,11 @@
package software.purpledragon.xml.scalatest
-import org.scalatest.{FlatSpec, Matchers}
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.matchers.should.Matchers
import software.purpledragon.xml.compare.options.DiffOptions
-class XmlMatchersSpec extends FlatSpec with Matchers with XmlMatchers {
+class XmlMatchersSpec extends AnyFlatSpec with Matchers with XmlMatchers {
"beXml(xml)" should "match identical XML" in {
val matcher = beXml(text)
@@ -68,7 +69,7 @@ class XmlMatchersSpec extends FlatSpec with Matchers with XmlMatchers {
}
"beXml(xml)(options)" should "not match XML with different namespace" in {
- val matcher = beXml(text)(Set.empty)
+ val matcher = beXml(text)(DiffOptions.empty)
val matchResult = matcher(text)
matchResult.matches shouldBe false
@@ -76,7 +77,7 @@ class XmlMatchersSpec extends FlatSpec with Matchers with XmlMatchers {
}
"beXml(xml) with implicit options" should "not match XML with different namespace" in {
- implicit val options: DiffOptions = Set.empty
+ implicit val options: DiffOptions = DiffOptions.empty
val matcher = beXml(text)
val matchResult = matcher(text)
diff --git a/xml-specs2/build.sbt b/xml-specs2/build.sbt
index e907227..accc974 100644
--- a/xml-specs2/build.sbt
+++ b/xml-specs2/build.sbt
@@ -1,5 +1,5 @@
name := "xml-specs2"
libraryDependencies ++= Seq(
- "org.specs2" %% "specs2-core" % "4.7.0" % Provided
+ "org.specs2" %% "specs2-core" % "4.9.4" % Provided
)
diff --git a/xml-specs2/src/main/scala/software/purpledragon/xml/specs2/XmlMatchers.scala b/xml-specs2/src/main/scala/software/purpledragon/xml/specs2/XmlMatchers.scala
index f9e3556..acd5756 100644
--- a/xml-specs2/src/main/scala/software/purpledragon/xml/specs2/XmlMatchers.scala
+++ b/xml-specs2/src/main/scala/software/purpledragon/xml/specs2/XmlMatchers.scala
@@ -41,33 +41,31 @@ trait XmlMatchers {
* result must beXml(1)
* }}}
*
- * If unspecified this will use [[software.purpledragon.xml.compare.XmlCompare.DefaultOptions XmlCompare.DefaultOptions]]
- * during the comparison. This can be overridden with a global implicit of
- * [[software.purpledragon.xml.compare.options.DiffOptions DiffOptions]] or on an individual basis:
+ * If unspecified this will use [[DiffOptions.default]] during the comparison. This can be overridden with a global
+ * implicit of [[DiffOptions]] or on an individual basis:
*
* {{{
- * implicit val diffOptions: DiffOptions = Set(IgnoreNamespace)
+ * implicit val diffOptions: DiffOptions = DiffOptions(IgnoreNamespace)
* result must beXml(1)
*
* // or
- * result must beXml(1)(Set.empty)
+ * result must beXml(1)(DiffOptions.empty)
* }}}
*/
- def beXml(expected: Node)(implicit options: DiffOptions = XmlCompare.DefaultOptions): Matcher[Node] = {
- actual: Node =>
- val diff = XmlCompare.compare(expected, actual, options)
+ def beXml(expected: Node)(implicit options: DiffOptions = DiffOptions.default): Matcher[Node] = { actual: Node =>
+ val diff = XmlCompare.compare(expected, actual, options)
- val failureBuilder = new StringBuilder()
- failureBuilder ++= "XML did not match"
+ val failureBuilder = new StringBuilder()
+ failureBuilder ++= "XML did not match"
- if (diff.failurePath.nonEmpty) {
- failureBuilder ++= " at "
- diff.failurePath.addString(failureBuilder, "[", " / ", "]")
- }
+ if (diff.failurePath.nonEmpty) {
+ failureBuilder ++= " at "
+ diff.failurePath.addString(failureBuilder, "[", " / ", "]")
+ }
- failureBuilder ++= ": "
- failureBuilder ++= diff.message
+ failureBuilder ++= ": "
+ failureBuilder ++= diff.message
- (diff.isEqual, "XML matched", failureBuilder.toString())
+ (diff.isEqual, "XML matched", failureBuilder.toString())
}
}
diff --git a/xml-specs2/src/test/scala/software/purpledragon/xml/specs2/XmlMatchersSpec.scala b/xml-specs2/src/test/scala/software/purpledragon/xml/specs2/XmlMatchersSpec.scala
index fd3dde3..e277496 100644
--- a/xml-specs2/src/test/scala/software/purpledragon/xml/specs2/XmlMatchersSpec.scala
+++ b/xml-specs2/src/test/scala/software/purpledragon/xml/specs2/XmlMatchersSpec.scala
@@ -73,7 +73,7 @@ class XmlMatchersSpec extends Specification with XmlMatchers with Expectations {
"beXml(xml)(options)" should {
"not match XML with different namespace" in {
- val matcher = beXml(text)(Set.empty)
+ val matcher = beXml(text)(DiffOptions.empty)
val matchResult = matcher(createExpectable(text))
matchResult.isSuccess === false
@@ -83,7 +83,7 @@ class XmlMatchersSpec extends Specification with XmlMatchers with Expectations {
"beXml(xml) with implicit options" should {
"not match XML with different namespace" in {
- implicit val options: DiffOptions = Set.empty
+ implicit val options: DiffOptions = DiffOptions.empty
val matcher = beXml(text)
val matchResult = matcher(createExpectable(text))