
package org.scalatest.tools

import org.scalatest.Spec
import org.scalatest.matchers.ShouldMatchers

class SbtCommandParserSpec extends Spec with ShouldMatchers {

  describe("the cmd terminal?") {
    it("should parse 'st'") {

      val parser = new SbtCommandParser
      val result = parser.parseResult("""st""")
      result match {
        case parser.Success(result, _) => println("success: " + result)
        case ns: parser.NoSuccess => fail(ns.toString)
      }
    }
    it("should parse 'st --'") {

      val parser = new SbtCommandParser
      val result = parser.parseResult("""st --""")
      result match {
        case parser.Success(result, _) => println("success: " + result)
        case ns: parser.NoSuccess => fail(ns.toString)
      }
    }
  }
}



package org.scalatest.tools

import org.scalatest.Spec
import org.scalatest.matchers.ShouldMatchers

class SbtCommandParserSpec extends Spec with ShouldMatchers {

  val parser = new SbtCommandParser

  def canParsePhrase(s: String) {
      val result = parser.parseResult(s)
      result match {
        case ns: parser.NoSuccess => fail(ns.toString)
        case _ => 
      }
  }

  def cannotParsePhrase(s: String) {
      val result = parser.parseResult(s)
      result match {
        case parser.Success(result, _) => fail("wasn't supposed to, but parsed: " + result)
        case _ =>
      }
  }

  describe("the cmd terminal?") {
    it("should parse 'st'") {
      canParsePhrase("""st""")
      canParsePhrase("""st --""")
    }
  }
}


Reduce code dup in test.
Reduce code dup in test.

