rspec-request_describer 0.3.2 → 0.5.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
  SHA256:
3
- metadata.gz: cb25f4acd8dc319c2dffca1e50b4fd19e9bae956b7d677dfa09ea438544628c3
4
- data.tar.gz: 22ee332cdbac790b599aa6a344dd600a47a57c2a7cc40b21a0e8786fba36a2f4
3
+ metadata.gz: 813d1506690f4cf7e4d0857dcdf1435fef147991f7ed62c38bf84c9cde8b7939
4
+ data.tar.gz: 0f4344c220644c8219596c95131fa0a39b550ed1495c93a438cd04f5e5f86f1f
5
5
  SHA512:
6
- metadata.gz: 17863cbb7b007fd4bba582748b1b899d02a20eafa1767f58a3020036489d58032e96b97df9c5d1a48b0745365f479b808fc5b92a0f19b809381ecb3029f91558
7
- data.tar.gz: 0354a83be4bf146da8eeb26ad338b733338e24ef0efd2fa79059d64750e8c0543544f07df2f9a8e38085c5b8e1877b79f2ee25be80d59fc3d453077d3d4bbd4f
6
+ metadata.gz: b01cd40a7f9e7053ee8b513adb33457d64701eb5afe710ecc22e784f300710a14f822d99d6568bcb43a46ca79f73c8b8e0e2d09396bc344f43a97d474cd4a8b0
7
+ data.tar.gz: 6aee8e0079e15f6e16061ef34289a7d2c7271591cb65fccf3772c83c1db0a0832e2a47ba52586db6dea756abcce3bbec9cb9ad5d7b7b1fe326c7c6958ac981de
@@ -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/CHANGELOG.md CHANGED
@@ -1,19 +1,32 @@
1
1
  # Changelog
2
2
 
3
- All notable changes to this project will be documented in this file.
3
+ ## Unreleased
4
4
 
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).
5
+ ## 0.5.0 - 2024-03-28
7
6
 
8
- ## v0.3.2 - 2020-02-15
7
+ ### Added
8
+
9
+ - Raise friendly error on incorrect `describe` usage.
10
+
11
+ ## 0.4.0 - 2023-07-10
12
+
13
+ ### Added
14
+
15
+ - Support HEAD HTTP method.
16
+
17
+ ## 0.3.2 - 2020-02-15
18
+
19
+ ### Removed
9
20
 
10
21
  - Remove runtime gem dependency on actionpack.
11
22
 
12
- ## v0.3.1 - 2019-05-08
23
+ ## 0.3.1 - 2019-05-08
24
+
25
+ ### Fixed
13
26
 
14
27
  - Fix env calculation timing.
15
28
 
16
- ## v0.3.0 - 2019-05-05
29
+ ## 0.3.0 - 2019-05-05
17
30
 
18
31
  ### Added
19
32
 
data/Gemfile CHANGED
@@ -3,5 +3,6 @@ source 'https://rubygems.org'
3
3
  # Specify your gem's dependencies in rspec-request_describer.gemspec
4
4
  gemspec
5
5
 
6
+ gem 'rake'
6
7
  gem 'rspec'
7
8
  gem 'rubocop'
data/Gemfile.lock CHANGED
@@ -1,60 +1,20 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-request_describer (0.2.2)
5
- actionpack (>= 5.0.0)
4
+ rspec-request_describer (0.5.0)
6
5
 
7
6
  GEM
8
7
  remote: https://rubygems.org/
9
8
  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
9
  ast (2.4.0)
29
- builder (3.2.3)
30
- concurrent-ruby (1.1.3)
31
- crass (1.0.4)
32
10
  diff-lcs (1.3)
33
- erubi (1.7.1)
34
- i18n (1.1.1)
35
- concurrent-ruby (~> 1.0)
36
11
  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
12
  parallel (1.12.1)
45
13
  parser (2.5.3.0)
46
14
  ast (~> 2.4.0)
47
15
  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
16
  rainbow (3.0.0)
