@@ -31,6 +31,38 @@ Feature: Use OAuth2 MAC client as a test client
31
31
response.finish
32
32
end
33
33
34
+ run app
35
+ end
36
+
37
+ map "/multiple" do
38
+ app = lambda do |env|
39
+ if env["HTTP_AUTHORIZATION"].blank?
40
+ return [401, {"Content-Type" => "text/plain"}, [""]]
41
+ end
42
+
43
+ request = Rack::Request.new(env)
44
+ response = Rack::Response.new
45
+ response["Content-Type"] = "text/plain"
46
+ response.write("hello #{request.params["targets"].join(", ")}")
47
+ response.finish
48
+ end
49
+
50
+ run app
51
+ end
52
+
53
+ map "/multiple_nested" do
54
+ app = lambda do |env|
55
+ if env["HTTP_AUTHORIZATION"].blank?
56
+ return [401, {"Content-Type" => "text/plain"}, [""]]
57
+ end
58
+
59
+ request = Rack::Request.new(env)
60
+ response = Rack::Response.new
61
+ response["Content-Type"] = "text/plain"
62
+ response.write("hello #{request.params["targets"].map {|company, products| company.to_s + ' with ' + products.join(' and ')}.join(", ")}")
63
+ response.finish
64
+ end
65
+
34
66
run app
35
67
end
36
68
end
@@ -50,6 +82,35 @@ Feature: Use OAuth2 MAC client as a test client
50
82
response_body.should eq('hello rspec_api_documentation')
51
83
end
52
84
end
85
+
86
+ get "/multiple" do
87
+ parameter :targets, "The people you want to greet"
88
+
89
+ let(:targets) { ["eric", "sam"] }
90
+
91
+ example "Greeting your favorite people" do
92
+ do_request
93
+
94
+ response_headers["Content-Type"].should eq("text/plain")
95
+ status.should eq(200)
96
+ response_body.should eq("hello eric, sam")
97
+ end
98
+ end
99
+
100
+ get "/multiple_nested" do
101
+ parameter :targets, "The companies you want to greet"
102
+
103
+ let(:targets) { { "apple" => ['mac', 'ios'], "google" => ['search', 'mail']} }
104
+
105
+ example "Greeting your favorite companies" do
106
+ do_request
107
+
108
+ response_headers["Content-Type"].should eq("text/plain")
109
+ status.should eq(200)
110
+ response_body.should eq("hello apple with mac and ios, google with search and mail")
111
+ end
112
+ end
113
+
53
114
end
54
115
"""
55
116
When I run `rspec app_spec.rb --format RspecApiDocumentation::ApiFormatter`
@@ -61,6 +122,10 @@ Feature: Use OAuth2 MAC client as a test client
61
122
Greetings
62
123
GET /
63
124
* Greeting your favorite gem
125
+ GET /multiple
126
+ * Greeting your favorite people
127
+ GET /multiple_nested
128
+ * Greeting your favorite companies
64
129
"""
65
- And the output should contain "1 example , 0 failures"
130
+ And the output should contain "3 examples , 0 failures"
66
131
And the exit status should be 0
0 commit comments