Curious Yogurt
2010-Nov-01 01:14 UTC
[rspec-users] How do I figure out which (wrong) 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.
David Chelimsky
2010-Nov-01 13:03 UTC
[rspec-users] How do I figure out which (wrong) file rspec is loading?
On Oct 31, 2010, at 11:14 PM, Curious Yogurt wrote:> 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.Controller specs don''t render views unless you tell them to explicitly. Please see: http://relishapp.com/rspec/rspec-rails/v/2-0/dir/controller-specs/do-not-render-views http://relishapp.com/rspec/rspec-rails/v/2-0/dir/controller-specs/render-views HTH, David
Evgeniy Dolzhenko
2010-Nov-01 14:03 UTC
[rspec-users] How do I figure out which (wrong) file rspec is loading?
Use `response.should render_template("main")` to set assertion on template that should be rendered for an action. If it fails it will print you the list of templates that got actually rendered. Also I guess you should show us your PagesController#main action, seems like what you get there is an empty response rendered with default views/layout/application.html.erb layout. On Mon, Nov 1, 2010 at 4:14 AM, Curious Yogurt <starempireelite at gmail.com> wrote:> 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. > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Curious Yogurt
2010-Nov-01 15:57 UTC
[rspec-users] How do I figure out which (wrong) file rspec is loading?
I solved the problem, though I didn''t track down the cause. It turns out that by tearing our rspec and reinstalling it, things started to work correctly. I''m thinking it might have been some sort of version conflict. Thanks so much for the suggestions. On Nov 1, 7:03?am, Evgeniy Dolzhenko <dolze... at gmail.com> wrote:> Use `response.should render_template("main")` to set assertion on > template that should be rendered for an action. > If it fails it will print you the list of templates that got actually rendered. > > Also I guess you should show us your PagesController#main action, > seems like what you get there is an empty response rendered with > default views/layout/application.html.erb layout. > > On Mon, Nov 1, 2010 at 4:14 AM, Curious Yogurt > > > > > > > > <starempireel... at gmail.com> wrote: > > 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. > > _______________________________________________ > > rspec-users mailing list > > rspec-us... at rubyforge.org > >http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-us... at rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users