rspec-rails-api 0.1.4 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +35 -0
- data/README.md +66 -5
- data/examples/commented.rb +1 -1
- data/lib/rspec/rails/api/metadata.rb +1 -1
- data/lib/rspec/rails/api/open_api_renderer.rb +2 -0
- data/lib/rspec/rails/api/version.rb +1 -1
- data/rspec-rails-api.gemspec +6 -0
- metadata +21 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0c5ddec517d805e43305c00f7b7baa19373acb3d8fe55bca724e521e57cc8e3
|
4
|
+
data.tar.gz: 9f1ed792f16c075e140610902f8d7671d13d03483115066e55ca48c43b42f8d7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 501da0c03e7375b0097e95d951b1db831743564abd88dd4d28e719be5ee84701daaa9583160a0610dcd3cde35b143b8199b07e6bf684e0261fd26afca5b67d23
|
7
|
+
data.tar.gz: 5eaf88f5467cb5d5a12ca311e53778507534ff5090e85647581899bc5c4b7ab1f9914aea97f663bc7474faaede720fe66ff3d350ff0ba12982361b0772a00ae2
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# Change Log
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
## 0.1.5 - 2019-10-31
|
5
|
+
|
6
|
+
### Fixed
|
7
|
+
|
8
|
+
- Fixed issue with POST/PUT/DELETE requests with no `request_params`
|
9
|
+
- Improved documentation (integration with Devise, typos and mistakes)
|
10
|
+
|
11
|
+
## 0.1.4 - 2019-10-24
|
12
|
+
|
13
|
+
### Added
|
14
|
+
|
15
|
+
- Added support for arrays of objects in request parameters
|
16
|
+
|
17
|
+
## 0.1.3 - 2019-10-23
|
18
|
+
|
19
|
+
### Added
|
20
|
+
|
21
|
+
- Added ability to document API descriptions, servers, etc... from the RSpec helper files
|
22
|
+
|
23
|
+
## 0.1.2 - 2019-10-22
|
24
|
+
|
25
|
+
### Added
|
26
|
+
|
27
|
+
- Added `item` property for arrays descriptions
|
28
|
+
|
29
|
+
## 0.1.1 - 2019-10-22
|
30
|
+
|
31
|
+
- Added support for custom headers in request examples (useful for `visit` method)
|
32
|
+
|
33
|
+
## 0.1.0 - 2019-10-21
|
34
|
+
|
35
|
+
Initial release
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
#
|
1
|
+
# RSpecRailsApiDoc
|
2
2
|
|
3
3
|
> An RSpec plugin to test Rails api responses and generate swagger
|
4
4
|
> documentation
|
@@ -34,7 +34,7 @@ require 'rails_helper'
|
|
34
34
|
require 'rspec_rails_api'
|
35
35
|
|
36
36
|
RSpec.configure do |config|
|
37
|
-
config.include
|
37
|
+
config.include RSpec::Rails::Api::DSL::Example
|
38
38
|
end
|
39
39
|
|
40
40
|
renderer = RSpec::Rails::Api::OpenApiRenderer.new
|
@@ -52,7 +52,7 @@ end
|
|
52
52
|
|
53
53
|
RSpec.configuration.after(:suite) do
|
54
54
|
# Default path is 'tmp/rspec_rails_api_output.json/yaml'
|
55
|
-
renderer.write_files Rails.root.join('public', 'swagger_doc'), only: :json
|
55
|
+
renderer.write_files Rails.root.join('public', 'swagger_doc'), only: [:json]
|
56
56
|
end
|
57
57
|
```
|
58
58
|
|
@@ -71,7 +71,68 @@ end
|
|
71
71
|
|
72
72
|
## Configuration
|
73
73
|
|
74
|
-
TODO
|
74
|
+
**TODO: This section is incomplete and the gem has no generator yet**
|
75
|
+
|
76
|
+
### Integration with Devise
|
77
|
+
|
78
|
+
To use `sign_in` and `sign_out` from Devise in the acceptance tests, create a Devise support file:
|
79
|
+
|
80
|
+
```rb
|
81
|
+
# spec/support/devise.rb
|
82
|
+
module DeviseAcceptanceSpecHelpers
|
83
|
+
include Warden::Test::Helpers
|
84
|
+
|
85
|
+
def sign_in(resource_or_scope, resource = nil)
|
86
|
+
resource ||= resource_or_scope
|
87
|
+
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
88
|
+
login_as(resource, scope: scope)
|
89
|
+
end
|
90
|
+
|
91
|
+
def sign_out(resource_or_scope)
|
92
|
+
scope = Devise::Mapping.find_scope!(resource_or_scope)
|
93
|
+
logout(scope)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
```
|
97
|
+
|
98
|
+
Load this file in `rails_helper.rb`:
|
99
|
+
|
100
|
+
```rb
|
101
|
+
#...
|
102
|
+
# Add additional requires below this line. Rails is not loaded until this point!
|
103
|
+
require 'support/devise'
|
104
|
+
#...
|
105
|
+
```
|
106
|
+
|
107
|
+
Include the helper for acceptance specs:
|
108
|
+
|
109
|
+
```rb
|
110
|
+
RSpec.configure do |config|
|
111
|
+
config.include DeviseAcceptanceSpecHelpers, type: :acceptance
|
112
|
+
end
|
113
|
+
```
|
114
|
+
|
115
|
+
You can now use the methods as usual:
|
116
|
+
|
117
|
+
```rb
|
118
|
+
# In a before block
|
119
|
+
before do
|
120
|
+
sign_in #...
|
121
|
+
end
|
122
|
+
|
123
|
+
# In examples
|
124
|
+
#...
|
125
|
+
for_code 200, 'Success' do |example|
|
126
|
+
sing_in #...
|
127
|
+
visit example
|
128
|
+
|
129
|
+
#...
|
130
|
+
end
|
131
|
+
#...
|
132
|
+
```
|
133
|
+
|
134
|
+
This solution comes from [this article](https://makandracards.com/makandra/37161-rspec-devise-how-to-sign-in-users-in-request-specs)
|
135
|
+
by Arne Hartherz (MIT license).
|
75
136
|
|
76
137
|
## Usage
|
77
138
|
|
@@ -457,6 +518,6 @@ The gem is available as open source under the terms of the
|
|
457
518
|
|
458
519
|
## Code of Conduct
|
459
520
|
|
460
|
-
Everyone interacting in the
|
521
|
+
Everyone interacting in the RSpecRailsApiDoc project’s codebases, issue
|
461
522
|
trackers, chat rooms and mailing lists is expected to follow the
|
462
523
|
[code of conduct](https://gitlab.com/experimentslabs/rspec-rails-api/blob/master/CODE_OF_CONDUCT.md).
|
data/examples/commented.rb
CHANGED
@@ -18,7 +18,7 @@ RSpec.describe 'Categories', type: :acceptance do
|
|
18
18
|
url: { type: :string, description: 'URL to this category' }
|
19
19
|
|
20
20
|
entity :error,
|
21
|
-
error: { type: :string,
|
21
|
+
error: { type: :string, description: 'The error' }
|
22
22
|
|
23
23
|
entity :form_error,
|
24
24
|
errors: {
|
@@ -30,6 +30,8 @@ module RSpec
|
|
30
30
|
def merge_context(context)
|
31
31
|
@metadata[:resources].deep_merge! context[:resources]
|
32
32
|
@metadata[:entities].deep_merge! context[:entities]
|
33
|
+
# Save context to make the fixture (will be saved in the reference project)
|
34
|
+
# File.write ::Rails.root.join('tmp', 'meta.yaml'), context.to_yaml
|
33
35
|
end
|
34
36
|
|
35
37
|
def write_files(path = nil, only: %i[yaml json])
|
data/rspec-rails-api.gemspec
CHANGED
@@ -17,6 +17,11 @@ Gem::Specification.new do |spec|
|
|
17
17
|
TXT
|
18
18
|
spec.homepage = 'https://gitlab.com/experimentslabs/rspec-rails-api'
|
19
19
|
spec.license = 'MIT'
|
20
|
+
spec.metadata = {
|
21
|
+
'source_code_uri' => 'https://gitlab.com/experimentslabs/rspec-rails-api',
|
22
|
+
'bug_tracker_uri' => 'https://gitlab.com/experimentslabs/rspec-rails-api/issues',
|
23
|
+
'changelog_uri' => 'https://gitlab.com/experimentslabs/rspec-rails-api/blob/master/CHANGELOG.md',
|
24
|
+
}
|
20
25
|
|
21
26
|
# Specify which files should be added to the gem when it is released.
|
22
27
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -29,6 +34,7 @@ Gem::Specification.new do |spec|
|
|
29
34
|
|
30
35
|
spec.add_development_dependency 'activesupport', '>= 5.2'
|
31
36
|
spec.add_development_dependency 'bundler', '~> 1.17'
|
37
|
+
spec.add_development_dependency 'byebug'
|
32
38
|
spec.add_development_dependency 'rake', '~> 10.0'
|
33
39
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
34
40
|
spec.add_development_dependency 'rubocop'
|
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.1.
|
4
|
+
version: 0.1.5
|
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-10-
|
11
|
+
date: 2019-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '1.17'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: byebug
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rake
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +136,7 @@ files:
|
|
122
136
|
- ".rspec"
|
123
137
|
- ".rubocop.yml"
|
124
138
|
- ".travis.yml"
|
139
|
+
- CHANGELOG.md
|
125
140
|
- CODE_OF_CONDUCT.md
|
126
141
|
- Gemfile
|
127
142
|
- LICENSE.txt
|
@@ -144,7 +159,10 @@ files:
|
|
144
159
|
homepage: https://gitlab.com/experimentslabs/rspec-rails-api
|
145
160
|
licenses:
|
146
161
|
- MIT
|
147
|
-
metadata:
|
162
|
+
metadata:
|
163
|
+
source_code_uri: https://gitlab.com/experimentslabs/rspec-rails-api
|
164
|
+
bug_tracker_uri: https://gitlab.com/experimentslabs/rspec-rails-api/issues
|
165
|
+
changelog_uri: https://gitlab.com/experimentslabs/rspec-rails-api/blob/master/CHANGELOG.md
|
148
166
|
post_install_message:
|
149
167
|
rdoc_options: []
|
150
168
|
require_paths:
|