Skip to content

Commit d9b9c80

Browse files
committed
Added tests and documented app_name.
1 parent 062919d commit d9b9c80

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,19 @@ Add this line to `./config/routes.rb`:
2828
mount GrapeSwaggerRails::Engine => '/swagger'
2929
```
3030

31-
Create an initializer (e.g. `./config/initializers/swagger.rb`) and specify the URL to your Swagger API schema:
31+
Create an initializer (e.g. `./config/initializers/swagger.rb`) and specify the URL to your Swagger API schema and app:
3232

3333
```ruby
3434
GrapeSwaggerRails.options.url = '/swagger_doc.json'
35-
GrapeSwaggerRails.options.app_name = 'Swagger'
3635
GrapeSwaggerRails.options.app_url = 'http://swagger.wordnik.com'
3736
```
3837

38+
You can set the app name, default is "Swagger".
39+
40+
``` ruby
41+
GrapeSwaggerRails.options.app_name = 'Swagger'
42+
```
43+
3944
You can specify additional headers to add to each request:
4045

4146
```ruby

spec/features/swagger_spec.rb

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
it 'adds an Authorization header' do
4040
fill_in 'apiKey', with: 'username:password'
4141
find('#endpointListTogger_headers', visible: true).click
42-
find('a[href="#!/headers/GET_api_headers_format"]', visible: true).click
42+
first('a[href="#!/headers/GET_api_headers_format"]', visible: true).click
4343
click_button 'Try it out!'
4444
expect(page).to have_css "span.attribute", text: 'Authorization'
4545
expect(page).to have_css "span.string", text: "Basic #{Base64.encode64('username:password').strip}"
@@ -55,7 +55,7 @@
5555
it 'adds an Authorization header' do
5656
fill_in 'apiKey', with: 'token'
5757
find('#endpointListTogger_headers', visible: true).click
58-
find('a[href="#!/headers/GET_api_headers_format"]', visible: true).click
58+
first('a[href="#!/headers/GET_api_headers_format"]', visible: true).click
5959
click_button 'Try it out!'
6060
expect(page).to have_css "span.attribute", text: 'Authorization'
6161
expect(page).to have_css "span.string", text: 'Bearer token'
@@ -70,7 +70,7 @@
7070
it 'adds an api_token query parameter' do
7171
fill_in 'apiKey', with: 'dummy'
7272
find('#endpointListTogger_params', visible: true).click
73-
find('a[href="#!/params/GET_api_params_format"]', visible: true).click
73+
first('a[href="#!/params/GET_api_params_format"]', visible: true).click
7474
click_button 'Try it out!'
7575
expect(page).to have_css "span.attribute", text: 'api_token'
7676
expect(page).to have_css "span.string", text: "dummy"
@@ -90,6 +90,25 @@
9090
expect(page).to have_content "Unauthorized Access"
9191
end
9292
end
93+
context "#app_name" do
94+
context 'set' do
95+
before do
96+
GrapeSwaggerRails.options.app_name = "Test App"
97+
visit '/swagger'
98+
end
99+
it 'sets page title' do
100+
expect(page.title).to eq "Test App"
101+
end
102+
end
103+
context 'not set' do
104+
before do
105+
visit '/swagger'
106+
end
107+
it 'defaults page title' do
108+
expect(page.title).to eq "Swagger"
109+
end
110+
end
111+
end
93112
after do
94113
GrapeSwaggerRails.options = @options
95114
end

0 commit comments

Comments
 (0)