rspec-request_describer 0.2.2 → 0.3.0

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: 7860d4f2fb580876b71c84c3c4b84f844644af11
4
- data.tar.gz: c9e1bf92c070cdaa7b4b76c30cb31459b11bc54f
2
+ SHA256:
3
+ metadata.gz: a8e2fcd9ca31fc770513b5d6c8aac8167a1a728f1413e830e4169bf680c66b0e
4
+ data.tar.gz: 6f7b366b4587b7c7b2fb327910a295f4a3652c6008e51223f70e358086bf03b9
5
5
  SHA512:
6
- metadata.gz: a64cf031ee613b3c12080fcda4b927c3f8ae9fd3f678aa54c53c106b2965c062198d5996a64aca08dc949b50ce1bbf58f578dd5c5dbfba4821df8dbda5dbb2c5
7
- data.tar.gz: b0adab9b3884366e6024bacfbd3b6d2ea4a5d1671a7eb3963344294ecc734aa6c991217ab5db9cb6eec1dbc85d7ebd775275710320052392e9ca115d53873c5d
6
+ metadata.gz: '08ea603385b4e6820f15ae69d59e9653150564e89aca496366dcb1bf96feda8ccc97f77d1399af4725f0978a74f1c187a1bf66eede4836b99adeb95972ec3511'
7
+ data.tar.gz: d9203c8edf2eca941726f4909156705b226ea14a1ff690606dd439241f174bd04231cdc35872d9eef014d72d5d7199ee3beeaa68edb07d5f699168a3f79268ad
@@ -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,45 +1,100 @@
1
- ## v0.2.2
1
+ # Changelog
2
2
 
3
- - Fix bug: Ignore case-sensitivity of HTTP headers (Thx @k5trismegistus, #14)
3
+ All notable changes to this project will be documented in this file.
4
4
 
5
- ## 0.2.1
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).
6
7
 
7
- - Fix error from `#process`
8
+ ## v0.3.0 - 2019-05-05
8
9
 
9
- ## 0.2.0
10
+ ### Added
10
11
 
11
- - Support actionpack 5.1.0
12
- - Dependent on actionpack
12
+ - Support symbol keys in request headers.
13
13
 
14
- ## 0.1.1
15
- - Prevent warning for Rails 5 (Thx @mrkn, #9)
14
+ ## 0.2.2 - 2018-05-13
16
15
 
17
- ## 0.1.0
18
- - Rename `method` with `http_method` (Thx @yujinakayama, #8)
16
+ ### Fixed
19
17
 
20
- ## 0.0.9
21
- - Ignore case-sensivity on Content-Type checking
18
+ - Fix bug: Ignore case-sensitivity of HTTP headers.
22
19
 
23
- ## 0.0.8
24
- - Use more sophisticated method capture pattern
20
+ ## 0.2.1 - 2017-02-27
25
21
 
26
- ## 0.0.7
27
- - Add `send_request` to explicitly call `subject` (Thx @lazywei)
22
+ ### Fixed
28
23
 
29
- ## 0.0.6
30
- - Allow any non-space characters in URL path
24
+ - Fix error from `#process`.
31
25
 
32
- ## 0.0.5
33
- - Allow hyphen in path
26
+ ## 0.2.0 - 2017-02-27
34
27
 
35
- ## 0.0.4
36
- - Define HTTPS as reserved header name
28
+ ### Added
37
29
 
38
- ## 0.0.3
39
- - Remove dependency on ActiveSupport's `Object#in?`
30
+ - Support actionpack 5.1.0.
40
31
 
41
- ## 0.0.2
42
- - Support RSpec 3
32
+ ### Changed
43
33
 
44
- ## 0.0.1
45
- - 1st Release
34
+ - Declare runtime dependency on actionpack.
35
+
36
+ ## 0.1.1 - 2016-05-15
37
+
38
+ ### Fixed
39
+
40
+ - Prevent warning for Rails 5.
41
+
42
+ ## 0.1.0 - 2015-10-09
43
+
44
+ ### Changed
45
+
46
+ - Rename `method` with `http_method`.
47
+
48
+ ## 0.0.9 - 2015-06-24
49
+
50
+ ### Changed
51
+
52
+ - Ignore case-sensivity on Content-Type checking.
53
+
54
+ ## 0.0.8 - 2015-05-20
55
+
56
+ ### Changed
57
+
58
+ - Use more sophisticated method capture pattern.
59
+
60
+ ## 0.0.7 - 2015-04-20
61
+
62
+ ### Added
63
+
64
+ - Add `send_request` to explicitly call `subject`.
65
+
66
+ ## 0.0.6 - 2015-02-12
67
+
68
+ ### Fixed
69
+
70
+ - Allow any non-space characters in URL path.
71
+
72
+ ## 0.0.5 - 2014-12-25
73
+
74
+ ### Fixed
75
+
76
+ - Allow hyphen in path.
77
+
78
+ ## 0.0.4 - 2014-12-18
79
+
80
+ ### Added
81
+
82
+ - Define HTTPS as reserved header name.
83
+
84
+ ## 0.0.3 - 2014-10-13
85
+
86
+ ### Removed
87
+
88
+ - Remove dependency on ActiveSupport's `Object#in?`.
89
+
90
+ ## 0.0.2 - 2014-09-25
91
+
92
+ ### Added
93
+
94
+ - Support RSpec 3.
95
+
96
+ ## 0.0.1 - 2014-08-29
97
+
98
+ ### Added
99
+
100
+ - 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
40
+ require 'rspec/request_describer'
41
+
20
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,20 +1,20 @@
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(
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
14
  PATCH
15
15
  POST
16
16
  PUT
17
- )
17
+ ].freeze
18
18
 
19
19
  class << self
20
20
  def included(base)
@@ -28,15 +28,17 @@ module RSpec
28
28
  http_method,
29
29
  path,
30
30
  headers: env,
31
- params: request_body,
31
+ params: request_body
32
32
  )
