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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca941a46b240db6e93a089851b119abe12d87f32
4
- data.tar.gz: 5928dde3da34b914593e271cd01ca8ead883f5df
3
+ metadata.gz: ced57c8f56dd8b08cb8ffbe3dc5a12e1d4f089b6
4
+ data.tar.gz: 65cd1e0ce8ad81cec6af3bba061ff23a84ec5cfa
5
5
  SHA512:
6
- metadata.gz: 1c4e8dda0f084369e0319d4f9b351d474efe843555da89e68cd3028ad45c3ea00b9dc6b9f051b1291f0957acdbf2d4ec39bbbc2c1feac929f7d6844eb2a6c0e0
7
- data.tar.gz: 1819c8db1f0a7db1350876206685be71d0979745c92d422eb36552dfec45f9201e10cb8f0047df69892b391ff79449f6457f938f58b3f10f12eb99da04502177
6
+ metadata.gz: 30175d6d6c99e887d1ff511f666193c789c397fea70c29f79fd932510425981c4950172cf3aeec649d0052b05a4156cb7f26e6f5a2c67ec4dbbd39c46843be26
7
+ data.tar.gz: 7db2261c18b7a787f67efa4128a57f6ed301aa5017f8354095ea0294c0eebbd260d4886237fe8829ed2f20633edf7a26e3352489f2f1a2c14a1c7f3ec1988961
@@ -1,3 +1,8 @@
1
+ ## 0.2.0
2
+
3
+ - Support actionpack 5.1.0
4
+ - Dependent on actionpack
5
+
1
6
  ## 0.1.1
2
7
  - Prevent warning for Rails 5 (Thx @mrkn, #9)
3
8
 
data/README.md CHANGED
@@ -17,7 +17,7 @@ Then include `RSpec::RequestDescriber` into your `RSpec.configuration`.
17
17
 
18
18
  ```ruby
19
19
  # spec/spec_helper.rb
20
- RSpec.configuration.include RSpec::RequestDescriber
20
+ RSpec.configuration.include RSpec::RequestDescriber, type: :request
21
21
  ```
22
22
 
23
23
  ## Usage
@@ -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
- def self.included(base)
20
- base.instance_eval do
21
- subject do
22
- send_request
23
- end
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
- else
25
+
30
26
  let(:send_request) do
31
- send http_method, path, request_body, env
27
+ process(
28
+ http_method,
29
+ path,
30
+ headers: env,
31
+ params: request_body,
32
+ )
32
33
  end
33
- end
34
34
 
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
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
- let(:headers) do
44
- {}
45
- end
43
+ let(:headers) do
44
+ {}
45
+ end
46
46
 
47
- let(:params) do
48
- {}
49
- end
47
+ let(:params) do
48
+ {}
49
+ end
50
50
 
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)
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
- let(:endpoint_segments) do
60
- current_example = RSpec.respond_to?(:current_example) ? RSpec.current_example : example
61
- current_example.full_description.match(/(#{SUPPORTED_METHODS.join("|")}) (\S+)/).to_a
62
- end
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
- let(:http_method) do
65
- endpoint_segments[1].downcase
66
- end
64
+ # @return [Symbol] e.g. `:get`
65
+ let(:http_method) do
66
+ endpoint_segments[1].downcase.to_sym
67
+ end
67
68
 
68
- let(:path) do
69
- endpoint_segments[2].gsub(/:(\w+[!?=]?)/) { send($1) }
69
+ let(:path) do
70
+ endpoint_segments[2].gsub(/:(\w+[!?=]?)/) { send($1) }
71
+ end
70
72
  end
71
73
  end
72
74
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module RequestDescriber
3
- VERSION = "0.1.1"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  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.1.1
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: 2016-05-14 00:00:00.000000000 Z
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.4.5
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: