Forum: RSpec render_template on create and update action - unexpected result with namespaced controllers

Posted by astjohn (Guest)
on 2011-12-22 06:09
(Received via mailing list)
All,

I've been having issues with my namespaced controllers and specs.  I
receive the following errors only on my create and update actions
(with invalid parameters) and only on my namespaced controllers.  My
non-namespaced controllers have similar specs and work well.  The
application works as expected, but the specs are reporting:


Failures:

  1) Management::CountriesController POST create with invalid params
re-renders the 'new' template
     Failure/Error: response.should render_template(:new)
       expecting <"new"> but rendering with <"">
     # ./spec/controllers/management/countries_controller_spec.rb:
169:in `block (4 levels) in <top (required)>'

  2) Management::CountriesController PUT update with invalid params re-
renders the 'edit' template
     Failure/Error: response.should render_template(:edit)
       expecting <"edit"> but rendering with <"">
     # ./spec/controllers/management/countries_controller_spec.rb:
240:in `block (4 levels) in <top (required)>'



Here's a gist to help my explanation:
https://gist.github.com/1468233

I'm using the Devise/CanCan combo.

Any help is greatly appreciated.  I've been ignoring these for a while
and it's time to fix them.

Cheers,
Adam
Posted by Justin Ko (Guest)
on 2011-12-22 09:20
(Received via mailing list)
On Dec 12, 2011, at 10:16 AM, astjohn wrote:

>
>       expecting <"edit"> but rendering with <"">
> Any help is greatly appreciated.  I've been ignoring these for a while
> and it's time to fix them.
>
> Cheers,
> Adam
> _______________________________________________
> rspec-users mailing list
> rspec-users@rubyforge.org
> http://rubyforge.org/mailman/listinfo/rspec-users

An empty response body tells me it's redirecting. Couple ways to check 
that:

1.) Use "puts" and "raise" to see if it even gets to the `respond_with`
2.) Look at the test logs to see what it's responding with.
3.) Use `response.response_code.should eq(200)`
Posted by Adam St. John (adam_s)
on 2012-01-29 23:22
Hi Justin,

Thanks for your reply.  I agree with your suggestions, however the 
response is fine.  Response code == 200 and nothing unusual in the logs.

Note that my non-namespaced controllers with similar tests behave as 
they should.  This weird issue only happens for my namespaced 
controllers.

-Adam

Justin Ko wrote in post #1037818:
> On Dec 12, 2011, at 10:16 AM, astjohn wrote:
>
>>
>>       expecting <"edit"> but rendering with <"">
>> Any help is greatly appreciated.  I've been ignoring these for a while
>> and it's time to fix them.
>>
>> Cheers,
>> Adam
>> _______________________________________________
>> rspec-users mailing list
>> rspec-users@rubyforge.org
>> http://rubyforge.org/mailman/listinfo/rspec-users
>
> An empty response body tells me it's redirecting. Couple ways to check
> that:
>
> 1.) Use "puts" and "raise" to see if it even gets to the `respond_with`
> 2.) Look at the test logs to see what it's responding with.
> 3.) Use `response.response_code.should eq(200)`
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.