Skip to content

Instantly share code, notes, and snippets.

@lamdor
Created June 23, 2011 15:47
Show Gist options
  • Save lamdor/1042813 to your computer and use it in GitHub Desktop.
Save lamdor/1042813 to your computer and use it in GitHub Desktop.
package examples
import org.specs2.mutable.Specification
import org.specs2.specification.{Before, Scope}
class BeforeWeirdnessSpec extends Specification {
"Before" should {
"execute before the example with a object" in context1 {
1 must_== 1
}
"execute before the example with a trait" in new context2 {
1 must_== 1
}
}
object context1 extends Before {
def before = {
println("BEFORE (in context1)...")
()
}
}
trait context2 extends Scope with Before {
def before = {
println("BEFORE (in context2)...")
()
}
}
}
[info] == examples.BeforeWeirdnessSpec ==
BEFORE (in context1)...
[info] Before should
[info] + execute before the example with a object
[info] + execute before the example with a trait
[info]
[info]
[info] Total for specification BeforeWeirdnessSpec
[info] Finished in 177 ms
[info] 2 examples, 0 failure, 0 error
[info]
[info] == examples.BeforeWeirdnessSpec ==
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment