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
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?
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?
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
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?
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.
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:
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
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?