Skip to content

Instantly share code, notes, and snippets.

@dabd
Last active April 3, 2016 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dabd/1c550c8d394e5422622afe04b73f0994 to your computer and use it in GitHub Desktop.
Save dabd/1c550c8d394e5422622afe04b73f0994 to your computer and use it in GitHub Desktop.
package models
import org.scalacheck.Arbitrary._
import org.scalacheck.Shapeless._
import org.scalacheck._
import shapeless.tag
import shapeless.tag.{apply => _, _}
object ArbitraryModelsSpecification extends Properties("ArbitraryModelsSpecification") {
import Prop.forAll
// implicit val bigDecimalGen = arbBigDecimal.arbitrary.suchThat(d => d >= 0 && d <= BigDecimal("999999999999.99"))
implicit val bigDecimalGen = for {
i <- arbBigInt.arbitrary.suchThat(x => x >= 0 && x <= BigInt("999999999999"))
d <- Gen.chooseNum(0, 99)
} yield BigDecimal(s"$i.$d")
implicit val moneyGen: Gen[String @@ Money] = for(m <- bigDecimalGen) yield tag[Money](m.toString())
implicit val arbMoney: Arbitrary[String @@ Money] = Arbitrary(moneyGen)
property("someProp") = forAll { m: (String @@ Money) =>
println(m)
true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment