[rspec-users] render_template failure

David Chelimsky dchelimsky at gmail.com
Sat Sep 4 15:26:10 EDT 2010


On Sep 4, 2010, at 1:41 PM, Daniel Lidström wrote:

> Hello,
> 
> I am trying to run this integration test of my user controller within
> a rails 3 application:
> 
> # spec/requests/users_spec.rb
> 
> require 'spec_helper'
> 
> describe "Users" do
> 
>    describe "success" do
> 
>      it "should make a new user" do
>        lambda do
>          visit signup_path
>          fill_in "Name", :with => "Example User"
>          fill_in "Email", :with => "user at example.com"
>          fill_in "Password", :with => "foobar"
>          fill_in "Confirmation", :with => "foobar"
>          click_button "Sign up"
>          page.should have_css("div.flash.success", :text =>
> "Welcome")
>          response.should render_template("user/show")
>        end.should change(User, :count).by(1)
>      end
>    end
> end
> 
> The test fails when render_template is being called:
> 
> daniel at ubuntu /home/daniel/programming/bowling (signing-up) $ rspec
> spec/requests/users_spec.rb -e "should make a new user"
> Run filtered using {:full_description=>/(?-mix:should make a new
> user)/}
> F
> 
> Failures:
>  1) Users signup success should make a new user
>     Failure/Error: response.should render_template("user/show")
>     @request must be an ActionDispatch::Request
>     # ./spec/requests/users_spec.rb:34
>     # ./spec/requests/users_spec.rb:26
> 
> Finished in 0.41306 seconds
> 1 example, 1 failure
> 
> I am using rspec-rails (2.0.0.beta.20) with capybara (0.3.9). What am
> I missing here? For what it's worth I have verified the behaviour
> manually: registering a new user does indeed take me to the show page.
> Thanks in advance!

The problem is that capybara doesn't assign anything to the @request variable after visit, so it doesn't support any of the built-in rails assertions that rely on @request, and render_template delegates to assert_template.

I'd file a bug with capybara on this one.

Cheers,
David


More information about the rspec-users mailing list