All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.specs.specification.LiteralSpecification.scala Maven / Gradle / Ivy

There is a newer version: 1.4.3
Show newest version
package org.specs.specification
import scala.xml._
import org.specs.util._
import org.specs.Sugar._

/**
 * This trait is experimental. It is supposed to help writing some literal specifications
 * using the xml capabilities of Scala.
 * Several "toy" specifications have been written using this style:
    *
  • bizSpecificationSpec *
  • calculatorBizSpec *
  • xmlRunnerSpec *
*/ trait LiteralSpecification extends Specification with DataTables { setSequential /** * This method is used to silence the result of a call in an action. For example:
   * The timer should be stopped {timer.stop.shh}
   * 
. This will not output the result of the stop method */ implicit def anyToShh(a: Any) = new Silenced class Silenced { def shh = "" } /** * This method is used setup a property value, in order to avoid repeting a string. For example:
   * The name of the person should be {"john" as personName in checkPersonName}
   * 
. */ implicit def anyToAs[T](a: T) = new AsProperty(a) class AsProperty[T](a: T) { def as(p: Property[T]) = {p() = a; p.toString } def apply(p: Property[T]) = {p() = a; p.toString } def apply(f: T => Any)= {f(a); a.toString } def as(f: T => Any)= {f(a); a.toString } } /** * This method allows to embbed a DataTable in a literal specification and display the results of its execution */ implicit def makeTable(s: String) = new TableExample(s) case class TableExample(desc: String) { def inTable(table: ExecutableDataTable) = { forExample(desc) in { table.execute table.results } desc + "\n" + table.toString } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy