Questions tagged [spec2]
21 questions
                    
                    8
                    
            votes
                
                3 answers
            
        scala spec2 I am Unable to create a test that uses must be_== and failure at the same time
I am new to Scala and Spec2.
I would like to create the following test but I get an error from the compiler.
Here is the test I would like to write
import org.specs2.mutable._
import org.specs2.specification._
import org.specs2.matcher._
import…
        
        shodz
        
- 344
 - 3
 - 13
 
                    7
                    
            votes
                
                1 answer
            
        Mocking Scala void function using Mockito
I found a few answers for this but nothing is working for me. 
Trying to mock Apache Shiro Subject interface login method which returns void.
Interface:
    void login(AuthenticationToken token) throws AuthenticationException;
I have tried :
   #1
…
        
        Barry
        
- 1,800
 - 2
 - 25
 - 46
 
                    5
                    
            votes
                
                1 answer
            
        sbt assembly with integration test
Hi i have an SBT build file that handles Integration test within our organization, the test themselves work and i can run separately unit and it test. However when packaging the app with sbt-assembly i am not able to run both test sequentially (unit…
        
        user145634
        
- 125
 - 7
 
                    4
                    
            votes
                
                2 answers
            
        How to define a custom argument matcher with mockito in spec2?
I want to verify if the business logic passes the expected user object to dao, but I can't figure how to write an custom argument matcher for it.
"user" should {
    "be saved" in {
        val dao = new UserDao()
        dao.save(any[User]) returns…
        
        Freewind
        
- 193,756
 - 157
 - 432
 - 708
 
                    3
                    
            votes
                
                1 answer
            
        Why sometimes exception can't be captured in Spec2?
The scala test code:
import play.api.test._
import scala._
import org.specs2.execute.Result
object ThrowTest extends PlaySpecification {
  "throwA" should {
    "catch the exception test1" in {
      world must throwA[Exception]
    }
    "catch…
        
        Freewind
        
- 193,756
 - 157
 - 432
 - 708
 
                    2
                    
            votes
                
                1 answer
            
        pact-jvm-consumer-specs2 - missing: [error] method: GET
I have problem with Pact JVM for spec2 consumer running with sbt.
- What can be wrong? 
- I doesn't generate any pact file.
given: 
sbt project with dependencies 
"au.com.dius" %% "pact-jvm-consumer-specs2" % "3.2.11"
"org.specs2" %% "specs2-junit"…
        
        user3245386
        
- 41
 - 3
 
                    2
                    
            votes
                
                1 answer
            
        In Play 2.2, Spec2 tests, I get Configuration error[Cannot connect to database [default]]
I am using Scala Spec2 in Play Framework version 2.2 application. When I run the tests, I get following errors: 
$ test-only ApplicationSpec
Mode is Test, Loading: application.test.conf
Create schema
Populate the application schema...
Stopping the…
        
        tuxdna
        
- 8,257
 - 4
 - 43
 - 61
 
                    1
                    
            vote
                
                0 answers
            
        How to run single spec2 test with maven?
I have a scala class with several spec2 tests in it and maven as build tool. I can't find how I can launch one single spec2 test using maven. Is it possible at all? 
        
        Alexandr Radchykov
        
- 166
 - 12
 
                    1
                    
            vote
                
                0 answers
            
        Request was not handled with spray-testkit
My service route:
get(
  path("add" / IntNumber / IntNumber)( (a, b) =>
    complete((a + b).toString())
  )
) ~
post(
  path("add") (
    formFields('a.as[Int], 'b.as[Int]) {
      (a, b) => complete((a + b).toString())
    })
)
my spec:
import…
        
        python_kaa
        
- 1,034
 - 13
 - 27
 
                    1
                    
            vote
                
                1 answer
            
        Scala: Spec2 Dependencies
how would one declare dependencies in Spec2 (Unit-Style)?
Example:
object MySpec extends Specification {
  firstDo MyOtherSpec
}
So MyOtherSpec's test execute before MySpec's tests!
        
        Tim Joseph
        
- 847
 - 2
 - 14
 - 28
 
                    1
                    
            vote
                
                0 answers
            
        Are any[Param] and Param(anyInt) equivalent while stubbing in Scala Spec2?
I'm having a strange behaviour while stubbing method that takes case classes as parameters.
I'm still trying to understand why, but in one case I'm getting a 
You cannot use argument matchers outside of verification or stubbing.
Examples of correct…
        
        Luca Molteni
        
- 5,230
 - 5
 - 34
 - 42
 
                    1
                    
            vote
                
                1 answer
            
        Controller action returns "Invalid Json" when using a Fakerequest from a spec2 test
I am using playframework 2.6 and play-slick 0.8.0. 
Action code: 
def addCompany = Authenticated {
 DBAction(parse.json) {
   implicit rs => {
     val newCompany = rs.request.body
     val result =…
        
        eeb
        
- 71
 - 7
 
                    1
                    
            vote
                
                1 answer
            
        Same function returns different result when running in console or spec2
It's a very strange problem.
I have a simple class which can decode a base64 string and get the first part before the ::
import scala.util.{Success, Try}
import org.apache.commons.codec.binary.Base64
class IdDecoder {
  def decode(token: String):…
        
        Freewind
        
- 193,756
 - 157
 - 432
 - 708
 
                    0
                    
            votes
                
                1 answer
            
        How to test an injected class through Spec2?
I am trying to test a class 
@Singleton
class Foo @Inject()(bar: Bar)(implicit ec: ExecutionContext) {
  def doSomething = bar.doSomethingInBar
}
class Bar {
  def doSomethingInBar = true
}
through a Specification class that is mentioned…
        
        Fahad Siddiqui
        
- 1,829
 - 1
 - 19
 - 41
 
                    0
                    
            votes
                
                1 answer
            
        Test response is a JsonArray -- Play framework 2.4.2 Spec 2 testing
I'm trying to test bellow using Play 2.4.2 , Spec 2 ,
" test response Returns a json  Array" in new WithApplication {
  val response = route(FakeRequest(GET, "/myservice/xx")).get
  // ??? test response is a json array
}
What would be the way to…
        
        nish1013
        
- 3,658
 - 8
 - 33
 - 46