where is wrong with contoller test?

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,   1) 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!

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

Your action method needs to be defined without arguments:

   def send_welcome_message       person = params[:person]       ...    end

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!

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

I’m not understanding what you’re saying very well, but I think the issue boils down to the fact that you can’t pass arguments to a controller method that way. You couldnt call " http://localhost:3000/controller/send_welcome_message(person)" from the URI box. You would post to "http://localhost:3000/controller/send_welcome_message " with :person parameters in the HTTP request.

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.

…*you’re doing things…

Stupid homophones.