tags:

views:

17

answers:

1

Hi there folks,

It's probably going to be one of the lame and novice level questions but I'm struggling with it for some time and it's still not working.

I have a HomeController:

package example

class HomeController {

    def index = { 
        [ message: "Hello, world!" ]
    }
}

Now I've installed easyb plugin:

grails install-plugin easyb

I've also created a basic story for this controller (in "test/unit" folder):

scenario "Should return 'Hello, world!' message", {
    given "Controller is instantiated", {
        mockController HomeController
        controller = new HomeController()
    }

    when "Controller received request for index action"
    and "No additional parameters are expected", {
        result = controller.index()  
    }

    then "Controller displays Hello, world!", {
        result.message.shouldBe "Hello, world!"
    }
}

When I run the easyb tests

grails test-app unit:easyb

instead of this test passing as it should I get the following error message at "when No additional parameters are expected":

[FAILURE: No signature of method: HomeController.index() is applicable for argument types: () values: []]

and then for the second part at "then Controller displays Hello, world!"

[FAILURE: No such property: result for class: HomeController]

I'm basically following the instructions from http://grails.org/plugin/easyb.

Can anyone explain to me what I'm doing wrong?

Matthias.

A: 

Oh well, I found it... conventions, conventions, conventions....

Naming the scenario file HomeController.story forced the engine to include "controller" variable in the scope. What's not clear though is why I couldn't do it again...

Nevermind. After removing the "given" part completely it works as it should.

Matthias Hryniszak