From 7b33ad53548c53ce1b8441871fc67fc67f456fdd Mon Sep 17 00:00:00 2001 From: Rocky Madden Date: Mon, 6 Jan 2014 10:48:10 -0700 Subject: Converted subproject to specs2 from scalatest. --- .../com/rockymadden/stringmetric/cli/CliSpec.scala | 81 --------- .../rockymadden/stringmetric/cli/PackageSpec.scala | 59 +++++++ .../rockymadden/stringmetric/cli/ScalaTest.scala | 18 -- .../cli/phonetic/metaphonealgorithmSpec.scala | 42 ++--- .../cli/phonetic/metaphonemetricSpec.scala | 51 ++---- .../cli/phonetic/nysiisalgorithmSpec.scala | 42 ++--- .../cli/phonetic/nysiismetricSpec.scala | 51 ++---- .../cli/phonetic/refinednysiisalgorithmSpec.scala | 42 ++--- .../cli/phonetic/refinednysiismetricSpec.scala | 51 ++---- .../cli/phonetic/refinedsoundexalgorithmSpec.scala | 42 ++--- .../cli/phonetic/refinedsoundexmetricSpec.scala | 51 ++---- .../cli/phonetic/soundexalgorithmSpec.scala | 42 ++--- .../cli/phonetic/soundexmetricSpec.scala | 51 ++---- .../cli/similarity/dicesorensenmetricSpec.scala | 42 ++--- .../cli/similarity/hammingmetricSpec.scala | 42 ++--- .../cli/similarity/jaccardmetricSpec.scala | 42 ++--- .../cli/similarity/jarometricSpec.scala | 42 ++--- .../cli/similarity/jarowinklermetricSpec.scala | 42 ++--- .../cli/similarity/levenshteinmetricSpec.scala | 42 ++--- .../cli/similarity/ngrammetricSpec.scala | 72 ++------ .../cli/similarity/overlapmetricSpec.scala | 42 ++--- .../similarity/ratcliffobershelpmetricSpec.scala | 42 ++--- .../similarity/weightedlevenshteinmetricSpec.scala | 182 +++++++++------------ project/build.scala | 5 +- 24 files changed, 381 insertions(+), 837 deletions(-) delete mode 100755 cli/src/test/scala/com/rockymadden/stringmetric/cli/CliSpec.scala create mode 100755 cli/src/test/scala/com/rockymadden/stringmetric/cli/PackageSpec.scala delete mode 100755 cli/src/test/scala/com/rockymadden/stringmetric/cli/ScalaTest.scala diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/CliSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/CliSpec.scala deleted file mode 100755 index 38c6fd3..0000000 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/CliSpec.scala +++ /dev/null @@ -1,81 +0,0 @@ -package com.rockymadden.stringmetric.cli - -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner - -@RunWith(classOf[JUnitRunner]) -final class CliSpec extends ScalaTest { "OptionMap" should provide { - "apply method" when passed { - "single valid double dashed option" should returns { - "populated Map" in { - val opts: OptionMap = Array("--help") - - (opts('help): String) should equal ("") - } - } - "multiple valid double dashed opts" should returns { - "populated Map" in { - val opts: OptionMap = Array("--help", "--test=test") - - (opts('help): String) should equal ("") - (opts('test): String) should equal ("test") - } - } - "invalid double dashed opts" should returns { - "empty Map" in { - val opts: OptionMap = Array("--help#", "--test%=test") - - opts.keysIterator.length should be (0) - } - } - "single valid single dashed option" should returns { - "populated Map" in { - val opts: OptionMap = Array("-h") - - (opts('h): String) should equal ("") - } - } - "multiple valid single dashed opts" should returns { - "populated Map" in { - val opts: OptionMap = Array("-h", "-i") - - (opts('h): String) should equal ("") - (opts('i): String) should equal ("") - } - } - "invalid single dashed opts" should returns { - "empty Map" in { - val opts: OptionMap = Array("-h-i", "-i#gloo") - - opts.keysIterator.length should be (0) - } - } - "single nameless option" should returns { - "single key populated Map" in { - val opts: OptionMap = Array("filename0") - - (opts('dashless): String).count(_ == ' ') should be (0) - } - } - "multiple single nameless opts" should returns { - "single key populated Map" in { - val opts: OptionMap = Array("filename0", "filename1", "filename2") - - (opts('dashless): String).count(_ == ' ') should be (2) - } - } - "mixed opts" should returns { - "populated Map" in { - val opts: OptionMap = Array( - "-q", "--help", "--test=test", "-go", "filename0", "filename1", "filename2" - ) - - (opts('q): String) should equal ("") - (opts('help): String) should equal ("") - (opts('test): String) should equal ("test") - (opts('go): String) should equal ("") - (opts('dashless): String).count(_ == ' ') should be (2) - } - } - } -}} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/PackageSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/PackageSpec.scala new file mode 100755 index 0000000..ac31a4d --- /dev/null +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/PackageSpec.scala @@ -0,0 +1,59 @@ +package com.rockymadden.stringmetric.cli + +object PackageSpec extends org.specs2.mutable.SpecificationWithJUnit { + "OptionMap apply()" should { + "return populated Map with single valid double dashed option" in { + val opts: OptionMap = Array("--help") + + (opts('help): String) must beEqualTo("") + } + "return populated Map with multiple valid double dashed opts" in { + val opts: OptionMap = Array("--help", "--test=test") + + (opts('help): String) must beEqualTo("") + (opts('test): String) must beEqualTo("test") + } + "return empty Map with invalid double dashed opts" in { + val opts: OptionMap = Array("--help#", "--test%=test") + + opts.keysIterator.length must beEqualTo(0) + } + "return populated Map with single valid single dashed option" in { + val opts: OptionMap = Array("-h") + + (opts('h): String) must beEqualTo("") + } + "return populated Map multiple valid single dashed opts" in { + val opts: OptionMap = Array("-h", "-i") + + (opts('h): String) must beEqualTo("") + (opts('i): String) must beEqualTo("") + } + "return empty Map with invalid single dashed opts" in { + val opts: OptionMap = Array("-h-i", "-i#gloo") + + opts.keysIterator.length must beEqualTo(0) + } + "return single key populated Map with single nameless option" in { + val opts: OptionMap = Array("filename0") + + (opts('dashless): String).count(_ == ' ') must beEqualTo(0) + } + "return single key populated Map with multiple single nameless opts" in { + val opts: OptionMap = Array("filename0", "filename1", "filename2") + + (opts('dashless): String).count(_ == ' ') must beEqualTo(2) + } + "return populated Map with mixed opts" in { + val opts: OptionMap = Array( + "-q", "--help", "--test=test", "-go", "filename0", "filename1", "filename2" + ) + + (opts('q): String) must beEqualTo("") + (opts('help): String) must beEqualTo("") + (opts('test): String) must beEqualTo("test") + (opts('go): String) must beEqualTo("") + (opts('dashless): String).count(_ == ' ') must beEqualTo(2) + } + } +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/ScalaTest.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/ScalaTest.scala deleted file mode 100755 index 4cc0eed..0000000 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/ScalaTest.scala +++ /dev/null @@ -1,18 +0,0 @@ -package com.rockymadden.stringmetric.cli - -import org.scalatest.{BeforeAndAfter, ParallelTestExecution, WordSpec} -import org.scalatest.matchers.ShouldMatchers - -trait ScalaTest extends WordSpec with ShouldMatchers with BeforeAndAfter with ParallelTestExecution { - def allows = afterWord("allow") - - def executes = afterWord("execute") - - def passed = afterWord("passed") - - def provide = afterWord("provide") - - def returns = afterWord("return") - - def throws = afterWord("throw") -} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithmSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithmSpec.scala index 8b8226d..1b22943 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithmSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonealgorithmSpec.scala @@ -1,37 +1,19 @@ package com.rockymadden.stringmetric.cli.phonetic -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object metaphonealgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit { + "metaphonealgorithm main()" should { + "print phonetic representation with valid dashless argument" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class metaphonealgorithmSpec extends ScalaTest { "metaphonealgorithm" should provide { - "main method" when passed { - "valid dashless argument" should executes { - "print phonetic representation" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(metaphonealgorithm.main(Array("--unitTest", "--debug", "abc"))) + out.toString must beEqualTo("abk\n") + out.reset() - Console.withOut(out)( - metaphonealgorithm.main(Array("--unitTest", "--debug", "abc")) - ) - - out.toString should equal ("abk\n") - out.reset() - - Console.withOut(out)( - metaphonealgorithm.main(Array("--unitTest", "--debug", "1")) - ) - - out.toString should equal ("not computable\n") - out.reset() - } + Console.withOut(out)(metaphonealgorithm.main(Array("--unitTest", "--debug", "1"))) + out.toString must beEqualTo("not computable\n") } - "no dashless argument" should throws { - "IllegalArgumentException" in { - evaluating { - metaphonealgorithm.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless argument" in { + metaphonealgorithm.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonemetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonemetricSpec.scala index ab8d4fb..5124068 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonemetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/metaphonemetricSpec.scala @@ -1,44 +1,23 @@ package com.rockymadden.stringmetric.cli.phonetic -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object metaphonemetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "metaphonemetric main()" should { + "print if they are a match with valid dashless arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class metaphonemetricSpec extends ScalaTest { "metaphonemetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(metaphonemetric.main(Array("--unitTest", "--debug", "abc", "abc"))) + out.toString must beEqualTo("true\n") + out.reset() - Console.withOut(out)( - metaphonemetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) + Console.withOut(out)(metaphonemetric.main(Array("--unitTest", "--debug", "abc", "xyz"))) + out.toString must beEqualTo("false\n") + out.reset() - out.toString should equal ("true\n") - out.reset() - - Console.withOut(out)( - metaphonemetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("false\n") - out.reset() - - Console.withOut(out)( - metaphonemetric.main(Array("--unitTest", "--debug", "1", "1")) - ) - - out.toString should equal ("not comparable\n") - out.reset() - } + Console.withOut(out)(metaphonemetric.main(Array("--unitTest", "--debug", "1", "1"))) + out.toString must beEqualTo("not comparable\n") } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - metaphonemetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless arguments" in { + metaphonemetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiisalgorithmSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiisalgorithmSpec.scala index 21ae04a..a331ba1 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiisalgorithmSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiisalgorithmSpec.scala @@ -1,37 +1,19 @@ package com.rockymadden.stringmetric.cli.phonetic -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object nysiisalgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit { + "nysiisalgorithm main()" should { + "print phonetic representation with valid dashless argument" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class nysiisalgorithmSpec extends ScalaTest { "nysiisalgorithm" should provide { - "main method" when passed { - "valid dashless argument" should executes { - "print phonetic representation" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(nysiisalgorithm.main(Array("--unitTest", "--debug", "abc"))) + out.toString must beEqualTo("abc\n") + out.reset() - Console.withOut(out)( - nysiisalgorithm.main(Array("--unitTest", "--debug", "abc")) - ) - - out.toString should equal ("abc\n") - out.reset() - - Console.withOut(out)( - nysiisalgorithm.main(Array("--unitTest", "--debug", "1")) - ) - - out.toString should equal ("not computable\n") - out.reset() - } + Console.withOut(out)(nysiisalgorithm.main(Array("--unitTest", "--debug", "1"))) + out.toString must beEqualTo("not computable\n") } - "no dashless argument" should throws { - "IllegalArgumentException" in { - evaluating { - nysiisalgorithm.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless argument" in { + nysiisalgorithm.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiismetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiismetricSpec.scala index aa28fe4..aaeb431 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiismetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/nysiismetricSpec.scala @@ -1,44 +1,23 @@ package com.rockymadden.stringmetric.cli.phonetic -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object nysiismetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "nysiismetric main()" should { + "print if they are a match with valid dashless arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class nysiismetricSpec extends ScalaTest { "nysiismetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(nysiismetric.main(Array("--unitTest", "--debug", "abc", "abc"))) + out.toString must beEqualTo("true\n") + out.reset() - Console.withOut(out)( - nysiismetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) + Console.withOut(out)(nysiismetric.main(Array("--unitTest", "--debug", "abc", "xyz"))) + out.toString must beEqualTo("false\n") + out.reset() - out.toString should equal ("true\n") - out.reset() - - Console.withOut(out)( - nysiismetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("false\n") - out.reset() - - Console.withOut(out)( - nysiismetric.main(Array("--unitTest", "--debug", "1", "1")) - ) - - out.toString should equal ("not comparable\n") - out.reset() - } + Console.withOut(out)(nysiismetric.main(Array("--unitTest", "--debug", "1", "1"))) + out.toString must beEqualTo("not comparable\n") } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - nysiismetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless arguments" in { + nysiismetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiisalgorithmSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiisalgorithmSpec.scala index f2e78d9..9fd6504 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiisalgorithmSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiisalgorithmSpec.scala @@ -1,37 +1,19 @@ package com.rockymadden.stringmetric.cli.phonetic -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object refinednysiisalgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit { + "refinednysiisalgorithm main()" should { + "print phonetic representation with valid dashless argument" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class refinednysiisalgorithmSpec extends ScalaTest { "refinednysiisalgorithm" should provide { - "main method" when passed { - "valid dashless argument" should executes { - "print phonetic representation" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(refinednysiisalgorithm.main(Array("--unitTest", "--debug", "abc"))) + out.toString must beEqualTo("abc\n") + out.reset() - Console.withOut(out)( - refinednysiisalgorithm.main(Array("--unitTest", "--debug", "abc")) - ) - - out.toString should equal ("abc\n") - out.reset() - - Console.withOut(out)( - refinednysiisalgorithm.main(Array("--unitTest", "--debug", "1")) - ) - - out.toString should equal ("not computable\n") - out.reset() - } + Console.withOut(out)(refinednysiisalgorithm.main(Array("--unitTest", "--debug", "1"))) + out.toString must beEqualTo("not computable\n") } - "no dashless argument" should throws { - "IllegalArgumentException" in { - evaluating { - refinednysiisalgorithm.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless argument" in { + refinednysiisalgorithm.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiismetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiismetricSpec.scala index ce9cebd..7a82f5e 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiismetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinednysiismetricSpec.scala @@ -1,44 +1,23 @@ package com.rockymadden.stringmetric.cli.phonetic -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object refinednysiismetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "refinednysiismetric main()" should { + "print if they are a match with valid dashless arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class refinednysiismetricSpec extends ScalaTest { "refinednysiismetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(refinednysiismetric.main(Array("--unitTest", "--debug", "abc", "abc"))) + out.toString must beEqualTo("true\n") + out.reset() - Console.withOut(out)( - refinednysiismetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) + Console.withOut(out)(refinednysiismetric.main(Array("--unitTest", "--debug", "abc", "xyz"))) + out.toString must beEqualTo("false\n") + out.reset() - out.toString should equal ("true\n") - out.reset() - - Console.withOut(out)( - refinednysiismetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("false\n") - out.reset() - - Console.withOut(out)( - refinednysiismetric.main(Array("--unitTest", "--debug", "1", "1")) - ) - - out.toString should equal ("not comparable\n") - out.reset() - } + Console.withOut(out)(refinednysiismetric.main(Array("--unitTest", "--debug", "1", "1"))) + out.toString must beEqualTo("not comparable\n") } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - refinednysiismetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException no dashless arguments" in { + refinednysiismetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexalgorithmSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexalgorithmSpec.scala index 18d46fa..051499b 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexalgorithmSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexalgorithmSpec.scala @@ -1,37 +1,19 @@ package com.rockymadden.stringmetric.cli.phonetic -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object refinedsoundexalgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit { + "refinedsoundexalgorithm main()" should { + "print phonetic representation with valid dashless argument" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class refinedsoundexalgorithmSpec extends ScalaTest { "refinedsoundexalgorithm" should provide { - "main method" when passed { - "valid dashless argument" should executes { - "print phonetic representation" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(refinedsoundexalgorithm.main(Array("--unitTest", "--debug", "abc"))) + out.toString must beEqualTo("a013\n") + out.reset() - Console.withOut(out)( - refinedsoundexalgorithm.main(Array("--unitTest", "--debug", "abc")) - ) - - out.toString should equal ("a013\n") - out.reset() - - Console.withOut(out)( - refinedsoundexalgorithm.main(Array("--unitTest", "--debug", "1")) - ) - - out.toString should equal ("not computable\n") - out.reset() - } + Console.withOut(out)(refinedsoundexalgorithm.main(Array("--unitTest", "--debug", "1"))) + out.toString must beEqualTo("not computable\n") } - "no dashless argument" should throws { - "IllegalArgumentException" in { - evaluating { - refinedsoundexalgorithm.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless argument" in { + refinedsoundexalgorithm.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexmetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexmetricSpec.scala index 041fada..e7c6d2d 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexmetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/refinedsoundexmetricSpec.scala @@ -1,44 +1,23 @@ package com.rockymadden.stringmetric.cli.phonetic -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object refinedsoundexmetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "refinedsoundexmetric main()" should { + "print if they are a match with valid dashless arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class refinedsoundexmetricSpec extends ScalaTest { "refinedsoundexmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(refinedsoundexmetric.main(Array("--unitTest", "--debug", "abc", "abc"))) + out.toString must beEqualTo("true\n") + out.reset() - Console.withOut(out)( - refinedsoundexmetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) + Console.withOut(out)(refinedsoundexmetric.main(Array("--unitTest", "--debug", "abc", "xyz"))) + out.toString must beEqualTo("false\n") + out.reset() - out.toString should equal ("true\n") - out.reset() - - Console.withOut(out)( - refinedsoundexmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("false\n") - out.reset() - - Console.withOut(out)( - refinedsoundexmetric.main(Array("--unitTest", "--debug", "1", "1")) - ) - - out.toString should equal ("not comparable\n") - out.reset() - } + Console.withOut(out)(refinedsoundexmetric.main(Array("--unitTest", "--debug", "1", "1"))) + out.toString must beEqualTo("not comparable\n") } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - refinedsoundexmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless arguments" in { + refinedsoundexmetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexalgorithmSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexalgorithmSpec.scala index e23b3c3..13151d3 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexalgorithmSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexalgorithmSpec.scala @@ -1,37 +1,19 @@ package com.rockymadden.stringmetric.cli.phonetic -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object soundexalgorithmSpec extends org.specs2.mutable.SpecificationWithJUnit { + "soundexalgorithm main()" should { + "print phonetic representation with valid dashless argument" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class soundexalgorithmSpec extends ScalaTest { "soundexalgorithm" should provide { - "main method" when passed { - "valid dashless argument" should executes { - "print phonetic representation" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(soundexalgorithm.main(Array("--unitTest", "--debug", "abc"))) + out.toString must beEqualTo("a120\n") + out.reset() - Console.withOut(out)( - soundexalgorithm.main(Array("--unitTest", "--debug", "abc")) - ) - - out.toString should equal ("a120\n") - out.reset() - - Console.withOut(out)( - soundexalgorithm.main(Array("--unitTest", "--debug", "1")) - ) - - out.toString should equal ("not computable\n") - out.reset() - } + Console.withOut(out)(soundexalgorithm.main(Array("--unitTest", "--debug", "1"))) + out.toString must beEqualTo("not computable\n") } - "no dashless argument" should throws { - "IllegalArgumentException" in { - evaluating { - soundexalgorithm.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException no dashless argument" in { + soundexalgorithm.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexmetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexmetricSpec.scala index 332b058..5bac540 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexmetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/phonetic/soundexmetricSpec.scala @@ -1,44 +1,23 @@ package com.rockymadden.stringmetric.cli.phonetic -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object soundexmetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "print if they are a match with soundexmetric main()" should { + "print if they are a match with valid dashless arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class soundexmetricSpec extends ScalaTest { "soundexmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(soundexmetric.main(Array("--unitTest", "--debug", "abc", "abc"))) + out.toString must beEqualTo("true\n") + out.reset() - Console.withOut(out)( - soundexmetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) + Console.withOut(out)(soundexmetric.main(Array("--unitTest", "--debug", "abc", "xyz"))) + out.toString must beEqualTo("false\n") + out.reset() - out.toString should equal ("true\n") - out.reset() - - Console.withOut(out)( - soundexmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("false\n") - out.reset() - - Console.withOut(out)( - soundexmetric.main(Array("--unitTest", "--debug", "1", "1")) - ) - - out.toString should equal ("not comparable\n") - out.reset() - } + Console.withOut(out)(soundexmetric.main(Array("--unitTest", "--debug", "1", "1"))) + out.toString must beEqualTo("not comparable\n") } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - soundexmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless arguments" in { + soundexmetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetricSpec.scala index 82cf8c2..5e0fce2 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/dicesorensenmetricSpec.scala @@ -1,37 +1,19 @@ package com.rockymadden.stringmetric.cli.similarity -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object dicesorensenmetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "dicesorensenmetric main()" should { + "print if they are a match with valid dashless arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class dicesorensenmetricSpec extends ScalaTest { "dicesorensenmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(dicesorensenmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "abc"))) + out.toString must beEqualTo("1.0\n") + out.reset() - Console.withOut(out)( - dicesorensenmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "abc")) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - dicesorensenmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "xyz")) - ) - - out.toString should equal ("0.0\n") - out.reset() - } + Console.withOut(out)(dicesorensenmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "xyz"))) + out.toString must beEqualTo("0.0\n") } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - dicesorensenmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless arguments" in { + dicesorensenmetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/hammingmetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/hammingmetricSpec.scala index dc34e8f..736e46b 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/hammingmetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/hammingmetricSpec.scala @@ -1,37 +1,19 @@ package com.rockymadden.stringmetric.cli.similarity -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object hammingmetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "hammingmetric main()" should { + "print if they are a match with valid dashless arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class hammingmetricSpec extends ScalaTest { "hammingmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(hammingmetric.main(Array("--unitTest", "--debug", "abc", "abc"))) + out.toString must beEqualTo("0\n") + out.reset() - Console.withOut(out)( - hammingmetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("0\n") - out.reset() - - Console.withOut(out)( - hammingmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("3\n") - out.reset() - } + Console.withOut(out)(hammingmetric.main(Array("--unitTest", "--debug", "abc", "xyz"))) + out.toString must beEqualTo("3\n") } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - hammingmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException no dashless arguments" in { + hammingmetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/jaccardmetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/jaccardmetricSpec.scala index 52da38f..4fa5c86 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/jaccardmetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/jaccardmetricSpec.scala @@ -1,37 +1,19 @@ package com.rockymadden.stringmetric.cli.similarity -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object jaccardmetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "jaccardmetric main()" should { + "print if they are a match with valid dashless arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class jaccardmetricSpec extends ScalaTest { "jaccardmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(jaccardmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "abc"))) + out.toString must beEqualTo("1.0\n") + out.reset() - Console.withOut(out)( - jaccardmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "abc")) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - jaccardmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "xyz")) - ) - - out.toString should equal ("0.0\n") - out.reset() - } + Console.withOut(out)(jaccardmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "xyz"))) + out.toString must beEqualTo("0.0\n") } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - jaccardmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException no dashless arguments" in { + jaccardmetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/jarometricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/jarometricSpec.scala index 866ea9e..6afdf70 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/jarometricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/jarometricSpec.scala @@ -1,37 +1,19 @@ package com.rockymadden.stringmetric.cli.similarity -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object jarometricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "jarometric main()" should { + "print the distance with valid dashless arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class jarometricSpec extends ScalaTest { "jarometric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print the distance" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(jarometric.main(Array("--unitTest", "--debug", "abc", "abc"))) + out.toString must beEqualTo("1.0\n") + out.reset() - Console.withOut(out)( - jarometric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - jarometric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("0.0\n") - out.reset() - } + Console.withOut(out)(jarometric.main(Array("--unitTest", "--debug", "abc", "xyz"))) + out.toString must beEqualTo("0.0\n") } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - jarometric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless arguments" in { + jarometric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/jarowinklermetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/jarowinklermetricSpec.scala index 56bf014..d064e0c 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/jarowinklermetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/jarowinklermetricSpec.scala @@ -1,37 +1,19 @@ package com.rockymadden.stringmetric.cli.similarity -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object jarowinklermetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "jarowinklermetric main()" should { + "print the distance with valid dashless arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class jarowinklermetricSpec extends ScalaTest { "jarowinklermetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print the distance" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(jarowinklermetric.main(Array("--unitTest", "--debug", "abc", "abc"))) + out.toString must beEqualTo("1.0\n") + out.reset() - Console.withOut(out)( - jarowinklermetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - jarowinklermetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("0.0\n") - out.reset() - } + Console.withOut(out)(jarowinklermetric.main(Array("--unitTest", "--debug", "abc", "xyz"))) + out.toString must beEqualTo("0.0\n") } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - jarowinklermetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless arguments" in { + jarowinklermetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/levenshteinmetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/levenshteinmetricSpec.scala index e18133c..f09ad70 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/levenshteinmetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/levenshteinmetricSpec.scala @@ -1,37 +1,19 @@ package com.rockymadden.stringmetric.cli.similarity -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object levenshteinmetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "levenshteinmetric main()" should { + "print if they are a match with valid dashless arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class levenshteinmetricSpec extends ScalaTest { "levenshteinmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(levenshteinmetric.main(Array("--unitTest", "--debug", "abc", "abc"))) + out.toString must beEqualTo("0\n") + out.reset() - Console.withOut(out)( - levenshteinmetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("0\n") - out.reset() - - Console.withOut(out)( - levenshteinmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("3\n") - out.reset() - } + Console.withOut(out)(levenshteinmetric.main(Array("--unitTest", "--debug", "abc", "xyz"))) + out.toString must beEqualTo("3\n") } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - levenshteinmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless arguments" in { + levenshteinmetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetricSpec.scala index 3106b02..8596613 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/ngrammetricSpec.scala @@ -1,66 +1,22 @@ package com.rockymadden.stringmetric.cli.similarity -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object ngrammetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "ngrammetric main()" should { + "print if they are a match with valid dashless arguments and valid n argument" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class ngrammetricSpec extends ScalaTest { "ngrammetric" should provide { - "main method" when passed { - "valid dashless arguments and valid n argument" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(ngrammetric.main(Array("--unitTest", "--debug", "--n=1", "abc", "abc"))) + out.toString must beEqualTo("1.0\n") + out.reset() - Console.withOut(out)( - ngrammetric.main( - Array( - "--unitTest", - "--debug", - "--n=1", - "abc", - "abc" - ) - ) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - ngrammetric.main( - Array( - "--unitTest", - "--debug", - "--n=1", - "abc", - "xyz" - ) - ) - ) - - out.toString should equal ("0.0\n") - out.reset() - } + Console.withOut(out)(ngrammetric.main(Array("--unitTest", "--debug", "--n=1", "abc", "xyz"))) + out.toString must beEqualTo("0.0\n") } - "valid dashless arguments and invalid n argument" should throws { - "IllegalArgumentException" in { - evaluating { - ngrammetric.main( - Array( - "--unitTest", - "abc", - "abc" - ) - ) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with valid dashless arguments but invalid n argument" in { + ngrammetric.main(Array("--unitTest", "abc", "abc")) must throwA[IllegalArgumentException] } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - ngrammetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless arguments" in { + ngrammetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/overlapmetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/overlapmetricSpec.scala index 0721ebe..31e88a9 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/overlapmetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/overlapmetricSpec.scala @@ -1,37 +1,19 @@ package com.rockymadden.stringmetric.cli.similarity -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object overlapmetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "overlapmetric main()" should { + "print if they are a match with valid dashless arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class overlapmetricSpec extends ScalaTest { "overlapmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(overlapmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "abc"))) + out.toString must beEqualTo("1.0\n") + out.reset() - Console.withOut(out)( - overlapmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "abc")) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - overlapmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "xyz")) - ) - - out.toString should equal ("0.0\n") - out.reset() - } + Console.withOut(out)(overlapmetric.main(Array("--unitTest", "--debug", "--n=2", "abc", "xyz"))) + out.toString must beEqualTo("0.0\n") } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - overlapmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless arguments" in { + overlapmetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/ratcliffobershelpmetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/ratcliffobershelpmetricSpec.scala index b4ae512..ab0243f 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/ratcliffobershelpmetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/ratcliffobershelpmetricSpec.scala @@ -1,37 +1,19 @@ package com.rockymadden.stringmetric.cli.similarity -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object ratcliffobershelpmetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "ratcliffobershelpmetric main()" should { + "print if they are a match with valid dashless arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class ratcliffobershelpmetricSpec extends ScalaTest { "ratcliffobershelpmetric" should provide { - "main method" when passed { - "valid dashless arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() + Console.withOut(out)(ratcliffobershelpmetric.main(Array("--unitTest", "--debug", "abc", "abc"))) + out.toString must beEqualTo("1.0\n") + out.reset() - Console.withOut(out)( - ratcliffobershelpmetric.main(Array("--unitTest", "--debug", "abc", "abc")) - ) - - out.toString should equal ("1.0\n") - out.reset() - - Console.withOut(out)( - ratcliffobershelpmetric.main(Array("--unitTest", "--debug", "abc", "xyz")) - ) - - out.toString should equal ("0.0\n") - out.reset() - } + Console.withOut(out)(ratcliffobershelpmetric.main(Array("--unitTest", "--debug", "abc", "xyz"))) + out.toString must beEqualTo("0.0\n") } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - ratcliffobershelpmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless arguments" in { + ratcliffobershelpmetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/weightedlevenshteinmetricSpec.scala b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/weightedlevenshteinmetricSpec.scala index 568f583..6fa9094 100755 --- a/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/weightedlevenshteinmetricSpec.scala +++ b/cli/src/test/scala/com/rockymadden/stringmetric/cli/similarity/weightedlevenshteinmetricSpec.scala @@ -1,121 +1,91 @@ package com.rockymadden.stringmetric.cli.similarity -import com.rockymadden.stringmetric.cli.ScalaTest -import org.junit.runner.RunWith -import org.scalatest.junit.JUnitRunner +object weightedlevenshteinmetricSpec extends org.specs2.mutable.SpecificationWithJUnit { + "weightedlevenshteinmetric main()" should { + "print if they are a match with valid dashless arguments and valid weight arguments" in { + val out = new java.io.ByteArrayOutputStream() -@RunWith(classOf[JUnitRunner]) -final class weightedlevenshteinmetricSpec extends ScalaTest { "weightedlevenshteinmetric" should provide { - "main method" when passed { - "valid dashless arguments and valid weight arguments" should executes { - "print if they are a match" in { - val out = new java.io.ByteArrayOutputStream() - - Console.withOut(out)( - weightedlevenshteinmetric.main( - Array( - "--unitTest", - "--debug", - "--deleteWeight=1", - "--insertWeight=1", - "--substituteWeight=1", - "abc", - "abc" - ) - ) + Console.withOut(out)(weightedlevenshteinmetric.main( + Array( + "--unitTest", + "--debug", + "--deleteWeight=1", + "--insertWeight=1", + "--substituteWeight=1", + "abc", + "abc" ) + )) + out.toString must beEqualTo("0.0\n") + out.reset() - out.toString should equal ("0.0\n") - out.reset() - - Console.withOut(out)( - weightedlevenshteinmetric.main( - Array( - "--unitTest", - "--debug", - "--deleteWeight=2", - "--insertWeight=2", - "--substituteWeight=1", - "abc", - "xyz" - ) - ) + Console.withOut(out)(weightedlevenshteinmetric.main( + Array( + "--unitTest", + "--debug", + "--deleteWeight=2", + "--insertWeight=2", + "--substituteWeight=1", + "abc", + "xyz" ) + )) + out.toString must beEqualTo("3.0\n") + out.reset() - out.toString should equal ("3.0\n") - out.reset() - - Console.withOut(out)( - weightedlevenshteinmetric.main( - Array( - "--unitTest", - "--debug", - "--deleteWeight=2", - "--insertWeight=1", - "--substituteWeight=2", - "xyz", - "xyzxyz" - ) - ) + Console.withOut(out)(weightedlevenshteinmetric.main( + Array( + "--unitTest", + "--debug", + "--deleteWeight=2", + "--insertWeight=1", + "--substituteWeight=2", + "xyz", + "xyzxyz" ) + )) + out.toString must beEqualTo("3.0\n") + out.reset() - out.toString should equal ("3.0\n") - out.reset() - - Console.withOut(out)( - weightedlevenshteinmetric.main( - Array( - "--unitTest", - "--debug", - "--deleteWeight=1", - "--insertWeight=2", - "--substituteWeight=2", - "xyzxyz", - "xyz" - ) - ) + Console.withOut(out)(weightedlevenshteinmetric.main( + Array( + "--unitTest", + "--debug", + "--deleteWeight=1", + "--insertWeight=2", + "--substituteWeight=2", + "xyzxyz", + "xyz" ) - - out.toString should equal ("3.0\n") - out.reset() - } + )) + out.toString must beEqualTo("3.0\n") } - "valid dashless arguments and invalid weight arguments" should throws { - "IllegalArgumentException" in { - evaluating { - weightedlevenshteinmetric.main( - Array( - "--unitTest", - "--debug", - "--deleteWeight=1", - "--substituteWeight=1", - "abc", - "abc" - ) - ) - } should produce [IllegalArgumentException] + "throw IllegalArgumentException with valid dashless arguments but invalid weight arguments" in { + weightedlevenshteinmetric.main( + Array( + "--unitTest", + "--debug", + "--deleteWeight=1", + "--substituteWeight=1", + "abc", + "abc" + ) + ) must throwA[IllegalArgumentException] - evaluating { - weightedlevenshteinmetric.main( - Array( - "--unitTest", - "--debug", - "--deleteWeight=1", - "--insertWeight=q", - "--substituteWeight=1", - "abc", - "abc" - ) - ) - } should produce [IllegalArgumentException] - } + weightedlevenshteinmetric.main( + Array( + "--unitTest", + "--debug", + "--deleteWeight=1", + "--insertWeight=q", + "--substituteWeight=1", + "abc", + "abc" + ) + ) must throwA[IllegalArgumentException] } - "no dashless arguments" should throws { - "IllegalArgumentException" in { - evaluating { - weightedlevenshteinmetric.main(Array("--unitTest", "--debug")) - } should produce [IllegalArgumentException] - } + "throw IllegalArgumentException with no dashless arguments" in { + weightedlevenshteinmetric.main(Array("--unitTest", "--debug")) must throwA[IllegalArgumentException] } } -}} +} diff --git a/project/build.scala b/project/build.scala index cdeeeb2..8150d08 100644 --- a/project/build.scala +++ b/project/build.scala @@ -46,10 +46,7 @@ object CoreBuild extends Build { lazy val cli: Project = Project("cli", file("cli"), settings = (root.settings: Seq[sbt.Def.Setting[_]]) ++ Seq( - libraryDependencies ++= Seq( - "junit" % "junit" % "4.11" % "test", - "org.scalatest" %% "scalatest" % "2.0.M5b" % "test" - ), + libraryDependencies ++= Seq("org.specs2" %% "specs2" % "2.3.7" % "test"), name := "stringmetric-cli" ) ).dependsOn(core) -- cgit v1.2.3