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.

On Wed, Apr 2, 2008 at 6:09 PM, Tim H. [email protected] 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

On 03/04/2008, at 10:09 , Tim H. 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

On Thu, Apr 3, 2008 at 8:03 AM, Rick DeNatale [email protected]
wrote:

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.

On Thu, Apr 3, 2008 at 8:58 AM, David C. [email protected]
wrote:

On Thu, Apr 3, 2008 at 8:03 AM, Rick DeNatale [email protected] 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!


Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/

On Wed, Apr 2, 2008 at 7:09 PM, Tim H. [email protected] 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/