Skip to content

@jbnunn /gist:7102350
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Using an in-memory database for Play! framework testing
class TestCountriesSpec extends Specification {
val appWithMemoryDatabase = FakeApplication(additionalConfiguration = inMemoryDatabase())
abstract class WithDbData extends WithApplication(appWithMemoryDatabase) {
override def around[T: AsResult](t: => T): Result = super.around {
setupData()
t
}
def setupData() {
AppDB.database.withSession { implicit session: Session =>
AppDB.dal.create
AppDB.dal.seedForTests
}
}
}
"Countries" should {
// Model tests
"be found by country id" in new WithDbData {
val country = AppDB.dal.Countries.findOne(1)
org.name aka "must have a name of Brazil" must equalTo("Brazil")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.