@@ -747,7 +747,7 @@ class TwitterAPI < Grape::API
747747 end
748748 describe "api structure with additional parameters" do
749749 before ( :each ) do
750- subject . get 'split/:string' , { :params => [ "token" ] , :optional_params => [ "limit" ] } do
750+ subject . get 'split/:string' , { :params => { "token" => "a token" } , :optional_params => { "limit" => "the limit" } } do
751751 params [ :string ] . split ( params [ :token ] , ( params [ :limit ] || 0 ) . to_i )
752752 end
753753 end
@@ -761,8 +761,8 @@ class TwitterAPI < Grape::API
761761 end
762762 it "should set route_params" do
763763 subject . routes . size . should == 1
764- subject . routes [ 0 ] . route_params . should == [ "string" , "token" ]
765- subject . routes [ 0 ] . route_optional_params . should == [ "limit" ]
764+ subject . routes [ 0 ] . route_params . should == { "string" => "" , "token" => "a token" }
765+ subject . routes [ 0 ] . route_optional_params . should == { "limit" => "the limit" }
766766 end
767767 end
768768 end
@@ -785,6 +785,17 @@ class TwitterAPI < Grape::API
785785 subject . routes [ 0 ] . route_description . should == "ping method"
786786 end
787787 end
788+ describe "single method with a an array of params and a desc hash block" do
789+ before ( :each ) do
790+ subject . desc "ping method" , { :params => { "x" => "y" } }
791+ subject . get "ping/:x" do
792+ 'pong'
793+ end
794+ end
795+ it "returns route description" do
796+ subject . routes [ 0 ] . route_description . should == "ping method"
797+ end
798+ end
788799 describe "api structure with multiple methods and descriptions" do
789800 before ( :each ) do
790801 class JitterAPI < Grape ::API
@@ -813,9 +824,9 @@ class LitterAPI < Grape::API
813824 end
814825 desc "third method" , :details => "details of third method"
815826 get "third" do ; end
816- desc "Reverses a string." , { :params => [
827+ desc "Reverses a string." , { :params =>
817828 { "s" => { :desc => "string to reverse" , :type => "string" } }
818- ] }
829+ }
819830 get "reverse" do
820831 params [ :s ] . reverse
821832 end
@@ -828,7 +839,7 @@ class LitterAPI < Grape::API
828839 LitterAPI ::routes [ 2 ] . route_foo . should == "bar"
829840 LitterAPI ::routes [ 3 ] . route_description . should == "third method"
830841 LitterAPI ::routes [ 4 ] . route_description . should == "Reverses a string."
831- LitterAPI ::routes [ 4 ] . route_params . should == [ { "s" => { :desc => "string to reverse" , :type => "string" } } ]
842+ LitterAPI ::routes [ 4 ] . route_params . should == { "s" => { :desc => "string to reverse" , :type => "string" } }
832843 end
833844 end
834845 end
0 commit comments