Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert on render_template failed because of response is string and does not have body method #9795

Closed
iambowen opened this issue Mar 19, 2013 · 4 comments

Comments

@iambowen
Copy link

hi, just upgrade to latest rails distribution and found this issue.

I am testing template that rendering another partial in haml test file, and the test is like this:

render
rendered.should render_template('template_name')

Then I will caught in an error complains that "response does not have method body" . It turns out that the assert_template method in test_case.rb file under actionpack/lib add a new line calling the body method of response.

//Force body to be read in case the template is being streamed
response.boy

I finally give up use this way to assert the rendered template, instead, i assert whether the element shows up in the rendered partial.

GIven if I want continue to use render_template in haml templates tests, do I have any other way to avoid that or how could covert the pure string into an http response?

@ekampp
Copy link
Contributor

ekampp commented Mar 26, 2013

I find, that it's better to test functionality: I.e. id the correct content show up on the complete, rendered template, than to test implementation: Was the template included in a particular maner.

But, when that's said, I'm using haml, and I have never had problems using rspec and the render_template matcher. What version of rails, rspec and haml are you using?

@JonRowe
Copy link
Contributor

JonRowe commented May 7, 2013

Heya @iambowen did you solve this? If not can you provide some more information? (version of rails, rspec, haml etc)

@senny
Copy link
Member

senny commented May 28, 2013

@iambowen what is the state of this issue? Can you provide a running example or a sample application on GitHub?

@iambowen
Copy link
Author

Sorry, it's been like 2 months ago, I can't remember that much. This thing happens when I tried to use render_template method when testing haml template instead of testing controller to render certain template. The problem is solved. Should I close the issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants