public class ControllerSpec extends RequestSpecHelper
 public class GreeterController extends AppController{
   ...
 }
 
 then the test will look like this:
 
 public class GreeterControllerSpec extends ControllerSpec{
 ...
 }
 
 ActiveWeb controller specs allow for true TDD, since they do not have a compiler dependency on controllers.
 You can describe full behavior of your controller before a controller class even exists. Simplest example:
 
 public GreeterControllerSpec extends ControllerSpec{
  @Test
  public void shouldRespondWithGreetingMessage(){
      request().get("index");
      a(responseCode()).shouldBeEqual(200);
      a(assigns().get("message")).shouldBeEqual("Hello, earthlings!");
  }
 }
 
 In a code snippet above, a request with HTTP GET method is simulated to the GreeterController, index() action.
 Controller is expected to assign an object called "message" with value "Hello, earthlings!" to a view. 
 This class will not open a connection to a test DB. If you need a connection,
 use DBControllerSpec.org.javalite.activeweb.DBControllerSpec}.SpecHelper.DynamicBuilder, SpecHelper.ModuleBuilder| Constructor and Description | 
|---|
ControllerSpec()  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
atStart()  | 
protected String | 
getControllerClassName()  | 
protected String | 
getControllerPath()
Returns a controller path - this includes packages if there are any after "app.controllers". 
 | 
protected RequestBuilder | 
request()
Use this DSL-ish method to send requests to controllers from specs. 
 | 
assigns, atStart00, bytesContent, contentType, cookie, cookieValue, count, getCookies, header, headerNames, headers, layout, redirected, redirectValue, responseContent, statusCode, template, text, val, val, valBoolean, valDouble, valFloat, valInteger, valLong, vals, valStringafterEnd, createInjector, flash, flash, flashExists, injector, registerTag, session, session, session, sessionBoolean, sessionDouble, sessionFloat, sessionHas, sessionInteger, sessionLong, sessionObject, sessionString, setInjector, setTemplateLocation@BeforeEach public void atStart()
atStart in class SpecHelperprotected RequestBuilder request()
RequestBuilder with convenience methods.protected final String getControllerPath()
protected final String getControllerClassName()
Copyright © 2020 JavaLite. All rights reserved.