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 <mauricio.linhares at gmail.com> 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 Maddox <pergesu at gmail.com>
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:> 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 )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_emptyYou 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> > > On Sat, Jun 7, 2008 at 1:27 PM, Pat Maddox <pergesu at gmail.com> 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 > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users