rspec-request_describer 0.2.2 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/workflows/test.yml +17 -0
- data/.gitignore +3 -6
- data/.rspec +1 -0
- data/.rubocop.yml +14 -0
- data/CHANGELOG.md +99 -29
- data/Gemfile +4 -0
- data/Gemfile.lock +52 -0
- data/README.md +86 -42
- data/Rakefile +1 -2
- data/lib/rspec/request_describer/version.rb +1 -1
- data/lib/rspec/request_describer.rb +15 -11
- data/rspec-request_describer.gemspec +8 -13
- data/spec/rspec/request_describer_spec.rb +141 -0
- data/spec/spec_helper.rb +21 -0
- metadata +14 -49
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f663222473fe59484bc2e7b66a12a0f00edbd594fe8c7213b25e65c09e301b5e
|
4
|
+
data.tar.gz: ff27bc035f85f243c1fbd9724f215329b700cabb963e99a23d3a795226c5d868
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4f0580c22c26f5c1d3ce15f7f14d7e24fba46bfb7b471b5d84c7d634965f5d981e467740e1484e6bfc5a081176439e0e608fcd151de317c673c8870e9d7c535
|
7
|
+
data.tar.gz: 219b07cde7c240ba1a2b42cb5ba433c7fec176f5bc32397ca09389dd774a3b214539f5e35d03410b0a9bdeb902fe339c2513aa2a7696fc46f8b14bd103a43db9
|
@@ -0,0 +1,17 @@
|
|
1
|
+
name: test
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
rspec:
|
11
|
+
uses: r7kamura/workflows/.github/workflows/ruby-rspec.yml@main
|
12
|
+
with:
|
13
|
+
ruby-version: 2.7.4
|
14
|
+
rubocop:
|
15
|
+
uses: r7kamura/workflows/.github/workflows/ruby-rubocop.yml@main
|
16
|
+
with:
|
17
|
+
ruby-version: 2.7.4
|
data/.gitignore
CHANGED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--require spec_helper
|
data/.rubocop.yml
ADDED
data/CHANGELOG.md
CHANGED
@@ -1,45 +1,115 @@
|
|
1
|
-
|
1
|
+
# Changelog
|
2
2
|
|
3
|
-
|
3
|
+
## Unreleased
|
4
4
|
|
5
|
-
## 0.
|
5
|
+
## 0.4.0 - 2023-07-10
|
6
6
|
|
7
|
-
|
7
|
+
### Added
|
8
8
|
|
9
|
-
|
9
|
+
- Support HEAD HTTP method.
|
10
10
|
|
11
|
-
|
12
|
-
- Dependent on actionpack
|
11
|
+
## 0.3.2 - 2020-02-15
|
13
12
|
|
14
|
-
|
15
|
-
- Prevent warning for Rails 5 (Thx @mrkn, #9)
|
13
|
+
### Removed
|
16
14
|
|
17
|
-
|
18
|
-
- Rename `method` with `http_method` (Thx @yujinakayama, #8)
|
15
|
+
- Remove runtime gem dependency on actionpack.
|
19
16
|
|
20
|
-
## 0.
|
21
|
-
- Ignore case-sensivity on Content-Type checking
|
17
|
+
## 0.3.1 - 2019-05-08
|
22
18
|
|
23
|
-
|
24
|
-
- Use more sophisticated method capture pattern
|
19
|
+
### Fixed
|
25
20
|
|
26
|
-
|
27
|
-
- Add `send_request` to explicitly call `subject` (Thx @lazywei)
|
21
|
+
- Fix env calculation timing.
|
28
22
|
|
29
|
-
## 0.0
|
30
|
-
- Allow any non-space characters in URL path
|
23
|
+
## 0.3.0 - 2019-05-05
|
31
24
|
|
32
|
-
|
33
|
-
- Allow hyphen in path
|
25
|
+
### Added
|
34
26
|
|
35
|
-
|
36
|
-
- Define HTTPS as reserved header name
|
27
|
+
- Support symbol keys in request headers.
|
37
28
|
|
38
|
-
## 0.
|
39
|
-
- Remove dependency on ActiveSupport's `Object#in?`
|
29
|
+
## 0.2.2 - 2018-05-13
|
40
30
|
|
41
|
-
|
42
|
-
- Support RSpec 3
|
31
|
+
### Fixed
|
43
32
|
|
44
|
-
|
45
|
-
|
33
|
+
- Fix bug: Ignore case-sensitivity of HTTP headers.
|
34
|
+
|
35
|
+
## 0.2.1 - 2017-02-27
|
36
|
+
|
37
|
+
### Fixed
|
38
|
+
|
39
|
+
- Fix error from `#process`.
|
40
|
+
|
41
|
+
## 0.2.0 - 2017-02-27
|
42
|
+
|
43
|
+
### Added
|
44
|
+
|
45
|
+
- Support actionpack 5.1.0.
|
46
|
+
|
47
|
+
### Changed
|
48
|
+
|
49
|
+
- Declare runtime dependency on actionpack.
|
50
|
+
|
51
|
+
## 0.1.1 - 2016-05-15
|
52
|
+
|
53
|
+
### Fixed
|
54
|
+
|
55
|
+
- Prevent warning for Rails 5.
|
56
|
+
|
57
|
+
## 0.1.0 - 2015-10-09
|
58
|
+
|
59
|
+
### Changed
|
60
|
+
|
61
|
+
- Rename `method` with `http_method`.
|
62
|
+
|
63
|
+
## 0.0.9 - 2015-06-24
|
64
|
+
|
65
|
+
### Changed
|
66
|
+
|
67
|
+
- Ignore case-sensivity on Content-Type checking.
|
68
|
+
|
69
|
+
## 0.0.8 - 2015-05-20
|
70
|
+
|
71
|
+
### Changed
|
72
|
+
|
73
|
+
- Use more sophisticated method capture pattern.
|
74
|
+
|
75
|
+
## 0.0.7 - 2015-04-20
|
76
|
+
|
77
|
+
### Added
|
78
|
+
|
79
|
+
- Add `send_request` to explicitly call `subject`.
|
80
|
+
|
81
|
+
## 0.0.6 - 2015-02-12
|
82
|
+
|
83
|
+
### Fixed
|
84
|
+
|
85
|
+
- Allow any non-space characters in URL path.
|
86
|
+
|
87
|
+
## 0.0.5 - 2014-12-25
|
88
|
+
|
89
|
+
### Fixed
|
90
|
+
|
91
|
+
- Allow hyphen in path.
|
92
|
+
|
93
|
+
## 0.0.4 - 2014-12-18
|
94
|
+
|
95
|
+
### Added
|
96
|
+
|
97
|
+
- Define HTTPS as reserved header name.
|
98
|
+
|
99
|
+
## 0.0.3 - 2014-10-13
|
100
|
+
|
101
|
+
### Removed
|
102
|
+
|
103
|
+
- Remove dependency on ActiveSupport's `Object#in?`.
|
104
|
+
|
105
|
+
## 0.0.2 - 2014-09-25
|
106
|
+
|
107
|
+
### Added
|
108
|
+
|
109
|
+
- Support RSpec 3.
|
110
|
+
|
111
|
+
## 0.0.1 - 2014-08-29
|
112
|
+
|
113
|
+
### Added
|
114
|
+
|
115
|
+
- 1st Release.
|
data/Gemfile
CHANGED
data/Gemfile.lock
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
rspec-request_describer (0.4.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
ast (2.4.0)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
jaro_winkler (1.5.1)
|
12
|
+
parallel (1.12.1)
|
13
|
+
parser (2.5.3.0)
|
14
|
+
ast (~> 2.4.0)
|
15
|
+
powerpack (0.1.2)
|
16
|
+
rainbow (3.0.0)
|
17
|
+
rake (13.0.1)
|
18
|
+
rspec (3.8.0)
|
19
|
+
rspec-core (~> 3.8.0)
|
20
|
+
rspec-expectations (~> 3.8.0)
|
21
|
+
rspec-mocks (~> 3.8.0)
|
22
|
+
rspec-core (3.8.0)
|
23
|
+
rspec-support (~> 3.8.0)
|
24
|
+
rspec-expectations (3.8.2)
|
25
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
26
|
+
rspec-support (~> 3.8.0)
|
27
|
+
rspec-mocks (3.8.0)
|
28
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
+
rspec-support (~> 3.8.0)
|
30
|
+
rspec-support (3.8.0)
|
31
|
+
rubocop (0.61.1)
|
32
|
+
jaro_winkler (~> 1.5.1)
|
33
|
+
parallel (~> 1.10)
|
34
|
+
parser (>= 2.5, != 2.5.1.1)
|
35
|
+
powerpack (~> 0.1)
|
36
|
+
rainbow (>= 2.2.2, < 4.0)
|
37
|
+
ruby-progressbar (~> 1.7)
|
38
|
+
unicode-display_width (~> 1.4.0)
|
39
|
+
ruby-progressbar (1.10.0)
|
40
|
+
unicode-display_width (1.4.0)
|
41
|
+
|
42
|
+
PLATFORMS
|
43
|
+
ruby
|
44
|
+
|
45
|
+
DEPENDENCIES
|
46
|
+
rake
|
47
|
+
rspec
|
48
|
+
rspec-request_describer!
|
49
|
+
rubocop
|
50
|
+
|
51
|
+
BUNDLED WITH
|
52
|
+
2.2.29
|
data/README.md
CHANGED
@@ -1,88 +1,132 @@
|
|
1
1
|
# RSpec::RequestDescriber
|
2
|
-
|
2
|
+
|
3
|
+
[![test](https://github.com/r7kamura/rspec-request_describer/actions/workflows/test.yml/badge.svg)](https://github.com/r7kamura/rspec-request_describer/actions/workflows/test.yml)
|
4
|
+
[![Gem Version](https://badge.fury.io/rb/rspec-request_describer.svg)](https://rubygems.org/gems/rspec-request_describer)
|
5
|
+
|
6
|
+
An RSpec plugin to write self-documenting request-specs.
|
7
|
+
|
8
|
+
This gem is designed for:
|
9
|
+
|
10
|
+
- [rack-test](https://github.com/rack-test/rack-test)
|
11
|
+
- [rspec-rails](https://github.com/rspec/rspec-rails)
|
3
12
|
|
4
13
|
## Setup
|
5
|
-
|
14
|
+
|
15
|
+
### Install
|
16
|
+
|
17
|
+
Add this line to your application's Gemfile:
|
6
18
|
|
7
19
|
```ruby
|
8
|
-
|
9
|
-
|
20
|
+
gem 'rspec-request_describer'
|
21
|
+
```
|
10
22
|
|
11
|
-
|
12
|
-
|
13
|
-
|
23
|
+
And then execute:
|
24
|
+
|
25
|
+
```
|
26
|
+
bundle
|
14
27
|
```
|
15
28
|
|
16
|
-
|
29
|
+
Or install it yourself as:
|
30
|
+
|
31
|
+
```
|
32
|
+
gem install rspec-request_describer
|
33
|
+
```
|
34
|
+
|
35
|
+
### Include
|
36
|
+
|
37
|
+
Include `RSpec::RequestDescriber` to your example groups like this:
|
17
38
|
|
18
39
|
```ruby
|
19
|
-
|
20
|
-
|
40
|
+
require 'rspec/request_describer'
|
41
|
+
|
42
|
+
RSpec.configure do |config|
|
43
|
+
config.include RSpec::RequestDescriber, type: :request
|
44
|
+
end
|
21
45
|
```
|
22
46
|
|
23
47
|
## Usage
|
24
|
-
|
48
|
+
|
49
|
+
Note that this is an example in a Rails app.
|
25
50
|
|
26
51
|
### subject
|
27
|
-
|
28
|
-
|
52
|
+
|
53
|
+
`RSpec::RequestDescriber` provides `subject` from its top-level description.
|
29
54
|
|
30
55
|
```ruby
|
31
|
-
|
32
|
-
|
56
|
+
# subject will be `get('/users')`.
|
57
|
+
RSpec.describe 'GET /users' do
|
58
|
+
it 'returns 200' do
|
59
|
+
subject
|
60
|
+
expect(response).to have_http_status(200)
|
61
|
+
end
|
33
62
|
end
|
34
63
|
```
|
35
64
|
|
36
65
|
### headers
|
37
|
-
`headers` is provided to modify request headers.
|
38
|
-
In the below example, a token is added into Authorization request header.
|
39
66
|
|
67
|
+
If you want to modify request headers, change `headers` before calling `subject`.
|
40
68
|
|
41
69
|
```ruby
|
42
|
-
|
43
|
-
|
70
|
+
# `subject` will be `get('/users', headers: { 'Authorization' => 'token 12345' })`.
|
71
|
+
RSpec.describe 'GET /users' do
|
72
|
+
context 'with Authorization header' do
|
44
73
|
before do
|
45
|
-
headers[
|
74
|
+
headers['Authorization'] = 'token 12345'
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'returns 200' do
|
78
|
+
subject
|
79
|
+
expect(response).to have_http_status(200)
|
46
80
|
end
|
47
|
-
it { should == 200 }
|
48
81
|
end
|
49
82
|
end
|
50
83
|
```
|
51
84
|
|
52
85
|
### params
|
53
|
-
|
54
|
-
|
55
|
-
For GET request `params` is converted into URL query string,
|
56
|
-
while it's converted into request body for the other methods
|
57
|
-
.
|
58
|
-
Note that if you specified `application/json` Content-Type request header,
|
59
|
-
`params` would be encoded into JSON format.
|
86
|
+
|
87
|
+
If you want to modify request parameters, change `params` before calling `subject`.
|
60
88
|
|
61
89
|
```ruby
|
62
|
-
|
63
|
-
|
90
|
+
# `subject` will be `get('/users', params: { 'sort' => 'id' })`.
|
91
|
+
RSpec.describe 'GET /users' do
|
92
|
+
context 'with sort parameter' do
|
64
93
|
before do
|
65
|
-
params[
|
94
|
+
params['sort'] = 'id'
|
66
95
|
end
|
67
96
|
|
68
|
-
it
|
69
|
-
|
70
|
-
|
71
|
-
|
97
|
+
it 'returns 200 with expected JSON body' do
|
98
|
+
subject
|
99
|
+
expect(response).to have_http_status(200)
|
100
|
+
expect(response.parsed_body).to match(
|
101
|
+
[
|
102
|
+
hash_including('id' => 1),
|
103
|
+
hash_including('id' => 2),
|
104
|
+
]
|
105
|
+
)
|
72
106
|
end
|
73
107
|
end
|
74
108
|
end
|
75
109
|
```
|
76
110
|
|
77
|
-
###
|
78
|
-
|
79
|
-
|
111
|
+
### path parameters
|
112
|
+
|
113
|
+
You can embed variables in URL path like `/users/:user_id`.
|
114
|
+
In this example, the returned value of `user_id` method will be emobeded as its real value.
|
80
115
|
|
81
116
|
```ruby
|
82
|
-
|
83
|
-
|
84
|
-
|
117
|
+
# `subject` will be `get("/users/#{user_id}")`.
|
118
|
+
RSpec.describe 'GET /users/:user_id' do
|
119
|
+
let(:user) do
|
120
|
+
User.create(name: 'alice')
|
121
|
+
end
|
122
|
+
|
123
|
+
let(:user_id) do
|
124
|
+
user.id
|
125
|
+
end
|
126
|
+
|
127
|
+
it 'returns 200' do
|
128
|
+
subject
|
129
|
+
expect(response).to have_http_status(200)
|
85
130
|
end
|
86
|
-
it { should == 200 }
|
87
131
|
end
|
88
132
|
```
|
data/Rakefile
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
require
|
2
|
-
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -1,20 +1,21 @@
|
|
1
|
-
require
|
1
|
+
require 'rspec/request_describer/version'
|
2
2
|
|
3
3
|
module RSpec
|
4
4
|
module RequestDescriber
|
5
|
-
RESERVED_HEADER_NAMES = %w
|
5
|
+
RESERVED_HEADER_NAMES = %w[
|
6
6
|
content-type
|
7
7
|
host
|
8
8
|
https
|
9
|
-
|
9
|
+
].freeze
|
10
10
|
|
11
|
-
SUPPORTED_METHODS = %w
|
11
|
+
SUPPORTED_METHODS = %w[
|
12
12
|
DELETE
|
13
13
|
GET
|
14
|
+
HEAD
|
14
15
|
PATCH
|
15
16
|
POST
|
16
17
|
PUT
|
17
|
-
|
18
|
+
].freeze
|
18
19
|
|
19
20
|
class << self
|
20
21
|
def included(base)
|
@@ -28,15 +29,17 @@ module RSpec
|
|
28
29
|
http_method,
|
29
30
|
path,
|
30
31
|
headers: env,
|
31
|
-
params: request_body
|
32
|
+
params: request_body
|
32
33
|
)
|
33
34
|
end
|
34
35
|
|
35
36
|
let(:request_body) do
|
36
|
-
if headers.any? { |key, value| key.
|
37
|
+
if headers.any? { |key, value| key.to_s.casecmp('content-type').zero? && value == 'application/json' }
|
37
38
|
params.to_json
|
38
39
|
else
|
39
|
-
params
|
40
|
+
params.inject({}) do |result, (key, value)|
|
41
|
+
result.merge(key.to_s => value)
|
42
|
+
end
|
40
43
|
end
|
41
44
|
end
|
42
45
|
|
@@ -50,8 +53,9 @@ module RSpec
|
|
50
53
|
|
51
54
|
let(:env) do
|
52
55
|
headers.inject({}) do |result, (key, value)|
|
53
|
-
key =
|
54
|
-
key = key.
|
56
|
+
key = key.to_s
|
57
|
+
key = 'HTTP_' + key unless RESERVED_HEADER_NAMES.include?(key.downcase)
|
58
|
+
key = key.tr('-', '_').upcase
|
55
59
|
result.merge(key => value)
|
56
60
|
end
|
57
61
|
end
|
@@ -67,7 +71,7 @@ module RSpec
|
|
67
71
|
end
|
68
72
|
|
69
73
|
let(:path) do
|
70
|
-
endpoint_segments[2].gsub(/:(\w+[!?=]?)/) { send(
|
74
|
+
endpoint_segments[2].gsub(/:(\w+[!?=]?)/) { send(Regexp.last_match(1)) }
|
71
75
|
end
|
72
76
|
end
|
73
77
|
end
|
@@ -1,23 +1,18 @@
|
|
1
|
-
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
1
|
+
lib = File.expand_path('lib', __dir__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'rspec/request_describer/version'
|
5
4
|
|
6
5
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
6
|
+
spec.name = 'rspec-request_describer'
|
8
7
|
spec.version = RSpec::RequestDescriber::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.homepage =
|
13
|
-
spec.license =
|
8
|
+
spec.authors = ['Ryo Nakamura']
|
9
|
+
spec.email = ['r7kamura@gmail.com']
|
10
|
+
spec.summary = 'An RSpec plugin to write self-documenting request-specs.'
|
11
|
+
spec.homepage = 'https://github.com/r7kamura/rspec-request_describer'
|
12
|
+
spec.license = 'MIT'
|
14
13
|
|
15
14
|
spec.files = `git ls-files -z`.split("\x0")
|
16
15
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
17
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
-
spec.require_paths = [
|
19
|
-
|
20
|
-
spec.add_dependency "actionpack", ">= 5.0.0"
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.7"
|
22
|
-
spec.add_development_dependency "rake", "~> 10.0"
|
17
|
+
spec.require_paths = ['lib']
|
23
18
|
end
|
@@ -0,0 +1,141 @@
|
|
1
|
+
require 'openssl'
|
2
|
+
|
3
|
+
RSpec.describe RSpec::RequestDescriber do
|
4
|
+
include RSpec::RequestDescriber
|
5
|
+
|
6
|
+
def get(*args)
|
7
|
+
[__method__, *args]
|
8
|
+
end
|
9
|
+
|
10
|
+
describe 'GET /users' do
|
11
|
+
it 'calls #get' do
|
12
|
+
is_expected.to eq(
|
13
|
+
[
|
14
|
+
:get,
|
15
|
+
'/users',
|
16
|
+
headers: {},
|
17
|
+
params: {}
|
18
|
+
]
|
19
|
+
)
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'with headers' do
|
23
|
+
let(:headers) do
|
24
|
+
super().merge('Authorization' => 'token 12345')
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'calls #get with HTTP_ prefixed and upper-cased headers' do
|
28
|
+
is_expected.to eq(
|
29
|
+
[
|
30
|
+
:get,
|
31
|
+
'/users',
|
32
|
+
headers: { 'HTTP_AUTHORIZATION' => 'token 12345' },
|
33
|
+
params: {}
|
34
|
+
]
|
35
|
+
)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
context 'with headers including reserved header name' do
|
40
|
+
let(:headers) do
|
41
|
+
super().merge('Https' => 'on')
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'calls #get with headers with non HTTP_ prefixed and upper-cased headers' do
|
45
|
+
is_expected.to eq(
|
46
|
+
[
|
47
|
+
:get,
|
48
|
+
'/users',
|
49
|
+
headers: { 'HTTPS' => 'on' },
|
50
|
+
params: {}
|
51
|
+
]
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'with symbolized keys headers' do
|
57
|
+
let(:headers) do
|
58
|
+
super().merge(AUTHORIZATION: 'token 12345')
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'calls #get with HTTP_ prefixed and stringified keys headers' do
|
62
|
+
is_expected.to eq(
|
63
|
+
[
|
64
|
+
:get,
|
65
|
+
'/users',
|
66
|
+
headers: { 'HTTP_AUTHORIZATION' => 'token 12345' },
|
67
|
+
params: {}
|
68
|
+
]
|
69
|
+
)
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
context 'with headers including request body' do
|
74
|
+
before do
|
75
|
+
headers['X-Signature'] = "sha1=#{OpenSSL::HMAC.hexdigest('SHA1', 'secret', request_body.to_s)}"
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'calls #get with HTTP_ prefixed and stringified keys headers' do
|
79
|
+
is_expected.to eq(
|
80
|
+
[
|
81
|
+
:get,
|
82
|
+
'/users',
|
83
|
+
headers: { 'HTTP_X_SIGNATURE' => 'sha1=5d61605c3feea9799210ddcb71307d4ba264225f' },
|
84
|
+
params: {}
|
85
|
+
]
|
86
|
+
)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
context 'with params' do
|
91
|
+
let(:params) do
|
92
|
+
super().merge('sort' => 'id')
|
93
|
+
end
|
94
|
+
|
95
|
+
it 'calls #get with params' do
|
96
|
+
is_expected.to eq(
|
97
|
+
[
|
98
|
+
:get,
|
99
|
+
'/users',
|
100
|
+
headers: {},
|
101
|
+
params: { 'sort' => 'id' }
|
102
|
+
]
|
103
|
+
)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
context 'with symbolized keys params' do
|
108
|
+
let(:params) do
|
109
|
+
super().merge(sort: 'id')
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'calls #get with stringified keys params' do
|
113
|
+
is_expected.to eq(
|
114
|
+
[
|
115
|
+
:get,
|
116
|
+
'/users',
|
117
|
+
headers: {},
|
118
|
+
params: { 'sort' => 'id' }
|
119
|
+
]
|
120
|
+
)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
describe 'GET /users/:user_id' do
|
126
|
+
let(:user_id) do
|
127
|
+
1
|
128
|
+
end
|
129
|
+
|
130
|
+
it 'calles #get with embeded variable in URL path' do
|
131
|
+
is_expected.to eq(
|
132
|
+
[
|
133
|
+
:get,
|
134
|
+
'/users/1',
|
135
|
+
headers: {},
|
136
|
+
params: {}
|
137
|
+
]
|
138
|
+
)
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'rspec/request_describer'
|
2
|
+
|
3
|
+
RSpec.configure do |config|
|
4
|
+
config.expect_with :rspec do |expectations|
|
5
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
6
|
+
end
|
7
|
+
|
8
|
+
config.mock_with :rspec do |mocks|
|
9
|
+
mocks.verify_partial_doubles = true
|
10
|
+
end
|
11
|
+
|
12
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
13
|
+
|
14
|
+
config.filter_run_when_matching :focus
|
15
|
+
|
16
|
+
config.disable_monkey_patching!
|
17
|
+
|
18
|
+
config.warnings = true
|
19
|
+
|
20
|
+
config.default_formatter = 'doc' if config.files_to_run.one?
|
21
|
+
end
|
metadata
CHANGED
@@ -1,57 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rspec-request_describer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: actionpack
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 5.0.0
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 5.0.0
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '1.7'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '1.7'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: rake
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '10.0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '10.0'
|
11
|
+
date: 2023-07-10 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
55
13
|
description:
|
56
14
|
email:
|
57
15
|
- r7kamura@gmail.com
|
@@ -59,15 +17,21 @@ executables: []
|
|
59
17
|
extensions: []
|
60
18
|
extra_rdoc_files: []
|
61
19
|
files:
|
20
|
+
- ".github/workflows/test.yml"
|
62
21
|
- ".gitignore"
|
22
|
+
- ".rspec"
|
23
|
+
- ".rubocop.yml"
|
63
24
|
- CHANGELOG.md
|
64
25
|
- Gemfile
|
26
|
+
- Gemfile.lock
|
65
27
|
- LICENSE.txt
|
66
28
|
- README.md
|
67
29
|
- Rakefile
|
68
30
|
- lib/rspec/request_describer.rb
|
69
31
|
- lib/rspec/request_describer/version.rb
|
70
32
|
- rspec-request_describer.gemspec
|
33
|
+
- spec/rspec/request_describer_spec.rb
|
34
|
+
- spec/spec_helper.rb
|
71
35
|
homepage: https://github.com/r7kamura/rspec-request_describer
|
72
36
|
licenses:
|
73
37
|
- MIT
|
@@ -87,9 +51,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
87
51
|
- !ruby/object:Gem::Version
|
88
52
|
version: '0'
|
89
53
|
requirements: []
|
90
|
-
|
91
|
-
rubygems_version: 2.6.11
|
54
|
+
rubygems_version: 3.3.26
|
92
55
|
signing_key:
|
93
56
|
specification_version: 4
|
94
|
-
summary:
|
95
|
-
test_files:
|
57
|
+
summary: An RSpec plugin to write self-documenting request-specs.
|
58
|
+
test_files:
|
59
|
+
- spec/rspec/request_describer_spec.rb
|
60
|
+
- spec/spec_helper.rb
|