1
1
require 'spec_helper'
2
+
2
3
describe "helpers" do
3
4
4
5
before ( :all ) do
@@ -14,32 +15,41 @@ class HelperTestAPI < Grape::API
14
15
15
16
end
16
17
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
29
46
end
30
47
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
43
53
end
44
54
45
55
end
0 commit comments