Skip to content

Commit

Permalink
Adapt spec to new DSL, nothing of implementation needed to be changed.
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-vandecasteele committed Jul 19, 2012
1 parent 86574eb commit 1145b78
Showing 1 changed file with 26 additions and 9 deletions.
35 changes: 26 additions & 9 deletions spec/grape/api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -923,31 +923,48 @@ def three
{ :description => "Reverses a string.", :params => { "s" => { :desc => "string to reverse", :type => "string" } } }
]
end
it "should merge the options of the namespace with the options of the method" do
subject.desc "namespace", :params => { :ns_param => "ns param" }
it "should merge the parameters of the namespace with the parameters of the method" do
subject.desc "namespace"
subject.params do
requires :ns_param, :desc => "namespace parameter"
end
subject.namespace "ns" do
desc "method", :params => { :method_param => "method param" }
desc "method"
params do
optional :method_param, :desc => "method parameter"
end
get "method" do ; end
end
subject.routes.map { |route|
{ :description => route.route_description, :params => route.route_params }
}.should eq [
{ :description => "method", :params => { :ns_param => "ns param", :method_param => "method param" } }
{ :description => "method", :params => { :ns_param => { :required => true, :desc => "namespace parameter" }, :method_param => { :required => false, :desc => "method parameter" } } }
]
end
it "should merge the options of nested namespaces" do
subject.desc "ns1", :params => { :ns_param => "ns param 1", :ns1_param => "ns1 param" }
it "should merge the parameters of nested namespaces" do
subject.desc "ns1"
subject.params do
optional :ns_param, :desc => "ns param 1"
requires :ns1_param, :desc => "ns1 param"
end
subject.namespace "ns1" do
desc "ns2", :params => { :ns_param => "ns param 2", :ns2_param => "ns2 param" }
desc "ns2"
params do
requires :ns_param, :desc => "ns param 2"
requires :ns2_param, :desc => "ns2 param"
end
namespace "ns2" do
desc "method", :params => { :method_param => "method param" }
desc "method"
params do
optional :method_param, :desc => "method param"
end
get "method" do ; end
end
end
subject.routes.map { |route|
{ :description => route.route_description, :params => route.route_params }
}.should eq [
{ :description => "method", :params => { :ns_param => "ns param 2", :ns1_param => "ns1 param", :ns2_param => "ns2 param", :method_param => "method param" } }
{ :description => "method", :params => { :ns_param => { :required => true, :desc => "ns param 2" }, :ns1_param => { :required => true, :desc => "ns1 param" }, :ns2_param => { :required => true, :desc => "ns2 param" }, :method_param => { :required => false, :desc => "method param" } } }
]
end
it "should not symbolize params" do
Expand Down

0 comments on commit 1145b78

Please sign in to comment.