Skip to content

Commit

Permalink
Added tests for run-mode property modification.
Browse files Browse the repository at this point in the history
  • Loading branch information
japgolly authored and fmpwizard committed Jul 6, 2013
1 parent 6d70b8d commit aad79b5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
2 changes: 1 addition & 1 deletion core/util/src/main/scala/net/liftweb/util/Props.scala
Expand Up @@ -120,7 +120,7 @@ object Props extends Logger {
}
}

@volatile private var runModeInitialised: Boolean = false
@volatile private[util] var runModeInitialised: Boolean = false

/**
* Exposes a property affecting run-mode determination, for customisation. If the property is modified
Expand Down
23 changes: 22 additions & 1 deletion core/util/src/test/scala/net/liftweb/util/PropsSpec.scala
Expand Up @@ -18,17 +18,38 @@ package net.liftweb
package util

import org.specs2.mutable.Specification

import Props.RunModes._

/**
* Systems under specification for Lift Mailer.
*/
object PropsSpec extends Specification {
"Props Specification".title
sequential

"Props" should {
"Detect test mode correctly" in {
Props.testMode must_== true
}

"Allow modification of run-mode properties before the run-mode is set" in {
val before = Props.autoDetectRunModeFn.get
try {
Props.runModeInitialised = false
Props.autoDetectRunModeFn.allowModification must_== true
Props.autoDetectRunModeFn.set(() => Test) must_== true
Props.autoDetectRunModeFn.get must_!= before
} finally {
Props.autoDetectRunModeFn.set(before)
Props.runModeInitialised = true
}
}

"Prohibit modification of run-mode properties when the run-mode is set" in {
val before = Props.autoDetectRunModeFn.get
Props.autoDetectRunModeFn.allowModification must_== false
Props.autoDetectRunModeFn.set(() => Test) must_== false
Props.autoDetectRunModeFn.get must_== before
}
}
}

0 comments on commit aad79b5

Please sign in to comment.