mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
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
This commit is contained in:
parent
7a5bac1de0
commit
9b42cd8cc1
2 changed files with 15 additions and 0 deletions
|
@ -192,6 +192,15 @@ module ActionWebService # :nodoc:
|
|||
-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 @@ class TC_API < Test::Unit::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue