From 3057a31a6c8ed3f4e25f1112df6bcbdb6d093a60 Mon Sep 17 00:00:00 2001 From: nazoking Date: Thu, 26 Feb 2015 11:47:47 +0900 Subject: [PATCH] add test for Diretory (set GitBucketHome when test scope) --- project/build.scala | 3 +++ src/test/scala/util/DirectorySpec.scala | 14 ++++++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/test/scala/util/DirectorySpec.scala diff --git a/project/build.scala b/project/build.scala index 7d4153809..f29febf66 100644 --- a/project/build.scala +++ b/project/build.scala @@ -69,6 +69,9 @@ object MyBuild extends Build { EclipseKeys.withSource := true, javacOptions in compile ++= Seq("-target", "7", "-source", "7"), testOptions in Test += Tests.Argument(TestFrameworks.Specs2, "junitxml", "console"), + javaOptions in Test += "-Dgitbucket.home=target/gitbucket_home_for_test", + testOptions in Test += Tests.Setup( () => new java.io.File("target/gitbucket_home_for_test").mkdir() ), + fork in Test := true, packageOptions += Package.MainClass("JettyLauncher") ).enablePlugins(SbtTwirl) } diff --git a/src/test/scala/util/DirectorySpec.scala b/src/test/scala/util/DirectorySpec.scala new file mode 100644 index 000000000..d961ea176 --- /dev/null +++ b/src/test/scala/util/DirectorySpec.scala @@ -0,0 +1,14 @@ +package util + +import org.specs2.mutable._ + +class DirectorySpec extends Specification { + "GitBucketHome" should { + "set under target in test scope" in { + Directory.GitBucketHome mustEqual new java.io.File("target/gitbucket_home_for_test").getAbsolutePath + } + "exists" in { + new java.io.File(Directory.GitBucketHome).exists + } + } +}