rspec-rails-api 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitlab-ci.yml +2 -1
- data/CHANGELOG.md +11 -1
- data/README.md +4 -6
- data/lib/rspec/rails/api/dsl/example_group.rb +14 -8
- data/lib/rspec/rails/api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: df99a2088657641a87ec55c6159cdf7973d75863718f94aebef6cc70d7b4ac95
|
4
|
+
data.tar.gz: 4bf341e1fc70d6dfe760a531e43aec6c4c8002b3c1000fe83d1b2ae3cac3f3a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 42b42ba732de1383324dde829463f6a042289f184a959a9dc1c8ff727d8fd56699f7e97f40d215f184f724249517be826f5de4a66a5e684593a166ee25843624
|
7
|
+
data.tar.gz: 2daa6738912fcf4192e7c155a6744400420cabb5b1422de6dca77d34ece4dee59528d228b85af52fed0e5eaa17aebb4d14b06ca46e913a81c46318c8b11b67da
|
data/.gitlab-ci.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,16 @@ All notable changes to this project will be documented in this file.
|
|
3
3
|
|
4
4
|
## Not released
|
5
5
|
|
6
|
+
## 0.2.1/0.2.2 - 2019-11-03
|
7
|
+
|
8
|
+
_Version 0.2.1 was released and yanked by mistake. Version 0.2.2 is the exact
|
9
|
+
same one, with a version bump_
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
|
13
|
+
- `for_code` method now have its `description` optional. If none is provided,
|
14
|
+
the description will be set from the status code.
|
15
|
+
|
6
16
|
## 0.2.0 - 2019-11-02
|
7
17
|
|
8
18
|
### Added
|
@@ -40,7 +50,7 @@ of the fixtures.
|
|
40
50
|
### Added
|
41
51
|
|
42
52
|
- Added ability to document API descriptions, servers, etc... from the RSpec helper files
|
43
|
-
|
53
|
+
|
44
54
|
## 0.1.2 - 2019-10-22
|
45
55
|
|
46
56
|
### Added
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# RSpec-rails-api
|
2
2
|
|
3
|
-
> An RSpec plugin to test Rails
|
3
|
+
> An RSpec plugin to test Rails API responses and generate swagger
|
4
4
|
> documentation
|
5
5
|
|
6
6
|
**This is a work in progress** but you're welcome to help, test, submit
|
@@ -8,9 +8,6 @@ issues, ...
|
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
-
As the gem is not yet published, you have to specify its git repository
|
12
|
-
in order to test it.
|
13
|
-
|
14
11
|
Add this line to your application's Gemfile:
|
15
12
|
|
16
13
|
```ruby
|
@@ -381,7 +378,7 @@ on_post '/api/items' do
|
|
381
378
|
end
|
382
379
|
```
|
383
380
|
|
384
|
-
##### `for_code(http_status, description, doc_only: false &block)`
|
381
|
+
##### `for_code(http_status, description = nil, doc_only: false &block)`
|
385
382
|
|
386
383
|
Describes the desired output for a precedently defined URL.
|
387
384
|
|
@@ -392,7 +389,8 @@ the metadatas.
|
|
392
389
|
- `http_status` is an integer representing an
|
393
390
|
[HTTP status](https://httpstat.us/)
|
394
391
|
- `description` should be some valid
|
395
|
-
[CommonMark](https://commonmark.org/)
|
392
|
+
[CommonMark](https://commonmark.org/). If not defined, a human readable
|
393
|
+
translation of the `http_status` will be used.
|
396
394
|
- `doc_only` can be set to true to temporarily disable block execution
|
397
395
|
and only create the documentation (without examples).
|
398
396
|
- `block` where additional tests can be performed. If `visit()` is
|
@@ -74,17 +74,13 @@ module RSpec
|
|
74
74
|
describe("#{action.upcase} #{url}", &block)
|
75
75
|
end
|
76
76
|
|
77
|
-
def for_code(status_code, description, doc_only: false, &block)
|
77
|
+
def for_code(status_code, description = nil, doc_only: false, &block)
|
78
|
+
description ||= Rack::Utils::HTTP_STATUS_CODES[status_code]
|
79
|
+
|
78
80
|
metadata[:rrad].add_status_code(status_code, description)
|
79
81
|
|
80
82
|
describe "-> #{status_code} - #{description}" do
|
81
|
-
|
82
|
-
example 'Test and create documentation', caller: block.send(:caller) do
|
83
|
-
instance_eval(&block) if block_given?
|
84
|
-
end
|
85
|
-
else
|
86
|
-
document_only status_code
|
87
|
-
end
|
83
|
+
execute_for_code_block(status_code, doc_only, block)
|
88
84
|
end
|
89
85
|
end
|
90
86
|
|
@@ -98,6 +94,16 @@ module RSpec
|
|
98
94
|
set_request_example parent_example.metadata[:rrad], request_params, status_code
|
99
95
|
end
|
100
96
|
end
|
97
|
+
|
98
|
+
def execute_for_code_block(status_code, doc_only, callback_block)
|
99
|
+
if (!ENV['DOC_ONLY'] || ENV['DOC_ONLY'] == 'false' || !doc_only) && callback_block
|
100
|
+
example 'Test and create documentation', caller: callback_block.send(:caller) do
|
101
|
+
instance_eval(&callback_block) if callback_block
|
102
|
+
end
|
103
|
+
else
|
104
|
+
document_only status_code
|
105
|
+
end
|
106
|
+
end
|
101
107
|
end
|
102
108
|
end
|
103
109
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-rails-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manuel Tancoigne
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|