Permalink
Browse files

invoke / invoke_delegated / invoke_layered check for correct number o…

…f args (closes #4610) [jerrett@bravenet.com]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4173 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent a86e594 commit f2790d03905c275e8eff3927429bdb77f6c75d3a @dhh dhh committed Apr 6, 2006
View
1 actionwebservice/lib/action_web_service/test_invoke.rb
@@ -52,6 +52,7 @@ def encode_rpc_call(service_name, api_method_name, *args)
end
protocol.register_api(api)
method = api.api_methods[api_method_name.to_sym]
+ raise ArgumentError, "wrong number of arguments for rpc call (#{args.length} for #{method.expects.length})" unless args.length == method.expects.length
protocol.encode_request(public_method_name(service_name, api_method_name), args.dup, method.expects)
end
View
21 actionwebservice/test/test_invoke_test.rb
@@ -76,4 +76,25 @@ def test_layered_add
end
end
end
+
+ def test_layered_fail_with_wrong_number_of_arguments
+ [:soap, :xmlrpc].each do |protocol|
+ @protocol = protocol
+ [:one, :two].each do |service|
+ @controller = TestInvokeLayeredController.new
+ assert_raise(ArgumentError) { invoke_layered service, :add, 1 }
+ end
+ end
+ end
+
+ def test_delegated_fail_with_wrong_number_of_arguments
+ @controller = TestInvokeDelegatedController.new
+ assert_raise(ArgumentError) { invoke_delegated :service, :add, 1 }
+ end
+
+ def test_direct_fail_with_wrong_number_of_arguments
+ @controller = TestInvokeDirectController.new
+ assert_raise(ArgumentError) { invoke :add, 1 }
+ end
+
end

0 comments on commit f2790d0

Please sign in to comment.