@@ -8,7 +8,10 @@ Feature: Generate HTML documentation from test examples
88 request = Rack::Request.new(env)
99 response = Rack::Response.new
1010 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)
1215 response.finish
1316 end
1417 end
@@ -31,14 +34,15 @@ Feature: Generate HTML documentation from test examples
3134 parameter :scoped, "This is a scoped variable", :scope => :scope
3235 parameter :sub, "This is scoped", :scope => [:scope, :further]
3336
34- response_field :hello, "The greeted thing"
37+ response_field :hello, "The greeted thing"
38+ response_field :message, "Translated greeting", scope: [:more_greetings, :bonjour]
3539
3640 example "Greeting your favorite gem" do
3741 do_request :target => "rspec_api_documentation"
3842
3943 expect(response_headers["Content-Type"]).to eq("application/json")
4044 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"}} }')
4246 end
4347 end
4448 end
@@ -71,12 +75,13 @@ Feature: Generate HTML documentation from test examples
7175 | scope [scoped ] | This is a scoped variable |
7276 | scope [further ][sub ] | This is scoped |
7377
74- Scenario : Examle HTML documentation should include the response fields
78+ Scenario : Example HTML documentation should include the response fields
7579 When I open the index
7680 And I navigate to "Greeting your favorite gem"
7781 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 |
8085
8186 Scenario : Example HTML documentation includes the request information
8287 When I open the index
@@ -99,5 +104,5 @@ Feature: Generate HTML documentation from test examples
99104 | Content -Length | 35 |
100105 And I should see the following response body:
101106 """
102- { "hello": "rspec_api_documentation" }
107+ { "hello": "rspec_api_documentation", "more_greetings": { "bonjour": { "message": "le monde" } } }
103108 """
0 commit comments