Skip to content

Commit

Permalink
Support they
Browse files Browse the repository at this point in the history
  • Loading branch information
bigwheel committed Oct 11, 2018
1 parent 3e8710d commit ece5b28
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/scala/com/github/bigwheel/scalatest/FunSpecEx.scala
Expand Up @@ -44,6 +44,26 @@ class FunSpecEx extends FunSpec {

}

override protected val they: TheyWord = new TheyWord() {

override def apply(specText: String, testTags: Tag*)
(testFun: => Any /* Assertion */)
(implicit pos: source.Position): Unit = {
tree = tree.insert(SpecText(specText).right[DescriptionWithBefore].leaf)
super.apply(specText, testTags: _*)(testFun)(pos)
}

}

override protected def describe(description: String)
(fun: => Unit)
(implicit pos: source.Position): Unit = {
val backup = tree
tree = DescriptionWithBefore(description, () => ()).left[SpecText].node()
super.describe(description)(fun)(pos)
tree = backup.insert(tree)
}

protected[this] def describeWithBefore(description: String)
(before: => Unit)
(fun: => Unit)
Expand Down
13 changes: 13 additions & 0 deletions src/test/scala/com/github/bigwheel/scalatest/FunSpecExSpec.scala
Expand Up @@ -31,6 +31,19 @@ class FunSpecExSpec extends FunSpecEx with Matchers {
}
}
}

describe("with normal description") {
describeWithBefore("works correctly (+ 9)") { subject += 9 } {
it("is 9") {
subject should be(9)
}

they("`they` also be able to be used") {
subject should be(9)
}
}
}

}

}

0 comments on commit ece5b28

Please sign in to comment.