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
cf36412a
Commit
cf36412a
authored
Sep 25, 2016
by
andrew morton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a test for capture_example
parent
27841825
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
6 deletions
+25
-6
helpers.rb
lib/rspec/swagger/helpers.rb
+1
-1
request_spec.rb
spec/requests/request_spec.rb
+3
-4
helpers_spec.rb
spec/rspec/swagger/helpers_spec.rb
+21
-1
No files found.
lib/rspec/swagger/helpers.rb
View file @
cf36412a
...
...
@@ -173,7 +173,7 @@ module RSpec
metadata
[
:swagger_operation
][
:produces
]
=
mime_types
end
def
response
status_code
,
attributes
=
{},
params
=
{},
&
block
def
response
status_code
,
attributes
=
{},
&
block
attributes
.
symbolize_keys!
validate_status_code!
status_code
...
...
spec/requests/request_spec.rb
View file @
cf36412a
...
...
@@ -12,7 +12,7 @@ RSpec.describe "Requestsing", type: :request do
operation
"GET"
,
summary
:"fetch list"
do
produces
'application/json'
response
(
200
,
{
description:
"successful"
}
,
{}
)
response
(
200
,
{
description:
"successful"
})
end
post
summary:
"create"
do
...
...
@@ -22,8 +22,7 @@ RSpec.describe "Requestsing", type: :request do
parameter
"body"
,
in: :body
,
schema:
{
foo: :bar
}
let
(
:body
)
{
{
post:
{
title:
'asdf'
,
body:
"blah"
}
}
}
# TODO: it should pull the body from the params
response
(
201
,
{
description:
"successfully created"
},
{
post:
{
title:
'asdf'
,
body:
"blah"
}
}.
to_json
)
do
response
(
201
,
{
description:
"successfully created"
})
do
it
"uses the body we passed in"
do
post
=
JSON
.
parse
(
response
.
body
)
expect
(
post
[
"title"
]).
to
eq
(
'asdf'
)
...
...
@@ -42,7 +41,7 @@ RSpec.describe "Requestsing", type: :request do
produces
'application/json'
before
{
Post
.
new
.
save
}
response
(
200
,
{
description:
"success"
}
,
{}
)
do
response
(
200
,
{
description:
"success"
})
do
capture_example
end
end
...
...
spec/rspec/swagger/helpers_spec.rb
View file @
cf36412a
...
...
@@ -186,7 +186,7 @@ RSpec.describe RSpec::Swagger::Helpers::Operation do
end
subject
{
klass
.
new
}
describe
"#response"
do
describe
'#response'
do
before
{
subject
.
metadata
=
{
swagger_object: :operation
}
}
it
"requires code be an integer 100...600 or :default"
do
...
...
@@ -206,3 +206,23 @@ RSpec.describe RSpec::Swagger::Helpers::Operation do
end
end
end
RSpec
.
describe
RSpec
::
Swagger
::
Helpers
::
Response
do
let
(
:klass
)
do
Class
.
new
do
include
RSpec
::
Swagger
::
Helpers
::
Response
attr_accessor
:metadata
def
describe
*
args
;
end
end
end
subject
{
klass
.
new
}
before
{
subject
.
metadata
=
{
swagger_object: :response
}
}
describe
'#capture_example'
do
it
"sets the capture metadata"
do
expect
{
subject
.
capture_example
}
.
to
change
{
subject
.
metadata
[
:capture_examples
]
}.
to
(
true
)
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