views:

109

answers:

1

Hi,

I've a controller that defines the @projects variables to be displayed in the view.

There is any way to access to that projects in the cucumber step? Note that this variables contains the paginated results, the idea is to test if the values are being displayed in the page.

I've tried to access the variable through assigns and controller but they are both nill.

Thanks.

+3  A: 

The way you would generally handle this is in Cucumber is by testing the output directly.

So:

Given X projects When I view project page N I should see Project A I should not see Project B

If you are interrogating code from Cucumber you are probably DoingItWrong(tm).

Toby Hede
Ok, so i have to say the name (e.g.) of the 5 projects that should appear in the page?I thought that this could be more dynamic because the projects are being created by a factory.
miguelfteixeira
You can make it a bit more dynamic by looking for the elements in the page. You can make some quite smart tasks using html parsing and regex ... "So I can see 5 Projects on the page" might map to something looking for specific html elements.
Toby Hede
If the projects are being created by a factory, then you should be able to have access in your step definitions. So store the variable in the given step, and you should be able to access the variable in subsequent when\then steps
AlistairH