Tim Haines
2008-Apr-02 23:09 UTC
[rspec-users] newb q: Can story steps report a view rendering error?
Hi''ya I have a When step that calls get game_url. It turns out that calling this page is resulting in a render error, which explains my failing Then steps. It would help me if the story told me there was a problem rendering the response. Is there any way to get the story steps to automatically raise an error if such a problem occurs? For now I can add response.code.should == "200" or something similar.. Tim. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rspec-users/attachments/20080403/8e40cd9f/attachment.html
Kyle Hargraves
2008-Apr-03 00:31 UTC
[rspec-users] newb q: Can story steps report a view rendering error?
On Wed, Apr 2, 2008 at 6:09 PM, Tim Haines <tmhaines at gmail.com> wrote:> Hi''ya > > I have a When step that calls get game_url. It turns out that calling this > page is resulting in a render error, which explains my failing Then steps. > It would help me if the story told me there was a problem rendering the > response. Is there any way to get the story steps to automatically raise an > error if such a problem occurs? > > For now I can add response.code.should == "200" or something similar..I just rely on test.log, inside of which you will find the typical stacktrace produced by errors that occur while rendering a template. So that will explain the problem; to catch the explosion before your stories move on, you are right that you have to check the response code. Your code check, or the equivalent ''response.should be_success'', should suffice. webrat, for example, wraps its requests in a method ''request_page()'', and after every request it calls ''assert_response :success'' so that the story will fail fast. Kyle
Alex Satrapa
2008-Apr-03 00:37 UTC
[rspec-users] newb q: Can story steps report a view rendering error?
On 03/04/2008, at 10:09 , Tim Haines wrote:> For now I can add response.code.should == "200" or something similar..The page returned by Rails to provide you with the stack trace and stuff? That is a valid HTML page, and it comes along with a HTTP 200 OK response. What you need to do is look for stuff that you expect to see or not see on the page: # This will complain when your page isn''t rendered using the expected template response.should have_tag(''title'', ''This is the title I expect to see'') There used to be an article on using the have_tag matcher here: http://rubypond.com/articles/2008/03/31/using-rspec-have_tag/ ... however at the time of writing this email, I get a page stating only, "The page you are looking for is temporarily unavailable. Please try again later." Hopefully it comes back, I go back to read it for a refresher every now and then. Hope this helps! Alex
Rick DeNatale
2008-Apr-03 12:03 UTC
[rspec-users] newb q: Can story steps report a view rendering error?
On Wed, Apr 2, 2008 at 7:09 PM, Tim Haines <tmhaines at gmail.com> wrote:> Hi''ya > > I have a When step that calls get game_url. It turns out that calling this > page is resulting in a render error, which explains my failing Then steps. > It would help me if the story told me there was a problem rendering the > response. Is there any way to get the story steps to automatically raise an > error if such a problem occurs? > > For now I can add response.code.should == "200" or something similar..I can''t help but think that this level would more properly be covered by having good controller and view specs in addition to stories. -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/
David Chelimsky
2008-Apr-03 12:58 UTC
[rspec-users] newb q: Can story steps report a view rendering error?
On Thu, Apr 3, 2008 at 8:03 AM, Rick DeNatale <rick.denatale at gmail.com> wrote:> On Wed, Apr 2, 2008 at 7:09 PM, Tim Haines <tmhaines at gmail.com> wrote: > > > Hi''ya > > > > I have a When step that calls get game_url. It turns out that calling this > > page is resulting in a render error, which explains my failing Then steps. > > It would help me if the story told me there was a problem rendering the > > response. Is there any way to get the story steps to automatically raise an > > error if such a problem occurs? > > > > For now I can add response.code.should == "200" or something similar.. > > I can''t help but think that this level would more properly be covered > by having good controller and view specs in addition to stories.I can''t help agreeing with you Rick.> > -- > Rick DeNatale > > My blog on Ruby > http://talklikeaduck.denhaven2.com/ > > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
Rick DeNatale
2008-Apr-03 18:43 UTC
[rspec-users] newb q: Can story steps report a view rendering error?
On Thu, Apr 3, 2008 at 8:58 AM, David Chelimsky <dchelimsky at gmail.com> wrote:> On Thu, Apr 3, 2008 at 8:03 AM, Rick DeNatale <rick.denatale at gmail.com> wrote:> > I can''t help but think that this level would more properly be covered > > by having good controller and view specs in addition to stories. > > I can''t help agreeing with you Rick.Great minds think alike! Or as an English friend of mine liked to say in reply. Fools fail to differ! <G> -- Rick DeNatale My blog on Ruby http://talklikeaduck.denhaven2.com/