33
33
  end
34
34
 
35
35
  let(:request_body) do
36
- if headers.any? { |key, value| key.downcase == "content-type" && value == "application/json" }
36
+ if env['CONTENT_TYPE'] == 'application/json'
37
37
  params.to_json
38
38
  else
39
- params
39
+ params.inject({}) do |result, (key, value)|
40
+ result.merge(key.to_s => value)
41
+ end
40
42
  end
41
43
  end
42
44
 
@@ -50,8 +52,9 @@ module RSpec
50
52
 
51
53
  let(:env) do
52
54
  headers.inject({}) do |result, (key, value)|
53
- key = "HTTP_" + key unless RESERVED_HEADER_NAMES.include?(key.downcase)
54
- key = key.gsub("-", "_").upcase
55
+ key = key.to_s
56
+ key = 'HTTP_' + key unless RESERVED_HEADER_NAMES.include?(key.downcase)
57
+ key = key.tr('-', '_').upcase
55
58
  result.merge(key => value)
56
59
  end
57
60
  end
@@ -67,7 +70,7 @@ module RSpec
67
70
  end
68
71
 
69
72
  let(:path) do
70
- endpoint_segments[2].gsub(/:(\w+[!?=]?)/) { send($1) }
73
+ endpoint_segments[2].gsub(/:(\w+[!?=]?)/) { send(Regexp.last_match(1)) }
71
74
  end
72
75
  end
73
76
  end
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module RequestDescriber
3
- VERSION = "0.2.2"
3
+ VERSION = '0.3.0'.freeze
4
4
  end
5
5
  end
@@ -1,23 +1,22 @@
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_dependency "actionpack", ">= 5.0.0"
21
- spec.add_development_dependency "bundler", "~> 1.7"
22
- spec.add_development_dependency "rake", "~> 10.0"
19
+ spec.add_dependency 'actionpack', '>= 5.0.0'
20
+ spec.add_development_dependency 'bundler', '~> 1.7'
21
+ spec.add_development_dependency 'rake', '~> 10.0'
23
22
  end
