document ObjectFor RSpec Rails request specs the document object is already defined by RSpec::HTML as the parsed response body.
If you are testing HTML in any other context, e.g. for parsing ActionMailer emails, simply define document with a let or subject block that calls the provided parse_html helper: