本文整理汇总了Scala中org.specs2.specification.core.Fragments类的典型用法代码示例。如果您正苦于以下问题:Scala Fragments类的具体用法?Scala Fragments怎么用?Scala Fragments使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Fragments类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Scala代码示例。
示例1: failTest
//设置package包名称以及导入依赖的类
package spray.testkit
import org.specs2.execute.{ Failure, FailureException }
import org.specs2.specification.core.{ Fragments, SpecificationStructure }
import org.specs2.specification.create.DefaultFragmentFactory
trait Specs2Interface extends TestFrameworkInterface with SpecificationStructure {
def failTest(msg: String) = {
val trace = new Exception().getStackTrace.toList
val fixedTrace = trace.drop(trace.indexWhere(_.getClassName.startsWith("org.specs2")) - 1)
throw new FailureException(Failure(msg, stackTrace = fixedTrace))
}
override def map(fs: ? Fragments) = super.map(fs).append(DefaultFragmentFactory.step(cleanUp()))
}
trait NoAutoHtmlLinkFragments extends org.specs2.specification.dsl.ReferenceDsl {
override def linkFragment(alias: String) = super.linkFragment(alias)
override def seeFragment(alias: String) = super.seeFragment(alias)
}
开发者ID:ShiftForward,项目名称:apso,代码行数:22,代码来源:Specs2Interface.scala
示例2: check
//设置package包名称以及导入依赖的类
package janstenpickle.vault.core
import java.net.URL
import janstenpickle.scala.syntax.SyntaxRequest._
import janstenpickle.scala.syntax.ResponseSyntax._
import janstenpickle.scala.syntax.VaultConfigSyntax._
import org.scalacheck.Gen
import org.specs2.Specification
import org.specs2.specification.core.Fragments
import uscala.result.specs2.ResultMatchers
import scala.concurrent.ExecutionContext
import scala.io.Source
trait VaultSpec extends Specification with ResultMatchers {
implicit val errConverter: Throwable => String = _.getMessage
implicit val ec: ExecutionContext = ExecutionContext.global
lazy val rootToken = Source.fromFile("/tmp/.root-token").mkString.trim
lazy val roleId = Source.fromFile("/tmp/.role-id").mkString.trim
lazy val secretId = Source.fromFile("/tmp/.secret-id").mkString.trim
lazy val rootConfig: VaultConfig = VaultConfig(
WSClient(new URL("http://localhost:8200")), rootToken
)
lazy val badTokenConfig = VaultConfig(
rootConfig.wsClient,
"face-off"
)
lazy val config = VaultConfig(
rootConfig.wsClient,
AppRole(roleId, secretId)
)
lazy val badServerConfig = VaultConfig(
WSClient(new URL("http://nic-cage.xyz")),
"con-air"
)
def check = config.token.attemptRun(_.getMessage) must beOk
override def map(fs: => Fragments) =
s2"""
Can receive a token for an AppRole $check
""" ^
fs
}
object VaultSpec {
val longerStrGen = Gen.alphaStr.suchThat(_.length >= 3)
val strGen = Gen.alphaStr.suchThat(_.nonEmpty)
}
开发者ID:janstenpickle,项目名称:scala-vault,代码行数:54,代码来源:VaultSpec.scala
示例3: failTest
//设置package包名称以及导入依赖的类
package spray.testkit
import org.specs2.execute.{Failure, FailureException}
import org.specs2.specification.core.{Fragments, SpecificationStructure}
import org.specs2.specification.create.DefaultFragmentFactory
trait Specs2Interface extends TestFrameworkInterface with SpecificationStructure {
def failTest(msg: String) = {
val trace = new Exception().getStackTrace.toList
val fixedTrace = trace.drop(trace.indexWhere(_.getClassName.startsWith("org.specs2")) - 1)
throw new FailureException(Failure(msg, stackTrace = fixedTrace))
}
override def map(fs: ? Fragments) = super.map(fs).append(DefaultFragmentFactory.step(cleanUp()))
}
trait NoAutoHtmlLinkFragments extends org.specs2.specification.dsl.ReferenceDsl {
override def linkFragment(alias: String) = super.linkFragment(alias)
override def seeFragment(alias: String) = super.seeFragment(alias)
}
开发者ID:qvantel,项目名称:jsonapi-scala,代码行数:22,代码来源:Specs2Interface.scala
示例4: MathStringEvaluatorTest
//设置package包名称以及导入依赖的类
package eval
import eval.impl.EvalExMathStringEvaluatorException
import org.specs2.specification.core.Fragments
import scala.util.{Failure, Success, Try}
abstract class MathStringEvaluatorTest extends org.specs2.mutable.Specification {
def evaluator: MathStringEvaluator
val testCases = Seq[(String, Try[Double])] (
// successes
"1 + 1" -> Success(2.0),
"4 - 1" -> Success(3.0),
"3 * 12" -> Success(36.0),
"5 / 2" -> Success(2.5),
"500 * 1000" -> Success(500000.0),
"1.049 * 1.049" -> Success(1.0),
"12345" -> Success(12345.0),
"1 + 2 + 3 + 4" -> Success(10.0),
"2 * 3 + 4" -> Success(10.0),
// failures
"2 -= 1" -> Failure(EvalExMathStringEvaluatorException("Unknown operator '-=' at position 3")),
"String string = \"Some string\"" -> Failure(EvalExMathStringEvaluatorException("Unknown operator '\"' at position 17"))
)
s"A ${evaluator.getClass.getSimpleName}" should {
Fragments.foreach(testCases) {
case (expression, expectedResult) =>
expectedResult match {
case Success(value) =>
s"Successfully evaluate $expression = $value" in {
evaluator.evaluateExpression(expression) must beEqualTo(expectedResult)
}
case Failure(value) =>
s"Fail to evaluate $expression = $value" in {
evaluator.evaluateExpression(expression) must beEqualTo(expectedResult)
}
}
}
}
}
开发者ID:cowboygneox,项目名称:its-a-bunny,代码行数:47,代码来源:MathStringEvaluatorTest.scala
示例5: failTest
//设置package包名称以及导入依赖的类
package spray.testkit
import org.specs2.execute.{ Failure, FailureException }
import org.specs2.specification.core.{ Fragments, SpecificationStructure }
import org.specs2.specification.create.DefaultFragmentFactory
// see https://groups.google.com/forum/#!msg/spray-user/2T6SBp4OJeI/zPDqlrumoOMJ
// https://gist.github.com/gmalouf/51a8722b50f6a9d30404
trait Specs2Interface extends TestFrameworkInterface with SpecificationStructure {
def failTest(msg: String) = {
val trace = new Exception().getStackTrace.toList
val fixedTrace = trace.drop(trace.indexWhere(_.getClassName.startsWith("org.specs2")) - 1)
throw new FailureException(Failure(msg, stackTrace = fixedTrace))
}
override def map(fs: ? Fragments) = super.map(fs).append(DefaultFragmentFactory.step(cleanUp()))
}
trait NoAutoHtmlLinkFragments extends org.specs2.specification.dsl.ReferenceDsl {
override def linkFragment(alias: String) = super.linkFragment(alias)
override def seeFragment(alias: String) = super.seeFragment(alias)
}
开发者ID:edinhodzic,项目名称:kyriakos-lib-rest-spray,代码行数:24,代码来源:Specs2Interface.scala
示例6: EventProcessorTest
//设置package包名称以及导入依赖的类
package com.komanov.serialization.domain
import com.komanov.serialization.converters.TestData
import org.specs2.mutable.SpecificationWithJUnit
import org.specs2.specification.core.Fragments
class EventProcessorTest extends SpecificationWithJUnit {
"apply/unapply" should {
Fragments.foreach(TestData.sites) { case (name, site) =>
s"serialize and deserialize a site [$name]" in {
val parsed = EventProcessor.apply(EventProcessor.unapply(site))
parsed must be_===(site)
}
}
}
}
开发者ID:dkomanov,项目名称:scala-serialization,代码行数:19,代码来源:EventProcessorTest.scala
示例7: map
//设置package包名称以及导入依赖的类
package utils
import de.flapdoodle.embed.mongo.MongodStarter
import de.flapdoodle.embed.mongo.config.{MongodConfigBuilder, Net}
import de.flapdoodle.embed.mongo.distribution.Version
import de.flapdoodle.embed.process.runtime.Network
import org.specs2.mutable.Specification
import org.specs2.specification.core.Fragments
import reactivemongo.api.{MongoConnection, MongoDriver}
trait EmbeddedConnection extends Specification {
val Port = 12345
private val starter = MongodStarter.getDefaultInstance
private val mongodConfig = new MongodConfigBuilder()
.version(Version.Main.PRODUCTION)
.net(new Net(Port, Network.localhostIsIPv6()))
.build()
private val mongodExecutable = starter.prepare(mongodConfig)
override def map(fs: => Fragments) = startMongo ^ fs ^ stopMongo
private def startMongo = step {
mongodExecutable.start
Thread.sleep(2000)
success
}
private def stopMongo() = step {
Thread.sleep(10000)
mongodExecutable.stop()
success
}
def getConnection: MongoConnection = {
Thread.sleep(2000)
val driver = new MongoDriver
val connection = driver.connection("localhost:12345" :: Nil)
Thread.sleep(2000)
connection
}
}
开发者ID:salceson,项目名称:toik-games-price-comparator,代码行数:42,代码来源:EmbeddedConnection.scala
示例8: QueryTest
//设置package包名称以及导入依赖的类
package com.komanov.mysql.streaming
import org.specs2.mutable.SpecificationWithJUnit
import org.specs2.specification.Scope
import org.specs2.specification.core.Fragments
import scala.collection.mutable
class QueryTest extends SpecificationWithJUnit {
sequential
MysqlRunner.run()
Fragments.foreach(Drivers.list) { driver =>
s"${driver.name}" should {
s"prepare/select/clear database" in new ctx {
Query.clearTable(driver)
Query.prepareTable(driver)
Query.selectAtOnce(driver) must be_===(Query.TestData)
Query.selectViaStreaming(driver) must be_===(Query.TestData)
Query.clearTable(driver)
Query.selectAtOnce(driver) must beEmpty
}
s"stream everything" in new ctx {
Query.clearTable(driver)
Query.prepareTable(driver)
val result = mutable.ListBuffer[TestTableRow]()
Query.forEach(driver, row => result += row)
result.toList must be_===(Query.TestData)
}
}
}
class ctx extends Scope {
}
}
开发者ID:dkomanov,项目名称:mysql-streaming,代码行数:40,代码来源:QueryTest.scala
注:本文中的org.specs2.specification.core.Fragments类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论