forked from davegurnell/checklist
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue davegurnell#1: Fix ExecutionContext in context tests.
- Loading branch information
Showing
1 changed file
with
3 additions
and
10 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,10 @@ import monix.execution.Scheduler | |
import org.scalatest.{AsyncFreeSpec, Matchers} | ||
|
||
import scala.collection.immutable.HashSet | ||
import scala.concurrent.{ExecutionContext, Future} | ||
import scala.concurrent.Future | ||
|
||
class ContextSpec extends AsyncFreeSpec with Matchers { | ||
implicit override def executionContext: Scheduler = monix.execution.Scheduler.Implicits.global | ||
|
||
val rule1 = Rule.pass[Int] | ||
val rule2 = rule1.liftTo[Future] | ||
|
@@ -36,7 +37,7 @@ class ContextSpec extends AsyncFreeSpec with Matchers { | |
override def apply[A](f: Future[A]): Task[A] = Task.deferFuture(f) | ||
} | ||
|
||
def taskToFuture(implicit ec: ExecutionContext, sch: Scheduler): Task ~> Future = new (Task ~> Future) { | ||
def taskToFuture: Task ~> Future = new (Task ~> Future) { | ||
override def apply[A](t: Task[A]): Future[A] = t.runAsync | ||
} | ||
|
||
|
@@ -73,17 +74,13 @@ class ContextSpec extends AsyncFreeSpec with Matchers { | |
} | ||
|
||
"Task unique email" in { | ||
import monix.execution.Scheduler.Implicits.global | ||
|
||
val validator = isEmail and isUniqueTask | ||
validator("[email protected]").runAsync map (_ should be(Ior.right("[email protected]"))) | ||
validator("[email protected]").runAsync map (_ should be(Ior.left(errors("Email is already registered")))) | ||
validator("hello@").runAsync map (_ should be(Ior.left(errors("Must be an email")))) | ||
} | ||
|
||
"Id, Future and Task unique non-empty email (as Task)" in { | ||
import monix.execution.Scheduler.Implicits.global | ||
|
||
implicit val transformation: Future ~> Task = futureToTask | ||
|
||
val validator = Rule.nonEmpty[String] and isUniqueTask and isEmailFuture | ||
|
@@ -94,8 +91,6 @@ class ContextSpec extends AsyncFreeSpec with Matchers { | |
} | ||
|
||
"Id, Future and Task unique non-empty email (as Future)" in { | ||
import monix.execution.Scheduler.Implicits.global | ||
|
||
implicit val transformation: Task ~> Future = taskToFuture | ||
|
||
val validator = isUniqueTask and isEmailFuture and Rule.nonEmpty[String] | ||
|
@@ -106,8 +101,6 @@ class ContextSpec extends AsyncFreeSpec with Matchers { | |
} | ||
|
||
"IO, Future and Task unique non-empty email (as Future)" in { | ||
import monix.execution.Scheduler.Implicits.global | ||
|
||
implicit val transformation1: Task ~> Future = taskToFuture | ||
implicit val transformation2: IO ~> Future = ioToFuture | ||
|
||
|