Skip to content

Instantly share code, notes, and snippets.

View dariathecracker's full-sized avatar

Daria dariathecracker

View GitHub Profile
@dariathecracker
dariathecracker / ioleo.tictactoe.scala
Last active June 4, 2020 11:43
MenuCommandParser.>.parse
object > extends MenuCommandParser.Service[MenuCommandParser] {
def parse(input: String) =
ZIO.accessM(_.menuCommandParser.parse(input))
}
@dariathecracker
dariathecracker / ioleo.tictactoe.scala
Last active June 4, 2020 11:43
Behaviour runnable specification
package ioleo.tictactoe.parser
import ioleo.tictactoe.domain.MenuCommand
import zio.test.{assertM, checkM, suite, testM, DefaultRunnableSpec, Gen}
import zio.test.Assertion.equalTo
import MenuCommandParserSpecUtils._
object MenuCommandParserSpec extends DefaultRunnableSpec(
suite("MenuCommandParser")(
@dariathecracker
dariathecracker / ioleo.tictactoe.scala
Last active June 4, 2020 12:08
Define live implementation
package ioleo.tictactoe.parser
import ioleo.tictactoe.domain.MenuCommand
import zio.UIO
trait MenuCommandParserLive extends MenuCommandParser {
val menuCommandParser = new MenuCommandParser.Service[Any] {
def parse(input: String): UIO[MenuCommand] = ???
@dariathecracker
dariathecracker / ioleo.tictactoe.scala
Last active June 4, 2020 12:08
Dependency in SBT build
libraryDependencies ++= Seq(
"dev.zio" %% "zio-macros-core" % "0.5.0",
"dev.zio" %% "zio-macros-test" % "0.5.0"
)
@dariathecracker
dariathecracker / ioleo.tictactoe.scala
Last active June 4, 2020 12:09
MenuCommandParser
package ioleo.tictactoe.parser
import ioleo.tictactoe.domain.MenuCommand
import zio.ZIO
import zio.macros.annotation.{accessible, mockable}
@accessible(">")
@mockable
trait MenuCommandParser {
package ioleo.tictactoe.domain
sealed trait MenuCommand
object MenuCommand {
case object NewGame extends MenuCommand
case object Resume extends MenuCommand
case object Quit extends MenuCommand
case object Invalid extends MenuCommand
}
package ioleo.tictactoe
import zio.test.{assert, suite, testM, DefaultRunnableSpec}
import zio.test.environment.TestConsole
import zio.test.Assertion.equalTo
object TicTacToeSpec extends DefaultRunnableSpec(
suite("TicTacToe")(
testM("prints to console") {
for {
libraryDependencies ++= Seq(
"dev.zio" %% "zio-test" % "1.0.0-RC16" % "test",
"dev.zio" %% "zio-test-sbt" % "1.0.0-RC16" % "test"
),
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework"))
libraryDependencies ++= Seq(
"dev.zio" %% "zio-test" % "1.0.0-RC16" % "test",
"dev.zio" %% "zio-test-sbt" % "1.0.0-RC16" % "test"
),
testFrameworks := Seq(new TestFramework("zio.test.sbt.ZTestFramework"))
libraryDependencies += "dev.zio" %% "zio" % "1.0.0-RC16"