Hello guys,
Is there any way to match a render :nothing?
I coudn’t find any way to do this so i’ve just changed my controllers
to do a “head :ok”, but it would be nice to know if there is any other
way 
–
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)
João Pessoa, PB, +55 83 8867-7208
On Sat, Jun 7, 2008 at 9:23 AM, Maurício Linhares
[email protected] wrote:
Hello guys,
Is there any way to match a render :nothing?
I coudn’t find any way to do this so i’ve just changed my controllers
to do a “head :ok”, but it would be nice to know if there is any other
way 
I’m pretty sure you can do
response.body.should be_blank # or == “”
If you don’t like how it reads, you could create a custom
render_nothing matcher.
Pat
Hi Pat,
'response.body.should be_empty" does not work 
The string on the response after a “render :nothing” is " " (one space
character), so i had to do a strip to make it work. I guess i’ll write
my own render_nothing matcher anyway. Here’s how it is now:
@assignments.should_receive( :find ).and_return( [ @assignment ] )
@assignments.should_not_receive( :create )
do_xhr
response.should be_success
response.body.strip.should be_empty
On Sat, Jun 7, 2008 at 1:27 PM, Pat M. [email protected] wrote:
I’m pretty sure you can do
response.body.should be_blank # or == “”
If you don’t like how it reads, you could create a custom
render_nothing matcher.
Pat
–
Maurício Linhares
http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/
(en)
João Pessoa, PB, +55 83 8867-7208
Oi Maurício,
On Jun 7, 2008, at 11:37 AM, Maurício Linhares wrote:
@assignments.should_not_receive( :create )
I would put should_not_receive(:create) in a separate example as it’s
a different concept from rendering nothing.
do_xhr
response.should be_success
response.body.strip.should be_empty
You can use the simple_matcher method for this quite … simply:
def render_nothing
simple_matcher(:nothing) do |response|
response.body.strip == ''
end
end
The failure message on this is quite verbose, and I have an idea about
a solution for that, but it’ll work 
Tchau,
David