Hi, everybody!
I got a strange question when I did a controller test as below
On controller.rb:
def send_welcome_message(person)
some codes;
end
the controller_test.rb:
def test_send_welcome_message
post :send_welcome_message, :person=>{:id=>‘2’, :name=>‘somebody’}
assert_response :success
end
when I run this test, There always said,
Error:
test_send_welcome_message(TestControllerTest):
ArgumentError: wrong number of arguments (0 for 1)
I know there maybe params are set wrong,
but how can I fix it out? please help, Thanks!
Thank you, Bob!
I depended on your suggestion to do that, It’s OK…
Now, I want to know why if I use
def send_welcome_message(person)
this way, I can’t get it?
anyone can help me? Thanks!
On a relate note, I would expect a method called send_welcome_message to
be
a helper function that maybe set flash[:notice] and redirected. I
wouldn’t
expect it to be a controller method. Your issue may be that your doing
things in the wrong places and confusing yourself.
Hi, everybody.
I think that is a function like “def send_welcome_message(person)”,
and that is a model method like “def send_welcome_message”,
so when you defined “def send_welcome_message(person)”, you can call
it in your method, then you don’t need to test this function.
This idea is right or not? Could somebody tell me…