If I have an action that should render nothing for certain Javascript requests, how can I test that that’s what it did?
That is, if the action is:
def some_action
respond_to do |format|
format.js { render :nothing => true if some_condition }
end
end
…how can I write a functional test to verify that it really did render nothing?
Edit: assert /\A\s*\z/.match(@response.body) asserts that the body contains only whitespace, is that testing the right thing?
assert /\A\s*\z/.match(@response.body)asserts that body contains only whitespace, which appears to be the simplest approach to this problem. More specific tests run into issues, since it apparently puts some odd whitespace characters into the body.