diff --git a/src/test/scala/com/gu/tip/HttpClientTest.scala b/src/test/scala/com/gu/tip/HttpClientTest.scala index 59cdb31..b337896 100644 --- a/src/test/scala/com/gu/tip/HttpClientTest.scala +++ b/src/test/scala/com/gu/tip/HttpClientTest.scala @@ -1,22 +1,22 @@ package com.gu.tip -import org.scalatest.FlatSpec +import org.scalatest.{FlatSpec, MustMatchers} -class HttpClientTest extends FlatSpec { +class HttpClientTest extends FlatSpec with MustMatchers { behavior of "HttpClient" it should "be able to make a GET request" in { object HttpClient extends HttpClient val (code, body) = HttpClient.get("http://example.com", ("Authorization","test")) - assert(code == 200) + code mustBe 200 } it should "be able to make a POST request" in { object HttpClient extends HttpClient val (code, body) = HttpClient.post("http://petstore.swagger.io/v2/pet", ("Authorization","test"), "{\"name\": \"doggie\"}") - assert(code == 200) + code mustBe 200 } } diff --git a/src/test/scala/com/gu/tip/NotifierTest.scala b/src/test/scala/com/gu/tip/NotifierTest.scala index bfa7cc4..b32233d 100644 --- a/src/test/scala/com/gu/tip/NotifierTest.scala +++ b/src/test/scala/com/gu/tip/NotifierTest.scala @@ -1,8 +1,8 @@ package com.gu.tip -import org.scalatest.FlatSpec +import org.scalatest.{FlatSpec, MustMatchers} -class NotifierTest extends FlatSpec { +class NotifierTest extends FlatSpec with MustMatchers { val mockCommitMessageResponse = """ @@ -27,7 +27,7 @@ class NotifierTest extends FlatSpec { object Notifier extends Notifier with GitHubApi with MockHttpClient - assert(Notifier.setLabelOnLatestMergedPr() != 200) + Notifier.setLabelOnLatestMergedPr() must not be 200 } behavior of "happy Notifier" @@ -43,6 +43,6 @@ class NotifierTest extends FlatSpec { object Notifier extends Notifier with GitHubApi with MockHttpClient - assert(Notifier.setLabelOnLatestMergedPr() == 200) + Notifier.setLabelOnLatestMergedPr() mustBe 200 } } diff --git a/src/test/scala/com/gu/tip/TipTest.scala b/src/test/scala/com/gu/tip/TipTest.scala index 1b6ac22..0fee0dd 100644 --- a/src/test/scala/com/gu/tip/TipTest.scala +++ b/src/test/scala/com/gu/tip/TipTest.scala @@ -1,9 +1,8 @@ package com.gu.tip -import org.scalatest.{AsyncFlatSpec} -import org.scalatest.Matchers._ +import org.scalatest.{AsyncFlatSpec, MustMatchers} -class TipTest extends AsyncFlatSpec { +class TipTest extends AsyncFlatSpec with MustMatchers { trait MockHttpClient extends HttpClient { override def get(endpoint: String = "", authHeader: (String, String) = ("", "")) = (200, "") override def post(endpoint: String = "", authHeader: (String, String) = ("", ""), jsonBody: String = "") = (200, "") @@ -14,7 +13,7 @@ class TipTest extends AsyncFlatSpec { behavior of "unhappy Tip" it should "error on bad path name" in { - Tip.verify("badName").map { result => assert(result == UnrecognizedPathName) } + Tip.verify("badName").map(_ mustBe UnrecognizedPathName) } it should "error on bad syntax path definition" in { @@ -22,14 +21,14 @@ class TipTest extends AsyncFlatSpec { override val pathConfigFilename: String = "tip-bad.yaml" } - Tip.verify("").map { result => assert(result == PathDefinitionSyntaxError) } + Tip.verify("").map( _ mustBe PathDefinitionSyntaxError) } it should "error on missing path definition file" in { object Tip extends Tip with Notifier with GitHubApi with MockHttpClient { override val pathConfigFilename: String = "tip-not-found.yaml" } - Tip.verify("").map { result => assert(result == PathDefinitionFileNotFound) } + Tip.verify("").map(_ mustBe PathDefinitionFileNotFound) } it should "error on unclassifed error" @@ -44,20 +43,16 @@ class TipTest extends AsyncFlatSpec { for { _ <- Tip.verify("Name A") result <- Tip.verify("Name B") - } yield { - assert(result == FailedToSetLabel) - } + } yield result mustBe FailedToSetLabel } behavior of "happy Tip" it should "verify a path" in { - Tip.verify("Name A").map { result => assert(result == PathVerified) } - + Tip.verify("Name A").map(_ mustBe PathVerified) } it should "set the label when all paths are verified" in { - trait MockNotifier extends NotifierIf {this: GitHubApiIf => override def setLabelOnLatestMergedPr(): Int = 200 } @@ -67,13 +62,10 @@ class TipTest extends AsyncFlatSpec { for { _ <- Tip.verify("Name A") result <- Tip.verify("Name B") - } yield { - assert(result == LabelSet) - } + } yield result mustBe LabelSet } it should "set the label only once" in { - trait MockNotifier extends NotifierIf {this: GitHubApiIf => override def setLabelOnLatestMergedPr(): Int = 200 } @@ -85,8 +77,6 @@ class TipTest extends AsyncFlatSpec { _ <- Tip.verify("Name B") _ <- Tip.verify("Name A") result <- Tip.verify("Name B") - } yield { - assert(result == LabelAlreadySet) - } + } yield result mustBe LabelAlreadySet } } \ No newline at end of file diff --git a/src/test/scala/com/gu/tip/YamlPathConfigReaderTest.scala b/src/test/scala/com/gu/tip/YamlPathConfigReaderTest.scala index 97ef8bc..a86fca7 100644 --- a/src/test/scala/com/gu/tip/YamlPathConfigReaderTest.scala +++ b/src/test/scala/com/gu/tip/YamlPathConfigReaderTest.scala @@ -1,10 +1,9 @@ import java.io.FileNotFoundException -import org.scalatest.FlatSpec -import org.scalatest.Matchers._ +import org.scalatest.{FlatSpec, Matchers} import com.gu.tip.{EnrichedPath, Path, Paths, YamlPathConfigReader} -class YamlPathConfigReaderTest extends FlatSpec { +class YamlPathConfigReaderTest extends FlatSpec with Matchers { "YamlPathConfigReader" should "convert tip.yaml definition to Paths type" in { YamlPathConfigReader("tip.yaml") shouldBe a [Paths] @@ -39,7 +38,7 @@ class YamlPathConfigReaderTest extends FlatSpec { val enrichedPath = new EnrichedPath(Path("Path Name", "Path Description")) val paths = new Paths(Map("Path Name" -> enrichedPath)) paths.verify("Path Name") - assert(paths.allVerified) + paths shouldBe 'allVerified } it should "verify a path only if it has not been verified before" in { @@ -48,6 +47,6 @@ class YamlPathConfigReaderTest extends FlatSpec { val paths = new Paths(Map("Path Name A" -> enrichedPathA, "Path Name B" -> enrichedPathB)) paths.verify("Path Name A") paths.verify("Path Name A") - assert(!paths.allVerified) + paths should not be 'allVerified } } \ No newline at end of file