提交 9b42cd8c 编写于 作者: L Leon Breedt

add API::Method#expects_to_hash convenience as well


git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1092 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 7a5bac1d
......@@ -192,6 +192,15 @@ def expects_index_of(param_name)
-1
end
# Returns a hash keyed by parameter name for the given
# parameter list
def expects_to_hash(params)
return {} if @expects.nil?
h = {}
@expects.zip(params){ |type, param| h[type.name] = param }
h
end
# String representation of this method
def to_s
fqn = ""
......
......@@ -85,6 +85,12 @@ def test_parameter_names
assert_equal -1, API.api_methods[:void].expects_index_of('test')
end
def test_parameter_hash
method = API.api_methods[:named_signature]
hash = method.expects_to_hash([5, false])
assert_equal({:appkey => 5, :publish => false}, hash)
end
def test_to_s
assert_equal 'void Expects(int param0, bool param1)', APITest::API.api_methods[:expects].to_s
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册