@@ -0,0 +1,122 @@
1
+ RSpec.describe RSpec::RequestDescriber do
2
+ include RSpec::RequestDescriber
3
+
4
+ def get(*args)
5
+ [__method__, *args]
6
+ end
7
+
8
+ describe 'GET /users' do
9
+ it 'calls #get' do
10
+ is_expected.to eq(
11
+ [
12
+ :get,
13
+ '/users',
14
+ headers: {},
15
+ params: {}
16
+ ]
17
+ )
18
+ end
19
+
20
+ context 'with headers' do
21
+ let(:headers) do
22
+ super().merge('Authorization' => 'token 12345')
23
+ end
24
+
25
+ it 'calls #get with HTTP_ prefixed and upper-cased headers' do
26
+ is_expected.to eq(
27
+ [
28
+ :get,
29
+ '/users',
30
+ headers: { 'HTTP_AUTHORIZATION' => 'token 12345' },
31
+ params: {}
32
+ ]
33
+ )
34
+ end
35
+ end
36
+
37
+ context 'with headers including reserved header name' do
38
+ let(:headers) do
39
+ super().merge('Https' => 'on')
40
+ end
41
+
42
+ it 'calls #get with headers with non HTTP_ prefixed and upper-cased headers' do
43
+ is_expected.to eq(
44
+ [
45
+ :get,
46
+ '/users',
47
+ headers: { 'HTTPS' => 'on' },
48
+ params: {}
49
+ ]
50
+ )
51
+ end
52
+ end
53
+
54
+ context 'with symbolized keys headers' do
55
+ let(:headers) do
56
+ super().merge(AUTHORIZATION: 'token 12345')
57
+ end
58
+
59
+ it 'calls #get with HTTP_ prefixed and stringified keys headers' do
60
+ is_expected.to eq(
61
+ [
62
+ :get,
63
+ '/users',
64
+ headers: { 'HTTP_AUTHORIZATION' => 'token 12345' },
65
+ params: {}
66
+ ]
67
+ )
68
+ end
69
+ end
70
+
71
+ context 'with params' do
72
+ let(:params) do
73
+ super().merge('sort' => 'id')
74
+ end
75
+
76
+ it 'calls #get with params' do
77
+ is_expected.to eq(
78
+ [
79
+ :get,
80
+ '/users',
81
+ headers: {},
82
+ params: { 'sort' => 'id' }
83
+ ]
84
+ )
85
+ end
86
+ end
87
+
88
+ context 'with symbolized keys params' do
89
+ let(:params) do
90
+ super().merge(sort: 'id')
91
+ end
92
+
93
+ it 'calls #get with stringified keys params' do
94
+ is_expected.to eq(
95
+ [
96
+ :get,
97
+ '/users',
98
+ headers: {},
99
+ params: { 'sort' => 'id' }
100
+ ]
101
+ )
102
+ end
103
+ end
104
+ end
105
+
106
+ describe 'GET /users/:user_id' do
107
+ let(:user_id) do
108
+ 1
109
+ end
110
+
111
+ it 'calles #get with embeded variable in URL path' do
112
+ is_expected.to eq(
113
+ [
114
+ :get,
115
+ '/users/1',
116
+ headers: {},
117
+ params: {}
118
+ ]
119
+ )
120
+ end
121
+ end
122
+ 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.2.2
4
+ version: 0.3.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: 2018-03-13 00:00:00.000000000 Z
11
+ date: 2019-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actionpack
@@ -59,15 +59,21 @@ executables: []
59
59
  extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
+ - ".circleci/config.yml"
62
63
  - ".gitignore"
64
+ - ".rspec"
65
+ - ".rubocop.yml"
63
66
  - CHANGELOG.md
64
67
  - Gemfile
68
+ - Gemfile.lock
65
69
  - LICENSE.txt
66
70
  - README.md
67
71
  - Rakefile
68
72
  - lib/rspec/request_describer.rb
69
73
  - lib/rspec/request_describer/version.rb
70
74
  - rspec-request_describer.gemspec
75
+ - spec/rspec/request_describer_spec.rb
76
+ - spec/spec_helper.rb
71
77
  homepage: https://github.com/r7kamura/rspec-request_describer
72
78
  licenses:
73
79
  - MIT
@@ -88,8 +94,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
88
94
  version: '0'
89
95
  requirements: []
90
96
  rubyforge_project:
91
- rubygems_version: 2.6.11
97
+ rubygems_version: 2.7.6
92
98
  signing_key:
93
99
  specification_version: 4
94
- summary: Force some rules to write self-documenting request spec.
95
- test_files: []
100
+ summary: An RSpec plugin to write self-documenting request-specs.
101
+ test_files:
102
+ - spec/rspec/request_describer_spec.rb
103
+ - spec/spec_helper.rb