views:

138

answers:

1

Hi all,

I could use some help figuring out what's going on. Check the log output below -- why would rails treat the two renders differently? Why does one succeed, without any related SQL calls and the second fail -- with an SQL access. (It's not an ActiveRecord model, no SQL should be involved in this render.)

Background

I have a cucumber feature with two scenarios that each rely on Webrat to resolve the step 'When I go to the list of articles' The Article model is not an ActiveRecord model, and shouldn't rely on SQL for access.

If I order the scenarios #1, #2 in the file, the first scenario passes all tests, while the second scenario fails, as expected, at a later different step.

If I order the scenarios #2, #1 in the file, the #2 scenario fails as expected, after passing the step in question. But the #1 scenario now fails the 'When I go to the list of articles' step with:

Resource not found (ActionView::TemplateError) features/article.feature:23:in `When I go to the list of articles'

test.log contents

-------- webrat test is successful - non-db backed model --------------

Processing ArticlesController#index (for 127.0.0.1 at 2009-08-12 13:22:37) [GET]
  Parameters: {"action"=>"index", "controller"=>"articles"}
Rendering template within layouts/application
Rendering articles/index
Completed in 9ms (View: 6, DB: 0) | 200 OK [http://www.example.com/ccc/articles]
REQUESTING PAGE: GET /ccc/articles/new with {} and HTTP headers {"HTTP_REFERER"=>"/ccc/articles"}

-------- webrat test fails ---------------------

Processing ArticlesController#index (for 127.0.0.1 at 2009-08-12 13:22:37) [GET]
  Parameters: {"action"=>"index", "controller"=>"articles"}
Rendering template within layouts/application
Rendering articles/index


Processing ApplicationController#index (for 127.0.0.1 at 2009-08-12 13:22:37) [GET]
  Parameters: {"action"=>"index", "controller"=>"articles"}
      ^[[4;35;1mSQL (0.1ms)^[[0m   ^[[0mROLLBACK^[[0m
A: 

In order to rule out some possibilities: change the location of the articles index page in paths.rb to something like "/test.html" and put that file in "/public" -- see if the steps exhibit the same behavior. If they do, something is most likely wonky in one of your test setup/teardown actions. If they do not, I'd look through the logic of the action itself and the contents of the template to understand what might be happening.

John Pignata
Thanks, I'll give it a try.
marfarma