# Rspec test cannot be passed when render partial in layout

**URL:** <https://www.ruby-forum.com/t/rspec-test-cannot-be-passed-when-render-partial-in-layout/160150>\
**Category:** Rails\
**Created:** [February 12, 2009, 8:56am UTC](https://www.ruby-forum.com/t/rspec-test-cannot-be-passed-when-render-partial-in-layout/160150 "2009-02-12T08:56:59Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![zerogy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/67e7ee/32.png) [@zerogy](https://www.ruby-forum.com/u/zerogy)\
**Post date:** [February 12, 2009, 8:56am UTC](https://www.ruby-forum.com/t/rspec-test-cannot-be-passed-when-render-partial-in-layout/160150/1 "2009-02-12T08:56:59Z")

</div>

I have a problem stuck me couples of days, could anyone help me?  
Thanks very much.  
The problem is that rspec test cannot be passed when the layout  
contains :partial,  
once i removed the :partial, the rspec test passed successfully. I  
could not find out the reason.  
Below is my code:  
application.html.erb

 \<%= render :partial =\> 'shared/header' %\> 

 \<%= yield %\> 

 \<%= render :partial =\> 'shared/footer' %\> 

users\_controller\_spec.rb  
describe UsersController do  
describe “Requesting /forgot\_password using GET” do  
it “should be successful” do  
get :forgot\_password  
end  
end  
end

---

<div class="post-metadata">

**Author:** ![zerogy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/67e7ee/32.png) [@zerogy](https://www.ruby-forum.com/u/zerogy)\
**Post date:** [February 12, 2009, 9:04am UTC](https://www.ruby-forum.com/t/rspec-test-cannot-be-passed-when-render-partial-in-layout/160150/2 "2009-02-12T09:04:01Z")

</div>

would be nice to know if your page renders correctly when you access  
it with your browser. also post the code of the partial that’s causing  
the error and of course the error itself. what’s respec’s output?

---

<div class="post-metadata">

**Author:** ![zerogy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/67e7ee/32.png) [@zerogy](https://www.ruby-forum.com/u/zerogy)\
**Post date:** [February 12, 2009, 9:43am UTC](https://www.ruby-forum.com/t/rspec-test-cannot-be-passed-when-render-partial-in-layout/160150/3 "2009-02-12T09:43:52Z")

</div>

> and each error has same informationm which is “wrong number of  
> arguments (3 for 1)”  
> which method is called with 3 arguments instead of 1?  
> is there anymore information you can give us?

---

<div class="post-metadata">

**Author:** ![zerogy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/67e7ee/32.png) [@zerogy](https://www.ruby-forum.com/u/zerogy)\
**Post date:** [February 12, 2009, 9:54am UTC](https://www.ruby-forum.com/t/rspec-test-cannot-be-passed-when-render-partial-in-layout/160150/4 "2009-02-12T09:54:27Z")

</div>

i just do not know which method is called with 3 arguments instead of  
1, so i could not solve the problem.  
and i pasted the relevant code below:  
routes.rb:  
…  
map.resources :users, :member =\> { :suspend =\> :get, :unsuspend  
=\> :get }

users\_controller.rb:  
…

# render new.rhtml

def new  
@user = User.new  
end

users\_controller\_spec.rb:  
…  
describe “named routing” do  
before(:each) do  
get :new  
end  
it “should route new\_user\_path() to /users/new” do  
new\_user\_path().should == “/users/new”  
end  
end

new.html.erb:

# Sign up as a new user

\<% @user.password = @user.password\_confirmation = nil %\>

 \<% if flash[:error] %\> 
 \<%= flash[:error] %\> 
 \<% end %\> \<% form\_for :user, :url =\> users\_path, :html =\> {:class =\> 'bigform'} do |f| -%\> 

\<%= label\_tag 'login' %\> \<%= f.text\_field :login, :class=\>"text" %\>\<%= error\_message\_on "user", "login" %\>

```
  <div class="clearfix"><%= label_tag 'email' %>
  <%= f.text_field :email, :class=>"text" %>
  <%= error_message_on "user", "email" %></div>

  <div class="clearfix"><%= label_tag 'password' %>
  <%= f.password_field :password, :class=>"text" %>
  <%= error_message_on "user", "password" %></div>

  <div class="clearfix"><%= label_tag 'password_confirmation',

```

‘Confirm Password’ %\>  
\<%= f.password\_field :password\_confirmation, :class=\>“text” %\>  
\<%= error\_message\_on “user”, “password\_confirmation” %\>

  

  

\<%= submit\_tag ‘Sign up’ %\>
  
\<% end -%\> 

The error is:  
ActionView::TemplateError in ‘UsersController named routing should  
route new\_user\_path() to /users/new’  
wrong number of arguments (3 for 1)

PS: my rails version is 2.2, is there any more information needed?

---

<div class="post-metadata">

**Author:** ![zerogy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/67e7ee/32.png) [@zerogy](https://www.ruby-forum.com/u/zerogy)\
**Post date:** [February 12, 2009, 10:28am UTC](https://www.ruby-forum.com/t/rspec-test-cannot-be-passed-when-render-partial-in-layout/160150/5 "2009-02-12T10:28:31Z")

</div>

it’s hard to say what wenbt wrong. most likely you forgot to put a  
closing bracket somewhere or sth similar. i’d try to set a debugger  
into that test and go through it step by step (or better ‘next’ by  
‘next’ _g_) until you can nail down which method fails.

---

<div class="post-metadata">

**Author:** ![zerogy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/67e7ee/32.png) [@zerogy](https://www.ruby-forum.com/u/zerogy)\
**Post date:** [February 12, 2009, 9:18am UTC](https://www.ruby-forum.com/t/rspec-test-cannot-be-passed-when-render-partial-in-layout/160150/6 "2009-02-12T09:18:04Z")

</div>

Thanks for your replying.  
the page render correctly since i would visit it via browser, and it  
works all right.  
in fact, there is nothing special in my partial, i pasted it below:

\_footer.html.erb:

- About Us
- Privacy
- Contact Us
- Help

and each error has same informationm which is “wrong number of  
arguments (3 for 1)”

---

<div class="post-metadata">

**Author:** ![zerogy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/67e7ee/32.png) [@zerogy](https://www.ruby-forum.com/u/zerogy)\
**Post date:** [February 12, 2009, 10:34am UTC](https://www.ruby-forum.com/t/rspec-test-cannot-be-passed-when-render-partial-in-layout/160150/7 "2009-02-12T10:34:23Z")

</div>

i just do not know which method is called with 3 arguments instead of  
1, so i could not solve the problem.  
and i pasted the relevant code below:  
routes.rb:  
…  
map.resources :users, :member =\> { :suspend =\> :get, :unsuspend  
=\> :get }

users\_controller.rb:  
…

# render new.rhtml

def new  
@user = User.new  
end

users\_controller\_spec.rb:  
…  
describe “named routing” do  
before(:each) do  
get :new  
end  
it “should route new\_user\_path() to /users/new” do  
new\_user\_path().should == “/users/new”  
end  
end

new.html.erb:

# Sign up as a new user

\<% @user.password = @user.password\_confirmation = nil %\>

 \<% if flash[:error] %\> 
 \<%= flash[:error] %\> 
 \<% end %\> \<% form\_for :user, :url =\> users\_path, :html =\> {:class =\> 'bigform'} do |f| -%\> 

\<%= label\_tag 'login' %\> \<%= f.text\_field :login, :class=\>"text" %\>\<%= error\_message\_on "user", "login" %\>

```
  <div class="clearfix"><%= label_tag 'email' %>
  <%= f.text_field :email, :class=>"text" %>
  <%= error_message_on "user", "email" %></div>

  <div class="clearfix"><%= label_tag 'password' %>
  <%= f.password_field :password, :class=>"text" %>
  <%= error_message_on "user", "password" %></div>

  <div class="clearfix"><%= label_tag 'password_confirmation',

```

‘Confirm Password’ %\>  
\<%= f.password\_field :password\_confirmation, :class=\>“text” %\>  
\<%= error\_message\_on “user”, “password\_confirmation” %\>

  

  

\<%= submit\_tag ‘Sign up’ %\>
  
\<% end -%\> 

The error is:  
ActionView::TemplateError in ‘UsersController named routing should  
route new\_user\_path() to /users/new’  
wrong number of arguments (3 for 1)

PS: my rails version is 2.2, is there any more information needed?

---

<div class="post-metadata">

**Author:** ![zerogy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/z/67e7ee/32.png) [@zerogy](https://www.ruby-forum.com/u/zerogy)\
**Post date:** [February 12, 2009, 10:36am UTC](https://www.ruby-forum.com/t/rspec-test-cannot-be-passed-when-render-partial-in-layout/160150/8 "2009-02-12T10:36:09Z")

</div>

thank you very much and i am going to debug to find out the source  
problem
