Topic: How do I trace which file rspec is loading?

I'm using Rails 3.0.1, RSpec-Rails 2.0.1 and Webrat 0.7.1. I have the following test:

describe PagesController do
  describe "GET 'main'" do
    it "should have the right title" do
      get 'main'
      response.should have_selector("title", :content => "My title")
    end
  end
end

The HTML of pages#main checks out: it contains My Title. When I run rspec, it gives me a failure on this test, and says it expects to find the tag in the following line:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">

Since this is not the file stored at pages#main, I take it that rspec is, for some reason, loading the wrong page. How do I solve this? Or, failing a general solution, how can I get rspec to tell me which page it is trying to load, so that I can try to figure out why it is going to this other page? Thanks.

Re: How do I trace which file rspec is loading?

Maybe need add render_views

describe PagesController do
  render_views 
  describe "GET 'main'" do
    it "should have the right title" do
      get 'main'
      response.should have_selector("title", :content => "My title")
    end
  end
end

Last edited by goodvin (2010-11-05 08:57:32)

Re: How do I trace which file rspec is loading?

I remember having similar issue with newest rspec and webrat. Out of curiosity - can you try to install capybara gem and try with that instead of webrat.