rspec-request_describer 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +1 -1
- data/lib/rspec/request_describer.rb +43 -41
- data/lib/rspec/request_describer/version.rb +1 -1
- data/rspec-request_describer.gemspec +1 -0
- metadata +17 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ced57c8f56dd8b08cb8ffbe3dc5a12e1d4f089b6
|
4
|
+
data.tar.gz: 65cd1e0ce8ad81cec6af3bba061ff23a84ec5cfa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30175d6d6c99e887d1ff511f666193c789c397fea70c29f79fd932510425981c4950172cf3aeec649d0052b05a4156cb7f26e6f5a2c67ec4dbbd39c46843be26
|
7
|
+
data.tar.gz: 7db2261c18b7a787f67efa4128a57f6ed301aa5017f8354095ea0294c0eebbd260d4886237fe8829ed2f20633edf7a26e3352489f2f1a2c14a1c7f3ec1988961
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -9,64 +9,66 @@ module RSpec
|
|
9
9
|
)
|
10
10
|
|
11
11
|
SUPPORTED_METHODS = %w(
|
12
|
+
DELETE
|
12
13
|
GET
|
14
|
+
PATCH
|
13
15
|
POST
|
14
16
|
PUT
|
15
|
-
PATCH
|
16
|
-
DELETE
|
17
17
|
)
|
18
18
|
|
19
|
-
|
20
|
-
base
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
if (ActionDispatch::Integration::Session.instance_method(:process_with_kwargs) rescue false)
|
26
|
-
let(:send_request) do
|
27
|
-
send http_method, path, params: request_body, headers: env
|
19
|
+
class << self
|
20
|
+
def included(base)
|
21
|
+
base.instance_eval do
|
22
|
+
subject do
|
23
|
+
send_request
|
28
24
|
end
|
29
|
-
|
25
|
+
|
30
26
|
let(:send_request) do
|
31
|
-
|
27
|
+
process(
|
28
|
+
http_method,
|
29
|
+
path,
|
30
|
+
headers: env,
|
31
|
+
params: request_body,
|
32
|
+
)
|
32
33
|
end
|
33
|
-
end
|
34
34
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
let(:request_body) do
|
36
|
+
if headers.any? { |key, value| key.downcase == "content-type" && value == "application/json" }
|
37
|
+
params.to_json
|
38
|
+
else
|
39
|
+
params
|
40
|
+
end
|
40
41
|
end
|
41
|
-
end
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
let(:headers) do
|
44
|
+
{}
|
45
|
+
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
47
|
+
let(:params) do
|
48
|
+
{}
|
49
|
+
end
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
51
|
+
let(:env) do
|
52
|
+
headers.inject({}) do |result, (key, value)|
|
53
|
+
key = "HTTP_" + key unless RESERVED_HEADER_NAMES.include?(key)
|
54
|
+
key = key.gsub("-", "_").upcase
|
55
|
+
result.merge(key => value)
|
56
|
+
end
|
56
57
|
end
|
57
|
-
end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
59
|
+
let(:endpoint_segments) do
|
60
|
+
current_example = ::RSpec.respond_to?(:current_example) ? ::RSpec.current_example : example
|
61
|
+
current_example.full_description.match(/(#{::Regexp.union(SUPPORTED_METHODS)}) (\S+)/).to_a
|
62
|
+
end
|
63
63
|
|
64
|
-
|
65
|
-
|
66
|
-
|
64
|
+
# @return [Symbol] e.g. `:get`
|
65
|
+
let(:http_method) do
|
66
|
+
endpoint_segments[1].downcase.to_sym
|
67
|
+
end
|
67
68
|
|
68
|
-
|
69
|
-
|
69
|
+
let(:path) do
|
70
|
+
endpoint_segments[2].gsub(/:(\w+[!?=]?)/) { send($1) }
|
71
|
+
end
|
70
72
|
end
|
71
73
|
end
|
72
74
|
end
|
@@ -17,6 +17,7 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
18
|
spec.require_paths = ["lib"]
|
19
19
|
|
20
|
+
spec.add_dependency "actionpack", ">= 5.0.0"
|
20
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
21
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
22
23
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
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.2.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:
|
11
|
+
date: 2017-02-27 00:00:00.000000000 Z
|
12
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
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -74,9 +88,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
74
88
|
version: '0'
|
75
89
|
requirements: []
|
76
90
|
rubyforge_project:
|
77
|
-
rubygems_version: 2.
|
91
|
+
rubygems_version: 2.5.2
|
78
92
|
signing_key:
|
79
93
|
specification_version: 4
|
80
94
|
summary: Force some rules to write self-documenting request spec.
|
81
95
|
test_files: []
|
82
|
-
has_rdoc:
|