Upio Upio - 1 year ago 108
Scala Question

Specs2 "value in is not a member of String"

I cannot compile the simple specs2 hello world example:

import org.junit.runner.RunWith
import org.specs2.Specification
import org.specs2.runner.JUnitRunner

import org.specs2.mutable._

class SampleTest extends Specification {

"The 'Hello world' string" should {
"contain 11 characters" in {
"Hello world" must have size(11)
"start with 'Hello'" in {
"Hello world" must startWith("Hello")
"end with 'world'" in {
"Hello world" must endWith("world")

Getting error:

:compileTestScala [ant:scalac] Element '/home/~~~~/workspaces/~~~~/build/resources/main' does not exist.

[ant:scalac] /home/~~~~/workspaces/~~~~/src/test/scala/com/~~~~/ingestion/SampleTest.scala:16:
error: value in is not a member of String

[ant:scalac] "contain 11 characters" in {

[ant:scalac] one error found

:compileTestScala FAILED

I'm using Gradle (hence the @RunWith annotation). Using specs2 version 'org.specs2:specs2_2.10:2.4.15'

apply plugin: 'java'
apply plugin: 'scala'

repositories {
maven {
url "http://dl.bintray.com/scalaz/releases"

configurations {
compile.extendsFrom provided

dependencies {
provided 'org.apache.hadoop:hadoop-client:2.2.0'

compile 'org.scala-lang:scala-library:2.10.0',


testCompile 'junit:junit:4.11',

jar {
dependsOn configurations.runtime
from {
(configurations.compile - configurations.provided).collect {
it.isDirectory() ? it : zipTree(it)

Answer Source

you need to extend org.specs2.mutable.Specification instead of org.specs2.Specification for that syntax.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download