You can use assert_select quite easily with HelperTestCase. Simply do the following:
- Add
@response = ActionController::TestResponse.new into the HelperTestCase#setup - In your test case, store the result of the helper method in
@response.body
The following example demonstrates:
class ApplicationHelperTest < HelperTestCase
include ApplicationHelper
def test_checkmark_img
@response.body = checkmark_img(true)
assert_select "img"
end
end
When using the content_tag method to generate html, you must also include the CaptureHelper and TextHelper modules into HelperTestCase. Due to a known bug, you cannot pass a block to content_tag from a test case.