Questions tagged [specs2]

Executable software specification tool that specifies behaviour both at the class and application level using Scala.

specs2 is a library for writing executable software specifications in Scala.

547 questions
6
votes
2 answers

Specs2 and @Before/@After-like methods

Given the code like: class RESTAcceptanceTest extends Specification { override def is = anonymous ^ signinOAuth def anonymous = "Something" ^ givenSomething ^ "must happen" ^ mustHappen end def signinOAuth =…
jdevelop
  • 12,176
  • 10
  • 56
  • 112
6
votes
1 answer

play framework 2: test a request with a json string as body

I have the following action def save() = Action(parse.json) { implicit request => request.body.asOpt[IdeaType].map { ideatype => ideatype.save.fold( errors => JsonBadRequest(errors), ideatype => Ok(toJson(ideatype)) ) …
opensas
  • 60,462
  • 79
  • 252
  • 386
6
votes
1 answer

What does the <% operator mean in Scala generics?

In specs2 there is a method called Around, documented here that has the following example: object http extends Around { def around[T <% Result](t: =>T) = openHttpSession("test") { t // execute t inside a http session } } The source for…
Jeff Wu
  • 2,428
  • 1
  • 21
  • 25
6
votes
3 answers

Using specs2 and FakeApplication() to test database fails evolution inserts

This is for Play! Framework 2.0. I'm trying to write a simple test case to ensure my user model is functioning properly and persisting data in my database. I'd like to run it in memory if possible so I can get a fresh start with every new run. The…
5
votes
2 answers

Specs2: How to turn a Seq[Matcher[A]] into a single Matcher[A]?

Given a sequence Seq[Matcher[A]] I want to obtain a single Matcher[A] that succeeds when all matchers inside the sequence succeed. Edit The answer provided by myself seems a bit clumsy and in addition it would be nice if all failing matchers of the…
ziggystar
  • 28,410
  • 9
  • 72
  • 124
5
votes
2 answers

Existing data for tests is not found Scala Specs2

I am building the integration tests which would read the data generated after the previous test cases and check it with expected result. When I run the tests the generated data is not visible in the directory in the next test cases, although it…
Cassie
  • 2,941
  • 8
  • 44
  • 92
5
votes
1 answer

Play Framework and Slick: testing database-related services

I'm trying to follow the most idiomatic way to having a few fully tested DAO services. I've got a few case classes such as the following: case class Person ( id :Int, firstName :String, lastName :String ) case class Car ( id …
mfirry
  • 3,634
  • 1
  • 26
  • 36
5
votes
1 answer

Unresolved dependency with specs2 scalaz-stream 0.5a

Since adding: "org.specs2" %% "specs2" % "2.4.15" % "test" withSources() withJavadoc(), To my build file I get [warn] Note: Unresolved dependencies path: [warn] org.scalaz.stream:scalaz-stream_2.10:0.5a [warn] +-…
samthebest
  • 30,803
  • 25
  • 102
  • 142
5
votes
1 answer

java.lang.ClassNotFoundException: IntegrationSpec while running specs2 Tests in Intellij 14

What I did is: Install Intellij 14 (the same problem appears also with Intellij 13) Install Scala 1.0 plugin for Intellij (supports Scala, SBT, SSP, HOCON and Play 2). Create a new Play 2.x project Run the project from Intellij 14 (open via…
5
votes
1 answer

Running Scala tests in Intellij

I am trying to run Scala tests (specs2) in Intellij Coummunity Edition 13.1.3. I am getting the following error: Connected to the target VM, address: '127.0.0.1:57980', transport: 'socket' 'Start' method is not found in MyNotifierRunner…
sebi
  • 1,791
  • 3
  • 25
  • 43
5
votes
2 answers

specs2: How to use "failtrace" option

In my specs2 tests, I frequently use helper functions to test groups of conditions at once. Unfortunately, that makes the line number output of failed tests useless, since all failures are on the same line. Google turned up that there's a…
Ben Dilts
  • 10,535
  • 16
  • 54
  • 85
5
votes
1 answer

Play Framework, Specs2 - Calling controller method directly from unit test

I have a method in my controller that I'd like to call directly. It takes in a POSTed form, validates it, then returns something. I want to test this directly - i.e. not go through the routes helper. This is my Form code (FormFields is just a case…
Ren
  • 3,395
  • 2
  • 27
  • 46
5
votes
1 answer

How to get past SQLException: Attempting to obtain a connection from a pool that has already been shutdown

I've got a Play (v 2.2.0) app using Typesafe Slick (v 1.0.1), and I'm trying to write a test (specs2) that seeds a PostgreSQL database, then makes a call to various controller actions to validate the existence of the data. In my test, I have: …
jbnunn
  • 6,161
  • 4
  • 40
  • 65
5
votes
1 answer

Run test in memory db play framework

I'm trying to run some tests for my application. It should be possible to run tests in a fresh new memory database but I won't get it to work. My test looks like this now: "Server" should { "persist data for personal user properly" in { …
malmling
  • 2,398
  • 4
  • 19
  • 33
5
votes
1 answer

Error using Mockito and Specs2

I have the following spec: import org.specs2.mock.Mockito import org.specs2.mutable.Specification class LinkUserServiceSpec extends Specification with Mockito { val linkUserService = mock[LinkUserService] "The 'LinkUserService' isUserLinked…
ThaDon
  • 7,826
  • 9
  • 52
  • 84