0

I have code like this

 "When some call is made, status is (+value+)" in {
        Get("/path") ~> routeToCall ~> check {
           // some statements
           status === OK  <---- this value I want in When Statment
        }
      }

whatever status we get OK or Fail, I want it in "when....... status is OK" some thing.

Sanjay Rabari
  • 2,091
  • 1
  • 17
  • 32
  • I understand what you want to do but I'm not sure it is sensible. It doesn't seem like a spec if it's state cannot be determined ahead of time. – Robert Horvick Feb 15 '16 at 16:02
  • My understanding is that your test assertion will vary depending on whether the HTTP Response is `2XX` versus `5XX`. If that's true, then why can't you simply use an `if/else`? – Kevin Meredith Feb 15 '16 at 17:42
  • This is the subject of the `specs2-gwt` module. Please have a look at https://etorreborre.github.io/specs2/guide/SPECS2-3.7.1/org.specs2.guide.GivenWhenThenStyle.html – Eric Feb 15 '16 at 21:01

1 Answers1

0

With the specs2-gwt module you can write something like

class APISpec extends mutable.Specification with 
   org.specs2.specification.dsl.mutable.GWT with   
   StandardDelimitedStepParsers {

   "When some call is made, status is {OK}".example(aString) { expected: String =>
     Get("/path") ~> routeToCall ~> check {
       // some statements
       status === expected
     }
   }
}

Please check the documentation for more examples.

Eric
  • 15,494
  • 38
  • 61