rspec-request_describer 0.1.1 → 0.3.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: ca941a46b240db6e93a089851b119abe12d87f32
4
- data.tar.gz: 5928dde3da34b914593e271cd01ca8ead883f5df
2
+ SHA256:
3
+ metadata.gz: cb25f4acd8dc319c2dffca1e50b4fd19e9bae956b7d677dfa09ea438544628c3
4
+ data.tar.gz: 22ee332cdbac790b599aa6a344dd600a47a57c2a7cc40b21a0e8786fba36a2f4
5
5
  SHA512:
6
- metadata.gz: 1c4e8dda0f084369e0319d4f9b351d474efe843555da89e68cd3028ad45c3ea00b9dc6b9f051b1291f0957acdbf2d4ec39bbbc2c1feac929f7d6844eb2a6c0e0
7
- data.tar.gz: 1819c8db1f0a7db1350876206685be71d0979745c92d422eb36552dfec45f9201e10cb8f0047df69892b391ff79449f6457f938f58b3f10f12eb99da04502177
6
+ metadata.gz: 17863cbb7b007fd4bba582748b1b899d02a20eafa1767f58a3020036489d58032e96b97df9c5d1a48b0745365f479b808fc5b92a0f19b809381ecb3029f91558
7
+ data.tar.gz: 0354a83be4bf146da8eeb26ad338b733338e24ef0efd2fa79059d64750e8c0543544f07df2f9a8e38085c5b8e1877b79f2ee25be80d59fc3d453077d3d4bbd4f
@@ -0,0 +1,46 @@
1
+ jobs:
2
+ rspec:
3
+ docker:
4
+ - image: ruby:2.5.3
5
+ steps:
6
+ - checkout
7
+ - restore_cache:
8
+ keys:
9
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
10
+ - v1-dependencies-
11
+ - run:
12
+ command: bundle install --jobs=4 --retry=3 --path vendor/bundle
13
+ name: bundle install
14
+ - save_cache:
15
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
16
+ paths:
17
+ - ./vendor/bundle
18
+ - run:
19
+ command: bundle exec rspec
20
+ name: rspec
21
+ rubocop:
22
+ docker:
23
+ - image: ruby:2.5.3
24
+ steps:
25
+ - checkout
26
+ - restore_cache:
27
+ keys:
28
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
29
+ - v1-dependencies-
30
+ - run:
31
+ command: bundle install --jobs=4 --retry=3 --path vendor/bundle
32
+ name: bundle install
33
+ - save_cache:
34
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
35
+ paths:
36
+ - ./vendor/bundle
37
+ - run:
38
+ command: bundle exec rubocop
39
+ name: rubocop
40
+ version: 2
41
+ workflows:
42
+ version: 2
43
+ test:
44
+ jobs:
45
+ - rspec
46
+ - rubocop
data/.gitignore CHANGED
@@ -1,14 +1,11 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
3
  /_yardoc/
5
4
  /coverage/
6
5
  /doc/
7
6
  /pkg/
8
7
  /spec/reports/
9
8
  /tmp/
10
- *.bundle
11
- *.so
12
- *.o
13
- *.a
14
- mkmf.log
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,14 @@
1
+ Metrics/AbcSize:
2
+ Enabled: false
3
+
4
+ Metrics/BlockLength:
5
+ Enabled: false
6
+
7
+ Metrics/LineLength:
8
+ Enabled: false
9
+
10
+ Metrics/MethodLength:
11
+ Enabled: false
12
+
13
+ Style/Documentation:
14
+ Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,32 +1,108 @@
1
- ## 0.1.1
2
- - Prevent warning for Rails 5 (Thx @mrkn, #9)
1
+ # Changelog
3
2
 
4
- ## 0.1.0
5
- - Rename `method` with `http_method` (Thx @yujinakayama, #8)
3
+ All notable changes to this project will be documented in this file.
6
4
 
7
- ## 0.0.9
8
- - Ignore case-sensivity on Content-Type checking
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
9
7
 
10
- ## 0.0.8
11
- - Use more sophisticated method capture pattern
8
+ ## v0.3.2 - 2020-02-15
12
9
 
13
- ## 0.0.7
14
- - Add `send_request` to explicitly call `subject` (Thx @lazywei)
10
+ - Remove runtime gem dependency on actionpack.
15
11
 
16
- ## 0.0.6
17
- - Allow any non-space characters in URL path
12
+ ## v0.3.1 - 2019-05-08
18
13
 
19
- ## 0.0.5
20
- - Allow hyphen in path
14
+ - Fix env calculation timing.
21
15
 
22
- ## 0.0.4
23
- - Define HTTPS as reserved header name
16
+ ## v0.3.0 - 2019-05-05
24
17
 
25
- ## 0.0.3
26
- - Remove dependency on ActiveSupport's `Object#in?`
18
+ ### Added
27
19
 
28
- ## 0.0.2
29
- - Support RSpec 3
20
+ - Support symbol keys in request headers.
30
21
 
31
- ## 0.0.1
32
- - 1st Release
22
+ ## 0.2.2 - 2018-05-13
23
+
24
+ ### Fixed
25
+
26
+ - Fix bug: Ignore case-sensitivity of HTTP headers.
27
+
28
+ ## 0.2.1 - 2017-02-27
29
+
30
+ ### Fixed
31
+
32
+ - Fix error from `#process`.
33
+
34
+ ## 0.2.0 - 2017-02-27
35
+
36
+ ### Added
37
+
38
+ - Support actionpack 5.1.0.
39
+
40
+ ### Changed
41
+
42
+ - Declare runtime dependency on actionpack.
43
+
44
+ ## 0.1.1 - 2016-05-15
45
+
46
+ ### Fixed
47
+
48
+ - Prevent warning for Rails 5.
49
+
50
+ ## 0.1.0 - 2015-10-09
51
+
52
+ ### Changed
53
+
54
+ - Rename `method` with `http_method`.
55
+
56
+ ## 0.0.9 - 2015-06-24
57
+
58
+ ### Changed
59
+
60
+ - Ignore case-sensivity on Content-Type checking.
61
+
62
+ ## 0.0.8 - 2015-05-20
63
+
64
+ ### Changed
65
+
66
+ - Use more sophisticated method capture pattern.
67
+
68
+ ## 0.0.7 - 2015-04-20
69
+
70
+ ### Added
71
+
72
+ - Add `send_request` to explicitly call `subject`.
73
+
74
+ ## 0.0.6 - 2015-02-12
75
+
76
+ ### Fixed
77
+
78
+ - Allow any non-space characters in URL path.
79
+
80
+ ## 0.0.5 - 2014-12-25
81
+
82
+ ### Fixed
83
+
84
+ - Allow hyphen in path.
85
+
86
+ ## 0.0.4 - 2014-12-18
87
+
88
+ ### Added
89
+
90
+ - Define HTTPS as reserved header name.
91
+
92
+ ## 0.0.3 - 2014-10-13
93
+
94
+ ### Removed
95
+
96
+ - Remove dependency on ActiveSupport's `Object#in?`.
97
+
98
+ ## 0.0.2 - 2014-09-25
99
+
100
+ ### Added
101
+
102
+ - Support RSpec 3.
103
+
104
+ ## 0.0.1 - 2014-08-29
105
+
106
+ ### Added
107
+
108
+ - 1st Release.
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in rspec-request_describer.gemspec
4
4
  gemspec
5
+
6
+ gem 'rspec'
7
+ gem 'rubocop'
data/Gemfile.lock ADDED
@@ -0,0 +1,96 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rspec-request_describer (0.2.2)
5
+ actionpack (>= 5.0.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ actionpack (5.2.2)
11
+ actionview (= 5.2.2)
12
+ activesupport (= 5.2.2)
13
+ rack (~> 2.0)
14
+ rack-test (>= 0.6.3)
15
+ rails-dom-testing (~> 2.0)
16
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
17
+ actionview (5.2.2)
18
+ activesupport (= 5.2.2)
19
+ builder (~> 3.1)
20
+ erubi (~> 1.4)
21
+ rails-dom-testing (~> 2.0)
22
+ rails-html-sanitizer (~> 1.0, >= 1.0.3)
23
+ activesupport (5.2.2)
24
+ concurrent-ruby (~> 1.0, >= 1.0.2)
25
+ i18n (>= 0.7, < 2)
26
+ minitest (~> 5.1)
27
+ tzinfo (~> 1.1)
28
+ ast (2.4.0)
29
+ builder (3.2.3)
30
+ concurrent-ruby (1.1.3)
31
+ crass (1.0.4)
32
+ diff-lcs (1.3)
33
+ erubi (1.7.1)
34
+ i18n (1.1.1)
35
+ concurrent-ruby (~> 1.0)
36
+ jaro_winkler (1.5.1)
37
+ loofah (2.2.3)
38
+ crass (~> 1.0.2)
39
+ nokogiri (>= 1.5.9)
40
+ mini_portile2 (2.3.0)
41
+ minitest (5.11.3)
42
+ nokogiri (1.8.5)
43
+ mini_portile2 (~> 2.3.0)
44
+ parallel (1.12.1)
45
+ parser (2.5.3.0)
46
+ ast (~> 2.4.0)
47
+ powerpack (0.1.2)
48
+ rack (2.0.6)
49
+ rack-test (1.1.0)
50
+ rack (>= 1.0, < 3)
51
+ rails-dom-testing (2.0.3)
52
+ activesupport (>= 4.2.0)
53
+ nokogiri (>= 1.6)
54
+ rails-html-sanitizer (1.0.4)
55
+ loofah (~> 2.2, >= 2.2.2)
56
+ rainbow (3.0.0)
57
+ rake (10.5.0)
58
+ rspec (3.8.0)
59
+ rspec-core (~> 3.8.0)
60
+ rspec-expectations (~> 3.8.0)
61
+ rspec-mocks (~> 3.8.0)
62
+ rspec-core (3.8.0)
63
+ rspec-support (~> 3.8.0)
64
+ rspec-expectations (3.8.2)
65
+ diff-lcs (>= 1.2.0, < 2.0)
66
+ rspec-support (~> 3.8.0)
67
+ rspec-mocks (3.8.0)
68
+ diff-lcs (>= 1.2.0, < 2.0)
69
+ rspec-support (~> 3.8.0)
70
+ rspec-support (3.8.0)
71
+ rubocop (0.61.1)
72
+ jaro_winkler (~> 1.5.1)
73
+ parallel (~> 1.10)
74
+ parser (>= 2.5, != 2.5.1.1)
75
+ powerpack (~> 0.1)
76
+ rainbow (>= 2.2.2, < 4.0)
77
+ ruby-progressbar (~> 1.7)
78
+ unicode-display_width (~> 1.4.0)
79
+ ruby-progressbar (1.10.0)
80
+ thread_safe (0.3.6)
81
+ tzinfo (1.2.5)
82
+ thread_safe (~> 0.1)
83
+ unicode-display_width (1.4.0)
84
+
85
+ PLATFORMS
86
+ ruby
87
+
88
+ DEPENDENCIES
89
+ bundler (~> 1.7)
90
+ rake (~> 10.0)
91
+ rspec
92
+ rspec-request_describer!
93
+ rubocop
94
+
95
+ BUNDLED WITH
96
+ 1.17.1
data/README.md CHANGED
@@ -1,88 +1,115 @@
1
1
  # RSpec::RequestDescriber
2
- Force some rules to write self-documenting request spec.
2
+
3
+ [![CircleCI](https://circleci.com/gh/r7kamura/rspec-request_describer.svg?style=svg)](https://circleci.com/gh/r7kamura/rspec-request_describer)
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
- Add `rspec-request_describer` into your Gemfile, then run `bundle install`.
14
+
15
+ ### Install
16
+
17
+ Add this line to your application's Gemfile:
6
18
 
7
19
  ```ruby
8
- # Gemfile
9
- gem "rspec-request_describer"
20
+ gem 'rspec-request_describer'
21
+ ```
22
+
23
+ And then execute:
24
+
25
+ ```
26
+ bundle
27
+ ```
10
28
 
11
- # rspec-request_describer depends on some methods of rspec-rails (or rack-test),
12
- # so you may need to add it unless you haven't do it yet.
13
- gem "rspec-rails" # or "rack-test"
29
+ Or install it yourself as:
30
+
31
+ ```
32
+ gem install rspec-request_describer
14
33
  ```
15
34
 
16
- Then include `RSpec::RequestDescriber` into your `RSpec.configuration`.
35
+ ### Include
36
+
37
+ Include `RSpec::RequestDescriber` to your example groups like this:
17
38
 
18
39
  ```ruby
19
- # spec/spec_helper.rb
20
- RSpec.configuration.include RSpec::RequestDescriber
40
+ require 'rspec/request_describer'
41
+
42
+ RSpec.configuration.include RSpec::RequestDescriber, type: :request
21
43
  ```
22
44
 
23
45
  ## Usage
24
- RSpec::RequestDescriber provides some `subject` and `let` to your specs.
25
46
 
26
47
  ### subject
27
- In the example below, the `subject` calls an HTTP request of GET /users,
28
- then returns its status code.
48
+
49
+ `RSpec::RequestDescriber` provides `subject` from its top-level description.
29
50
 
30
51
  ```ruby
31
- describe "GET /users" do
32
- it { should == 200 }
52
+ # subject will be `get('/users')`.
53
+ RSpec.describe 'GET /users' do
54
+ it { is_expected.to eq(200) }
33
55
  end
34
56
  ```
35
57
 
36
58
  ### headers
37
- `headers` is provided to modify request headers.
38
- In the below example, a token is added into Authorization request header.
39
59
 
60
+ If you want to modify request headers, change `headers` before calling `subject`.
40
61
 
41
62
  ```ruby
42
- describe "GET /users" do
43
- context "with Authorization header" do
63
+ # `subject` will be `get('/users', headers: { 'Authorization' => 'token 12345' })`.
64
+ RSpec.describe 'GET /users' do
65
+ context 'with Authorization header' do
44
66
  before do
45
- headers["Authorization"] = "token 12345"
67
+ headers['Authorization'] = 'token 12345'
46
68
  end
47
- it { should == 200 }
69
+ it { is_expected.to eq(200) }
48
70
  end
49
71
  end
50
72
  ```
51
73
 
52
74
  ### params
53
- You can also pass query parameter or request body by modifying `params`.
54
- In the this example, `?sort=id` is added into URL query string.
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.
75
+
76
+ If you want to modify request parameters, change `params` before calling `subject`.
60
77
 
61
78
  ```ruby
62
- describe "GET /users" do
63
- context "with sort parameter" do
79
+ # `subject` will be `get('/users', params: { 'sort' => 'id' })`.
80
+ RSpec.describe 'GET /users' do
81
+ context 'with sort parameter' do
64
82
  before do
65
- params["sort"] = "id"
83
+ params['sort'] = 'id'
66
84
  end
67
85
 
68
- it "returns users in ID order" do
86
+ it 'returns users in ID order' do
87
+ is_expected.to eq(200)
88
+
69
89
  users = JSON.parse(response.body)
70
- users[0].id.should == 1
71
- users[1].id.should == 2
90
+ expect(users[0]['id']).to eq(1)
91
+ expect(users[1]['id']).to eq(2)
72
92
  end
73
93
  end
74
94
  end
75
95
  ```
76
96
 
77
- ### variable
78
- You can use variables in URL path like `:id`.
79
- In this example, the returned value of `id` method is used as its real value.
97
+ ### variables in URL path
98
+
99
+ You can embed variables in URL path like `/users/:id`.
100
+ In this example, the returned value of `id` method will be emobeded as its real value.
80
101
 
81
102
  ```ruby
82
- describe "GET /users/:id" do
83
- let(:id) do
84
- User.create(name: "alice").id
103
+ # `subject` will be `get("/users/#{user_id}")`.
104
+ RSpec.describe 'GET /users/:user_id' do
105
+ let(:user) do
106
+ User.create(name: 'alice')
85
107
  end
86
- it { should == 200 }
108
+
109
+ let(:user_id) do
110
+ user.id
111
+ end
112
+
113
+ it { is_expected.to eq(200) }
87
114
  end
88
115
  ```
data/Rakefile CHANGED
@@ -1,2 +1 @@
1
- require "bundler/gem_tasks"
2
-
1
+ require 'bundler/gem_tasks'
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module RequestDescriber
3
- VERSION = "0.1.1"
3
+ VERSION = '0.3.2'.freeze
4
4
  end
5
5
  end
@@ -1,72 +1,77 @@
1
- require "rspec/request_describer/version"
1
+ require 'rspec/request_describer/version'
2
2
 
3
3
  module RSpec
4
4
  module RequestDescriber
5
- RESERVED_HEADER_NAMES = %w(
6
- Content-Type
7
- Host
8
- HTTPS
9
- )
5
+ RESERVED_HEADER_NAMES = %w[
6
+ content-type
7
+ host
8
+ https
9
+ ].freeze
10
10
 
11
- SUPPORTED_METHODS = %w(
11
+ SUPPORTED_METHODS = %w[
12
+ DELETE
12
13
  GET
14
+ PATCH
13
15
  POST
14
16
  PUT
15
- PATCH
16
- DELETE
17
- )
18
-
19
- def self.included(base)
20
- base.instance_eval do
21
- subject do
22
- send_request
23
- end
17
+ ].freeze
24
18
 
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
+ send(
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.to_s.casecmp('content-type').zero? && value == 'application/json' }
37
+ params.to_json
38
+ else
39
+ params.inject({}) do |result, (key, value)|
40
+ result.merge(key.to_s => value)
41
+ end
42
+ end
40
43
  end
41
- end
42
44
 
43
- let(:headers) do
44
- {}
45
- end
45
+ let(:headers) do
46
+ {}
47
+ end
46
48
 
47
- let(:params) do
48
- {}
49
- end
49
+ let(:params) do
50
+ {}
51
+ end
50
52
 
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)
53
+ let(:env) do
54
+ headers.inject({}) do |result, (key, value)|
55
+ key = key.to_s
56
+ key = 'HTTP_' + key unless RESERVED_HEADER_NAMES.include?(key.downcase)
57
+ key = key.tr('-', '_').upcase
58
+ result.merge(key => value)
59
+ end
56
60
  end
57
- end
58
61
 
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
62
+ let(:endpoint_segments) do
63
+ current_example = ::RSpec.respond_to?(:current_example) ? ::RSpec.current_example : example
64
+ current_example.full_description.match(/(#{::Regexp.union(SUPPORTED_METHODS)}) (\S+)/).to_a
65
+ end
63
66
 
64
- let(:http_method) do
65
- endpoint_segments[1].downcase
66
- end
67
+ # @return [String] e.g. `"get"`
68
+ let(:http_method) do
69
+ endpoint_segments[1].downcase
70
+ end
67
71
 
68
- let(:path) do
69
- endpoint_segments[2].gsub(/:(\w+[!?=]?)/) { send($1) }
72
+ let(:path) do
73
+ endpoint_segments[2].gsub(/:(\w+[!?=]?)/) { send(Regexp.last_match(1)) }
74
+ end
70
75
  end
71
76
  end
72
77
  end
@@ -1,22 +1,21 @@
1
- # coding: utf-8
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 = "rspec-request_describer"
6
+ spec.name = 'rspec-request_describer'
8
7
  spec.version = RSpec::RequestDescriber::VERSION
9
- spec.authors = ["Ryo Nakamura"]
10
- spec.email = ["r7kamura@gmail.com"]
11
- spec.summary = "Force some rules to write self-documenting request spec."
12
- spec.homepage = "https://github.com/r7kamura/rspec-request_describer"
13
- spec.license = "MIT"
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 = ["lib"]
17
+ spec.require_paths = ['lib']
19
18
 
20
- spec.add_development_dependency "bundler", "~> 1.7"
21
- spec.add_development_dependency "rake", "~> 10.0"
19
+ spec.add_development_dependency 'bundler', '~> 1.7'
20
+ spec.add_development_dependency 'rake', '~> 10.0'
22
21
  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
@@ -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,14 +1,14 @@
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.3.2
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: 2020-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -45,15 +45,21 @@ executables: []
45
45
  extensions: []
46
46
  extra_rdoc_files: []
47
47
  files:
48
+ - ".circleci/config.yml"
48
49
  - ".gitignore"
50
+ - ".rspec"
51
+ - ".rubocop.yml"
49
52
  - CHANGELOG.md
50
53
  - Gemfile
54
+ - Gemfile.lock
51
55
  - LICENSE.txt
52
56
  - README.md
53
57
  - Rakefile
54
58
  - lib/rspec/request_describer.rb
55
59
  - lib/rspec/request_describer/version.rb
56
60
  - rspec-request_describer.gemspec
61
+ - spec/rspec/request_describer_spec.rb
62
+ - spec/spec_helper.rb
57
63
  homepage: https://github.com/r7kamura/rspec-request_describer
58
64
  licenses:
59
65
  - MIT
@@ -73,10 +79,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
79
  - !ruby/object:Gem::Version
74
80
  version: '0'
75
81
  requirements: []
76
- rubyforge_project:
77
- rubygems_version: 2.4.5
82
+ rubygems_version: 3.0.3
78
83
  signing_key:
79
84
  specification_version: 4
80
- summary: Force some rules to write self-documenting request spec.
81
- test_files: []
82
- has_rdoc:
85
+ summary: An RSpec plugin to write self-documenting request-specs.
86
+ test_files:
87
+ - spec/rspec/request_describer_spec.rb
88
+ - spec/spec_helper.rb