Skip to content

Commit

Permalink
added a check for the use of Expectations with Scope. fixes #321. fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
etorreborre committed Jan 22, 2015
1 parent 05eb653 commit 226d84b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Expand Up @@ -8,7 +8,7 @@ import org.specs2.execute.Result
* This trait provides implicit definitions to transform any value into a MustExpectable
*/
trait MustExpectations extends Expectations {
implicit def akaMust[T](tm: Expectable[T]) = new MustExpectable(() => tm.valueDefinition()) {
implicit def akaMust[T](tm: Expectable[T]): MustExpectable[T] = new MustExpectable(() => tm.valueDefinition()) {
override private[specs2] val desc = tm.desc
override private[specs2] val showValueAs = tm.showValueAs
override def check[S >: T](r: MatchResult[S]): MatchResult[S] = checkFailure(r)
Expand Down
Expand Up @@ -124,7 +124,10 @@ trait NoThrownExpectations extends Expectations {
/**
* This trait represents any Scope that is used to enclose expectations which might be thrown
*/
trait Scope
trait Scope {
if (this.isInstanceOf[Expectations] && !this.isInstanceOf[ThrownExpectations])
throw new RuntimeException("You shouldn't mixin `org.specs2.matcher.MustExpectations` or `org.specs2.matcher.ShouldExpectations` with `Scope`, use `org.specs2.matcher.MustThrownExpectations` or `org.specs2.matcher.ShouldThrownExpectations` instead.")
}

object Scope {
/** typeclass to transform a Scope to a Result */
Expand Down

0 comments on commit 226d84b

Please sign in to comment.