@@ -8,7 +8,10 @@ Feature: Generate HTML documentation from test examples
8
8
request = Rack::Request.new(env)
9
9
response = Rack::Response.new
10
10
response["Content-Type"] = "application/json"
11
- response.write({ "hello" => request.params["target"] }.to_json)
11
+ response.write({
12
+ "hello" => request.params["target"],
13
+ "more_greetings" => { "bonjour" => { "message" => "le monde" } }
14
+ }.to_json)
12
15
response.finish
13
16
end
14
17
end
@@ -31,14 +34,15 @@ Feature: Generate HTML documentation from test examples
31
34
parameter :scoped, "This is a scoped variable", :scope => :scope
32
35
parameter :sub, "This is scoped", :scope => [:scope, :further]
33
36
34
- response_field :hello, "The greeted thing"
37
+ response_field :hello, "The greeted thing"
38
+ response_field :message, "Translated greeting", scope: [:more_greetings, :bonjour]
35
39
36
40
example "Greeting your favorite gem" do
37
41
do_request :target => "rspec_api_documentation"
38
42
39
43
expect(response_headers["Content-Type"]).to eq("application/json")
40
44
expect(status).to eq(200)
41
- expect(response_body).to eq('{"hello":"rspec_api_documentation"}')
45
+ expect(response_body).to eq('{"hello":"rspec_api_documentation","more_greetings":{"bonjour":{"message":"le monde"}} }')
42
46
end
43
47
end
44
48
end
@@ -71,12 +75,13 @@ Feature: Generate HTML documentation from test examples
71
75
| scope [scoped ] | This is a scoped variable |
72
76
| scope [further ][sub ] | This is scoped |
73
77
74
- Scenario : Examle HTML documentation should include the response fields
78
+ Scenario : Example HTML documentation should include the response fields
75
79
When I open the index
76
80
And I navigate to "Greeting your favorite gem"
77
81
Then I should see the following response fields:
78
- | name | description |
79
- | hello | The greeted thing |
82
+ | name | description |
83
+ | hello | The greeted thing |
84
+ | more_greetings [bonjour ][message ] | Translated greeting |
80
85
81
86
Scenario : Example HTML documentation includes the request information
82
87
When I open the index
@@ -99,5 +104,5 @@ Feature: Generate HTML documentation from test examples
99
104
| Content -Length | 35 |
100
105
And I should see the following response body:
101
106
"""
102
- { "hello": "rspec_api_documentation" }
107
+ { "hello": "rspec_api_documentation", "more_greetings": { "bonjour": { "message": "le monde" } } }
103
108
"""
0 commit comments