Skip to content

Commit

Permalink
removed the beforeSpec step to integrate it with the skipAll option
Browse files Browse the repository at this point in the history
  • Loading branch information
etorreborre committed Mar 15, 2011
1 parent daad6b6 commit 1013f8b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Expand Up @@ -36,7 +36,6 @@ object MongoDirectSpec extends MongoAcceptance { def is = args(sequential=true,
"""
This is a tutorial on how to use MongoDB with Lift
"""^p^
Step(doBeforeSpec) ^
"First we use the DB directly" ^
"to save a db object and retrieve it. It should be the same doc we built" ! direct.e1^
"we can also upsert the document" ! direct.e2^
Expand Down Expand Up @@ -86,9 +85,7 @@ This is a tutorial on how to use MongoDB with Lift
def withSession[T <% Result](f: (DB, DBCollection) => T): T = MongoDB.useSession { db => f(db, db.getCollection("testCollection")) }

def cleanup(name: String) = if (isMongoRunning) withDb { db =>
if (!debug) {
db.getCollection(name).drop
}
if (!debug) { db.getCollection(name).drop }
success
}

Expand Down
Expand Up @@ -45,12 +45,14 @@ trait MongoSetup extends MustMatchers {
dbs foreach { dbtuple => MongoDB.defineDb(dbtuple._1, MongoAddress(dbtuple._2, dbtuple._3)) }
}

lazy val isMongoRunning: Boolean =
lazy val isMongoRunning: Boolean = {
dbs foreach { dbtuple => MongoDB.defineDb(dbtuple._1, MongoAddress(dbtuple._2, dbtuple._3)) }
try {
if (dbs.isEmpty) false
else dbs exists { dbtuple => MongoDB.use(dbtuple._1)(db => true) }
} catch { case e: Exception => false }

}

def beRunning: Matcher[Boolean] = ((_:Boolean), "MongoDb is running", "MongoDb is not running")
def checkMongoIsRunning = isMongoRunning must beRunning.orSkip

Expand Down

0 comments on commit 1013f8b

Please sign in to comment.