Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
import org.specs2.execute.{AsResult, Result}
import org.specs2.specification.ForEach
import scalikejdbc.{DB, DBSession, NamedDB}
import scala.util.Try
trait DefaultDataContext extends ForEach[DefaultObjects]
with DataContextDbName with DataContextName with DefaultGenerator {
implicit lazy val session: DBSession = DB.autoCommitSession()
override def foreach[R](f: (DefaultObjects) => R)(implicit evidence$3: AsResult[R]): Result =
NamedDB(dbName).withSession(session) { implicit session: DBSession =>
val testData = DefaultObjects.create(name = randomName(className))
val result = Try {
AsResult(f(testData))
}
testData.cleanup(session)
result.get
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.