Hi List
I have a controller method that I would like to render some objects as XML, using the following:
render :xml => @goals
Is there anyway in RSpec to check that the controller is indeed rendering xml?
Rory
Hi List
I have a controller method that I would like to render some objects as XML, using the following:
render :xml => @goals
Is there anyway in RSpec to check that the controller is indeed rendering xml?
Rory
Is this a conditional render call or does the action always render xml? It will always render xml if you tell it to, and you don’t need to test Rails; it’s already been tested.
Is this a conditional render call or does the action always render
xml? It will always render xml if you tell it to, and you don't need
to test Rails; it's already been tested.
That said, you could always check @response.content_type
Fred
Frederick Cheung wrote:
Is this a conditional render call or does the action always render xml? It will always render xml if you tell it to, and you don't need to test Rails; it's already been tested.
That said, you could always check @response.content_type
<snip>
Thanks Frederick and Ryan
To answer Ryan's question:
Currently, it will always render xml, but I am trying to do BDD and writing my specs first, therefore I am putting the spec in to force myself to remember to render as xml, rather than checking rails
I didn’t know about that @response.content_type, thanks Fred!
Also, isn’t it response, not @response?
I didn't know about that @response.content_type, thanks Fred!
Also, isn't it response, not @response?
Not as far as I know.
Fred
Frederick Cheung wrote:
I didn't know about that @response.content_type, thanks Fred!
Also, isn't it response, not @response?
Not as far as I know.
Fred
<snip> Plain old response seems to work for me. Does anybody know if there is some place where the response methods are documented (e..g response.code, response.content_type etc) ?
Rory McKinley wrote:
Plain old response seems to work for me. Does anybody know if there is some place where the response methods are documented (e..g response.code, response.content_type etc) ?
ActionController::AbstractResponse
Nice code in the pastie Very helpful. Thanks.
Spongy wrote: