How to assert the content of the response body in rails 3 functional test
I have a Rails 3.0.7 application. In the functional test I have following code. I am not using rspec or anything. This is plain vanilla functional test that comes with ra开发者_运维问答ils.
assert_response :success
Above assertion is passing. However I need to assert on the full content that is returned as the body of the response. How do I access the response body?
You can access the response body in a functional test via:
response.body
Often, in this style of testing, you really want to use the method:
assert_select
A nice way to check out the assert_select API is via the cheat gem:
gem install cheat
cheat assert_select
This rails testing guide might help you some: http://guides.rubyonrails.org/testing.html#testing-views
精彩评论