Skip to content

Commit

Permalink
Fix more styling issues, add badge
Browse files Browse the repository at this point in the history
  • Loading branch information
lloydmeta committed Feb 20, 2015
1 parent cd9c1c1 commit 54b7d44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# CSV binders for Play [![Build Status](https://travis-ci.org/lloydmeta/play-csv.svg?branch=master)](https://travis-ci.org/lloydmeta/play-csv) [![Coverage Status](https://coveralls.io/repos/lloydmeta/play-csv/badge.svg?branch=master)](https://coveralls.io/r/lloydmeta/play-csv?branch=master)
# CSV binders for Play [![Build Status](https://travis-ci.org/lloydmeta/play-csv.svg?branch=master)](https://travis-ci.org/lloydmeta/play-csv) [![Coverage Status](https://coveralls.io/repos/lloydmeta/play-csv/badge.svg?branch=master)](https://coveralls.io/r/lloydmeta/play-csv?branch=master) [![Codacy Badge](https://www.codacy.com/project/badge/011ba7adf75c4b26ac42dbd5e0d46f13)](https://www.codacy.com/public/lloydmeta/play-csv)

If you're reading this, you probably know what you want: CSV path, query and form binders for
your Play-based application.
Expand Down
14 changes: 8 additions & 6 deletions src/test/scala/com/beachape/play/CsvSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package com.beachape.play
import org.scalatest.{ Matchers, FunSpec }
import play.api.data.Form
import play.api.data.Forms._
import org.scalatest.OptionValues._
import org.scalatest.EitherValues._

class CsvSpec extends FunSpec with Matchers {

Expand All @@ -11,12 +13,12 @@ class CsvSpec extends FunSpec with Matchers {
val subject = Csv.queryStringBindable[Int]

it("should create a binder that can bind strings corresponding the proper type") {
subject.bind("hello", Map("hello" -> Seq("1,2,3"))).get.right.get shouldBe Csv(1, 2, 3)
subject.bind("hello", Map("hello" -> Seq("1"))).get.right.get shouldBe Csv(1)
subject.bind("hello", Map("hello" -> Seq("1,2,3"))).value.right.value shouldBe Csv(1, 2, 3)
subject.bind("hello", Map("hello" -> Seq("1"))).value.right.value shouldBe Csv(1)
}

it("should create a binder that cannot bind strings that don't correspond to the proper type") {
subject.bind("hello", Map("hello" -> Seq("this is the song that never ends, yes 1t goes on and on my friend"))).get should be('left)
subject.bind("hello", Map("hello" -> Seq("this is the song that never ends, yes 1t goes on and on my friend"))).value should be('left)
subject.bind("hello", Map("helloz" -> Seq("1.2, 3.4"))) shouldBe None
}

Expand All @@ -32,8 +34,8 @@ class CsvSpec extends FunSpec with Matchers {
val subject = Csv.pathStringBindable[Int]

it("should create a binder that can bind strings corresponding the proper type") {
subject.bind("hello", "1,2,3").right.get shouldBe Csv(1, 2, 3)
subject.bind("hello", "1").right.get shouldBe Csv(1)
subject.bind("hello", "1,2,3").right.value shouldBe Csv(1, 2, 3)
subject.bind("hello", "1").right.value shouldBe Csv(1)
}

it("should create a binder that cannot bind strings that don't correspond to the proper type") {
Expand All @@ -53,7 +55,7 @@ class CsvSpec extends FunSpec with Matchers {

it("should bind proper strings into a CsvSeq") {
val r1 = subject.bind(Map("hello" -> "1,2,3"))
r1.value.get shouldBe Csv(1, 2, 3)
r1.value.value shouldBe Csv(1, 2, 3)
}

it("should fail to bind random strings") {
Expand Down

0 comments on commit 54b7d44

Please sign in to comment.