Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
rspec-rails-swagger
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open-source
rspec-rails-swagger
Commits
cdbca3a8
Commit
cdbca3a8
authored
Sep 22, 2016
by
andrew morton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use root consumes/produces if not specified in operation
parent
d2c108e3
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
7 deletions
+28
-7
helpers.rb
lib/rspec/swagger/helpers.rb
+4
-2
helpers_spec.rb
spec/rspec/swagger/helpers_spec.rb
+24
-5
No files found.
lib/rspec/swagger/helpers.rb
View file @
cdbca3a8
...
@@ -204,11 +204,13 @@ module RSpec
...
@@ -204,11 +204,13 @@ module RSpec
end
end
def
resolve_produces
metadata
def
resolve_produces
metadata
metadata
[
:swagger_operation
][
:produces
]
document
=
resolve_document
metadata
metadata
[
:swagger_operation
][
:produces
]
||
document
[
:produces
]
end
end
def
resolve_consumes
metadata
def
resolve_consumes
metadata
metadata
[
:swagger_operation
][
:consumes
]
document
=
resolve_document
metadata
metadata
[
:swagger_operation
][
:consumes
]
||
document
[
:consumes
]
end
end
def
resolve_headers
metadata
def
resolve_headers
metadata
...
...
spec/rspec/swagger/helpers_spec.rb
View file @
cdbca3a8
...
@@ -235,19 +235,38 @@ RSpec.describe RSpec::Swagger::Helpers::Resolver do
...
@@ -235,19 +235,38 @@ RSpec.describe RSpec::Swagger::Helpers::Resolver do
end
end
describe
"#resolve_headers"
,
:swagger_object
do
describe
"#resolve_headers"
,
:swagger_object
do
context
"with consumes set"
do
context
"with consumes/produces in the operation"
do
let
(
:metadata
)
{
{
swagger_operation:
{
consumes:
[
'application/json'
]}}
}
let
(
:metadata
)
do
{
swagger_operation:
{
consumes:
[
'application/json'
],
produces:
[
'application/xml'
]}}
end
before
do
allow
(
self
).
to
receive
(
:resolve_document
)
{
{}
}
end
it
"sets the Content-Type header"
do
it
"sets the Content-Type header"
do
expect
(
resolve_headers
(
metadata
)).
to
include
(
'CONTENT_TYPE'
=>
'application/json'
)
expect
(
resolve_headers
(
metadata
)).
to
include
(
'CONTENT_TYPE'
=>
'application/json'
)
end
end
it
"sets the Accepts header"
do
expect
(
resolve_headers
(
metadata
)).
to
include
(
'HTTP_ACCEPT'
=>
'application/xml'
)
end
end
end
context
"with produces set"
do
context
"with consumes/produces in the document"
do
let
(
:metadata
)
{
{
swagger_operation:
{
produces:
[
'application/xml'
]}}
}
let
(
:metadata
)
{
{
swagger_document:
'test.json'
,
swagger_operation:
{}}
}
before
do
allow
(
self
).
to
receive
(
:resolve_document
)
do
{
consumes:
[
'text/plain; charset=utf-8'
],
produces:
[
'application/vnd.github.v3.raw+json'
]}
end
end
it
"sets the Content-Type header"
do
expect
(
resolve_headers
(
metadata
)).
to
include
(
'CONTENT_TYPE'
=>
'text/plain; charset=utf-8'
)
end
it
"sets the Accepts header"
do
it
"sets the Accepts header"
do
expect
(
resolve_headers
(
metadata
)).
to
include
(
'HTTP_ACCEPT'
=>
'application/
xml
'
)
expect
(
resolve_headers
(
metadata
)).
to
include
(
'HTTP_ACCEPT'
=>
'application/
vnd.github.v3.raw+json
'
)
end
end
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment