What I want to do is get my request unit test to enter the format.text
block in my controller:
def preview
byebug
respond_to do |format|
format.text { render template: 'reporting/iue/report_mailer/report.text' }
format.html { render template: 'reporting/iue/report_mailer/report.html' }
end
end
In my request rspec I'm passing the as: :text
option
subject(:request) do
get api_iue_preview_path(report.id), headers: auth_headers, as: :text
end
But it doesn't enter the text
block.
I've observed that:
(byebug) request.format
#<Mime::Type:0x007faaf921c8b0 @synonyms=["application/xhtml+xml"], @symbol=:html, @string="text/html", @hash=-3118253865377356622>
(byebug) request.format.html?
true
(byebug) request.format.text?
false
Meaning 'text/html'
does not count as text format, but does count as an html.
Does anyone know why?