Skip to content

Commit f08e6b9

Browse files
idyllTim Vandecasteele
authored andcommitted
added a spec for the path parsing
1 parent 019e922 commit f08e6b9

File tree

1 file changed

+34
-24
lines changed

1 file changed

+34
-24
lines changed

spec/grape-swagger-helper_spec.rb

Lines changed: 34 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'spec_helper'
2+
23
describe "helpers" do
34

45
before(:all) do
@@ -14,32 +15,41 @@ class HelperTestAPI < Grape::API
1415

1516
end
1617

17-
it "should parse params as query strings for a GET" do
18-
params = {
19-
name: {type: 'String', :desc =>"A name", required: true },
20-
level: 'max'
21-
}
22-
path = "/coolness"
23-
method = "GET"
24-
@api.parse_params(params, path, method).should ==
25-
[
26-
{paramType: "query", name: :name, description:"A name", dataType: "String", required: true},
27-
{paramType: "query", name: :level, description:"", dataType: "String", required: false}
28-
]
18+
context "parsing parameters" do
19+
it "should parse params as query strings for a GET" do
20+
params = {
21+
name: {type: 'String', :@api => "A name", required: true },
22+
level: 'max'
23+
}
24+
path = "/coolness"
25+
method = "GET"
26+
@api.parse_params(params, path, method).should ==
27+
[
28+
{paramType: "query", name: :name, description:"A name", dataType: "String", required: true},
29+
{paramType: "query", name: :level, description:"", dataType: "String", required: false}
30+
]
31+
end
32+
33+
it "should parse params as body for a POST" do
34+
params = {
35+
name: {type: 'String', :@api =>"A name", required: true },
36+
level: 'max'
37+
}
38+
path = "/coolness"
39+
method = "POST"
40+
@api.parse_params(params, path, method).should ==
41+
[
42+
{paramType: "body", name: :name, description:"A name", dataType: "String", required: true},
43+
{paramType: "body", name: :level, description:"", dataType: "String", required: false}
44+
]
45+
end
2946
end
3047

31-
it "should parse params as body for a POST" do
32-
params = {
33-
name: {type: 'String', :desc =>"A name", required: true },
34-
level: 'max'
35-
}
36-
path = "/coolness"
37-
method = "POST"
38-
@api.parse_params(params, path, method).should ==
39-
[
40-
{paramType: "body", name: :name, description:"A name", dataType: "String", required: true},
41-
{paramType: "body", name: :level, description:"", dataType: "String", required: false}
42-
]
48+
context "parsing the path" do
49+
it "should parse the path" do
50+
path = ":abc/def(.:format)"
51+
@api.parse_path(path).should == "{abc}/def.{format}"
52+
end
4353
end
4454

4555
end

0 commit comments

Comments
 (0)