Skip to content

Commit

Permalink
Add test for for-comprehensions with Validated values
Browse files Browse the repository at this point in the history
  • Loading branch information
ruippeixotog committed Mar 6, 2016
1 parent d513e54 commit 09e2054
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/test/scala/net/ruippeixotog/scalascraper/dsl/DSLSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,23 @@ class DSLSpec extends Specification {
useExtractor(ext1) mustEqual VSuccess(Some("Section 2"))
useExtractor(ext2) mustEqual VFailure(())
}

"support for comprehensions with Validated values" in {
val menu = doc >> element("#menu")

val text = for {
m <- menu ~/~ validator("span")(_.nonEmpty)
t = m >> stext(".active")
} yield t

text mustEqual VSuccess("Section 2")

val text2 = for {
m <- menu ~/~ validator(".active")(_.isEmpty)
t = m >> stext(".active")
} yield t

text2 mustEqual VFailure(())
}
}
}

0 comments on commit 09e2054

Please sign in to comment.