57
- rake (10.5.0)
17
+ rake (13.0.1)
58
18
  rspec (3.8.0)
59
19
  rspec-core (~> 3.8.0)
60
20
  rspec-expectations (~> 3.8.0)
@@ -77,20 +37,16 @@ GEM
77
37
  ruby-progressbar (~> 1.7)
78
38
  unicode-display_width (~> 1.4.0)
79
39
  ruby-progressbar (1.10.0)
80
- thread_safe (0.3.6)
81
- tzinfo (1.2.5)
82
- thread_safe (~> 0.1)
83
40
  unicode-display_width (1.4.0)
84
41
 
85
42
  PLATFORMS
86
43
  ruby
87
44
 
88
45
  DEPENDENCIES
89
- bundler (~> 1.7)
90
- rake (~> 10.0)
46
+ rake
91
47
  rspec
92
48
  rspec-request_describer!
93
49
  rubocop
94
50
 
95
51
  BUNDLED WITH
96
- 1.17.1
52
+ 2.2.29
data/README.md CHANGED
@@ -1,9 +1,9 @@
1
1
  # RSpec::RequestDescriber
2
2
 
3
- [![CircleCI](https://circleci.com/gh/r7kamura/rspec-request_describer.svg?style=svg)](https://circleci.com/gh/r7kamura/rspec-request_describer)
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
4
  [![Gem Version](https://badge.fury.io/rb/rspec-request_describer.svg)](https://rubygems.org/gems/rspec-request_describer)
5
5
 
6
- An RSpec plugin to write self-documenting request-specs.
6
+ RSpec plugin to write self-documenting request-specs.
7
7
 
8
8
  This gem is designed for:
9
9
 
@@ -39,11 +39,15 @@ Include `RSpec::RequestDescriber` to your example groups like this:
39
39
  ```ruby
40
40
  require 'rspec/request_describer'
41
41
 
42
- RSpec.configuration.include RSpec::RequestDescriber, type: :request
42
+ RSpec.configure do |config|
43
+ config.include RSpec::RequestDescriber, type: :request
44
+ end
43
45
  ```
44
46
 
45
47
  ## Usage
46
48
 
49
+ Note that this is an example in a Rails app.
50
+
47
51
  ### subject
48
52
 
49
53
  `RSpec::RequestDescriber` provides `subject` from its top-level description.
@@ -51,7 +55,10 @@ RSpec.configuration.include RSpec::RequestDescriber, type: :request
51
55
  ```ruby
52
56
  # subject will be `get('/users')`.
53
57
  RSpec.describe 'GET /users' do
54
- it { is_expected.to eq(200) }
58
+ it 'returns 200' do
59
+ subject
60
+ expect(response).to have_http_status(200)
61
+ end
55
62
  end
56
63
  ```
57
64
 
@@ -66,7 +73,11 @@ RSpec.describe 'GET /users' do
66
73
  before do
67
74
  headers['Authorization'] = 'token 12345'
68
75
  end
69
- it { is_expected.to eq(200) }
76
+
77
+ it 'returns 200' do
78
+ subject
79
+ expect(response).to have_http_status(200)
80
+ end
70
81
  end
71
82
  end
72
83
  ```
@@ -83,21 +94,24 @@ RSpec.describe 'GET /users' do
83
94
  params['sort'] = 'id'
84
95
  end
85
96
 
86
- it 'returns users in ID order' do
87
- is_expected.to eq(200)
88
-
89
- users = JSON.parse(response.body)
90
- expect(users[0]['id']).to eq(1)
91
- expect(users[1]['id']).to eq(2)
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
+ )
92
106
  end
93
107
  end
94
108
  end
95
109
  ```
96
110
 
97
- ### variables in URL path
111
+ ### path parameters
98
112
 
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.
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 embedded as its real value.
101
115
 
102
116
  ```ruby
103
117
  # `subject` will be `get("/users/#{user_id}")`.
@@ -110,6 +124,9 @@ RSpec.describe 'GET /users/:user_id' do
110
124
  user.id
111
125
  end
112
126
 
113
- it { is_expected.to eq(200) }
127
+ it 'returns 200' do
128
+ subject
129
+ expect(response).to have_http_status(200)
130
+ end
114
131
  end
115
132
  ```
@@ -1,5 +1,5 @@
1
1
  module RSpec
2
2
  module RequestDescriber
3
- VERSION = '0.3.2'.freeze
3
+ VERSION = '0.5.0'.freeze
4
4
  end
5
5
  end
@@ -2,6 +2,8 @@ require 'rspec/request_describer/version'
2
2
 
3
3
  module RSpec
4
4
  module RequestDescriber
5
+ class IncorrectDescribe < StandardError; end
6
+
5
7
  RESERVED_HEADER_NAMES = %w[
6
8
  content-type
7
9
  host
@@ -11,6 +13,7 @@ module RSpec
11
13
  SUPPORTED_METHODS = %w[
12
14
  DELETE
13
15
  GET
16
+ HEAD
14
17
  PATCH
15
18
  POST
16
19
  PUT
@@ -61,7 +64,10 @@ module RSpec
61
64
 
62
65
  let(:endpoint_segments) do
63
66
  current_example = ::RSpec.respond_to?(:current_example) ? ::RSpec.current_example : example
64
- current_example.full_description.match(/(#{::Regexp.union(SUPPORTED_METHODS)}) (\S+)/).to_a
67
+ match = current_example.full_description.match(/(#{::Regexp.union(SUPPORTED_METHODS)}) (\S+)/)
68
+ raise IncorrectDescribe, 'Please use the format "METHOD /path" for the describe' unless match
69
+
70
+ match.to_a
65
71
  end
66
72
 
67
73
  # @return [String] e.g. `"get"`
@@ -15,7 +15,4 @@ Gem::Specification.new do |spec|
15
15
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
16
16
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
17
17
  spec.require_paths = ['lib']
18
-
19
- spec.add_development_dependency 'bundler', '~> 1.7'
20
- spec.add_development_dependency 'rake', '~> 10.0'
21
18
  end
@@ -138,4 +138,10 @@ RSpec.describe RSpec::RequestDescriber do
138
138
  )
139
139
  end
140
140
  end
141
+
142
+ context 'when the test case is under the top-level describe unexpectedly' do
143
+ it 'handles the error' do
144
+ expect { subject }.to raise_error(RSpec::RequestDescriber::IncorrectDescribe)
145
+ end
146
+ end
141
147
  end
metadata CHANGED
@@ -1,51 +1,23 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-request_describer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-15 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.7'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.7'
27
- - !ruby/object:Gem::Dependency
28
- name: rake
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: '10.0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- description:
11
+ date: 2024-03-28 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
42
14
  email:
43
15
  - r7kamura@gmail.com
44
16
  executables: []
45
17
  extensions: []
46
18
  extra_rdoc_files: []
47
19
  files:
48
- - ".circleci/config.yml"
20
+ - ".github/workflows/test.yml"
49
21
  - ".gitignore"
50
22
  - ".rspec"
51
23
  - ".rubocop.yml"
@@ -64,7 +36,7 @@ homepage: https://github.com/r7kamura/rspec-request_describer
64
36
  licenses:
65
37
  - MIT
66
38
  metadata: {}
67
- post_install_message:
39
+ post_install_message:
68
40
  rdoc_options: []
69
41
  require_paths:
70
42
  - lib
@@ -79,8 +51,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
51
  - !ruby/object:Gem::Version
80
52
  version: '0'
81
53
  requirements: []
82
- rubygems_version: 3.0.3
83
- signing_key:
54
+ rubygems_version: 3.4.19
55
+ signing_key:
84
56
  specification_version: 4
85
57
  summary: An RSpec plugin to write self-documenting request-specs.
86
58
  test_files:
data/.circleci/config.yml DELETED
@@ -1,46 +0,0 @@
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