response_code_matchers 0.0.4 → 0.2.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: 53a4b159cf5c12f38193d963b5d20c3f3a9c1a11
4
- data.tar.gz: 506c56a352ef4b15511c3776478f2d2d51fba7a7
2
+ SHA256:
3
+ metadata.gz: bbb219ecf8e5bb234b68944356a82fd4e6a9ed160e06aa28ad8fee5f750507b3
4
+ data.tar.gz: 43ee6b654b6e6fc771ccd1fcad18bc18e824051704ed468769d39e4c7c62be2e
5
5
  SHA512:
6
- metadata.gz: 97002e3666789d2a8ff9ec70e3c5688684cda240ab3eb0e87fea16ac5e6b3a27d564793f3f851a9b930ff4936d3378b52956fe38dab942ccd8859e2f1cf2b71d
7
- data.tar.gz: 0fcefa8525c5d407246dae671de0d73c6fe61b4005bb4096842ce3620d23bea9176c7f91a700314da33824bf52d1006fd88907db8812b20c82505a09c1e140c4
6
+ metadata.gz: ddb0d38882b29adebfdfdaa53cf0f615cd187382628fd80e5796caabe4ea7611fa215508437fcd8000a707debd20317dfcbdf2d44db90001f70bc39cc61b612b
7
+ data.tar.gz: b3431282a1254fb33fcfd7d913585da607531f7d5736f7957854d1f4d0fda0aaf0dd399b8c2d3c42fd709ee248b6e87dd25b1fcef3d953f429c1466438f98b16
@@ -0,0 +1,23 @@
1
+ changelog:
2
+ categories:
3
+ - title: Added
4
+ labels:
5
+ - add
6
+ - title: Changed
7
+ labels:
8
+ - change
9
+ - title: Deprecated
10
+ labels:
11
+ - deprecate
12
+ - title: Fixed
13
+ labels:
14
+ - fix
15
+ - title: Removed
16
+ labels:
17
+ - remove
18
+ - title: Security
19
+ labels:
20
+ - security
21
+ - title: Others
22
+ labels:
23
+ - "*"
@@ -0,0 +1,37 @@
1
+ # This file is machine-generated by `gh actions-lock`.
2
+ # Do not edit by hand; run `gh actions-lock` to update.
3
+ # Docs: https://gh.io/actions-lockfile
4
+ version: 'v0.0.3'
5
+ workflows:
6
+ '.github/workflows/bump-request.yml':
7
+ - 'actions/checkout@v7.0.1'
8
+ - 'r7kamura/bump-request@v0.7.1'
9
+ - 'ruby/setup-ruby@v1.336.0'
10
+ '.github/workflows/ci.yml':
11
+ - 'actions/checkout@v7.0.1'
12
+ - 'ruby/setup-ruby@v1.336.0'
13
+ '.github/workflows/release.yml': []
14
+ dependencies:
15
+ 'actions/checkout@v7.0.1':
16
+ ref: 'v7.0.1'
17
+ commit: 'sha1-3d3c42e5aac5ba805825da76410c181273ba90b1'
18
+ owner_id: 44036562
19
+ repo_id: 197814629
20
+ 'actions/setup-node@v7.1.0':
21
+ ref: 'v7.1.0'
22
+ commit: 'sha1-949feb2413d6458794dcd2491c4babbbce0c15c1'
23
+ owner_id: 44036562
24
+ repo_id: 189476904
25
+ 'r7kamura/bump-request@v0.7.1':
26
+ ref: 'v0.7.1'
27
+ commit: 'sha1-b27937188d404bc0c2fd442403e6de1d20f9b349'
28
+ owner_id: 111689
29
+ repo_id: 533135195
30
+ uses:
31
+ - 'actions/checkout@v7.0.1'
32
+ - 'actions/setup-node@v7.1.0'
33
+ 'ruby/setup-ruby@v1.336.0':
34
+ ref: 'v1.336.0'
35
+ commit: 'sha1-de492cf36cbab201753d720ce4f4e336cd688c94'
36
+ owner_id: 210414
37
+ repo_id: 231208785
@@ -0,0 +1,26 @@
1
+ name: bump-request
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version:
7
+ description: Version to change to.
8
+ required: true
9
+ type: string
10
+
11
+ jobs:
12
+ run:
13
+ runs-on: ubuntu-latest
14
+ steps:
15
+ - uses: actions/checkout@v7.0.1
16
+ - name: Set up Ruby
17
+ uses: ruby/setup-ruby@v1.336.0
18
+ with:
19
+ ruby-version: 3.3
20
+ bundler-cache: true
21
+ - uses: r7kamura/bump-request@v0.7.1
22
+ with:
23
+ command: |
24
+ sed -i -r 's/([0-9]+\.[0-9]+\.[0-9]+)/${{ inputs.version }}/' lib/response_code_matchers/version.rb
25
+ bundle install
26
+ version: ${{ inputs.version }}
@@ -0,0 +1,24 @@
1
+ name: ci
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+ pull_request:
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+ name: Ruby ${{ matrix.ruby }}
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ ruby: ['3.3', '3.4', '4.0']
17
+ steps:
18
+ - uses: actions/checkout@v7.0.1
19
+ - name: Set up Ruby
20
+ uses: ruby/setup-ruby@v1.336.0
21
+ with:
22
+ ruby-version: ${{ matrix.ruby }}
23
+ bundler-cache: true
24
+ - run: bundle exec rspec
@@ -0,0 +1,11 @@
1
+ name: release
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ release:
10
+ uses: r7kamura/workflows/.github/workflows/gem-release.yml@main
11
+ if: github.repository_owner == 'r7kamura'
data/.gitignore CHANGED
@@ -4,6 +4,7 @@
4
4
  .config
5
5
  .yardoc
6
6
  Gemfile.lock
7
+ gemfiles/*.lock
7
8
  InstalledFiles
8
9
  _yardoc
9
10
  coverage
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in response_code_matchers.gemspec
4
4
  gemspec
5
+
6
+ gem 'rake'
7
+ gem 'rspec'
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # ResponseCodeMatchers
2
-
3
2
  Provide rspec matchers to match http response code.
4
- The receiver of this matcher should have `#code` or `#status` method which returns http status code.
3
+ The receiver of this matcher should have `#code` or `#status` method which returns http status code,
4
+ and `#header` and `#headers` methods.
5
5
 
6
6
  ## Installation
7
7
  ```
@@ -72,7 +72,7 @@ There are 2 advantages to use this gem.
72
72
  expected not_found? to return true, got false
73
73
 
74
74
  # with response_code_matchers.gem
75
- expected response code to be 404, but 400
75
+ expected response code to be 404, got 400
76
76
  ```
77
77
 
78
78
 
@@ -96,7 +96,6 @@ expected response code to be 404, but 400
96
96
  303: response.should be_see_other
97
97
  304: response.should be_not_modified
98
98
  305: response.should be_use_proxy
99
- 306: response.should be_reserved
100
99
  307: response.should be_temporary_redirect
101
100
  400: response.should be_bad_request
102
101
  401: response.should be_unauthorized
@@ -111,10 +110,10 @@ expected response code to be 404, but 400
111
110
  410: response.should be_gone
112
111
  411: response.should be_length_required
113
112
  412: response.should be_precondition_failed
114
- 413: response.should be_request_entity_too_large
115
- 414: response.should be_request_uri_too_long
113
+ 413: response.should be_payload_too_large
114
+ 414: response.should be_uri_too_long
116
115
  415: response.should be_unsupported_media_type
117
- 416: response.should be_requested_range_not_satisfiable
116
+ 416: response.should be_range_not_satisfiable
118
117
  417: response.should be_expectation_failed
119
118
  418: response.should be_im_a_teapot
120
119
  422: response.should be_unprocessable_entity
@@ -1,3 +1,3 @@
1
1
  module ResponseCodeMatchers
2
- VERSION = "0.0.4"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -14,21 +14,39 @@ module ResponseCodeMatchers
14
14
  end
15
15
  end
16
16
 
17
+ # Compatibility matchers for status names that were renamed or removed in Rack 3.1.
18
+ # Each is defined only when Rack no longer provides a matcher with that name.
19
+ LEGACY_MATCHERS = {
20
+ "payload_too_large" => [413, "content_too_large"],
21
+ "unprocessable_entity" => [422, "unprocessable_content"],
22
+ "not_extended" => [510, "not_extended"],
23
+ }.freeze
24
+
25
+ LEGACY_MATCHERS.each do |legacy_name, (code, name)|
26
+ next if method_defined?("be_#{legacy_name}")
27
+
28
+ define_method("be_#{legacy_name}") do
29
+ ResponseCodeMatcher.new(code.to_s, name)
30
+ end
31
+ end
32
+
17
33
  class ResponseCodeMatcher
18
34
  def initialize(expected, name)
19
35
  @expected = expected
20
36
  @name = name
21
37
  end
22
38
 
23
- def matches?(response)
24
- if @valid = response.respond_to?(:code)
25
- @actual = response.code
39
+ def matches?(obj)
40
+ return obj.__send__(method_name) unless obj.respond_to?(:header) && obj.respond_to?(:body)
41
+
42
+ if @valid = obj.respond_to?(:code)
43
+ @actual = obj.code
26
44
  @actual == @expected
27
- elsif @valid = response.respond_to?(:status)
28
- @actual = response.status.to_s
45
+ elsif @valid = obj.respond_to?(:status)
46
+ @actual = obj.status.to_s
29
47
  @actual == @expected
30
48
  else
31
- response.__send__(method_name)
49
+ obj.__send__(method_name)
32
50
  end
33
51
  end
34
52
 
@@ -38,7 +56,7 @@ module ResponseCodeMatchers
38
56
 
39
57
  def failure_message
40
58
  if @valid
41
- "expected response code to be #@expected, but #@actual"
59
+ "expected response code to be #@expected, got #@actual"
42
60
  else
43
61
  "expected #{method_name} to return true, got false"
44
62
  end
@@ -46,7 +64,7 @@ module ResponseCodeMatchers
46
64
 
47
65
  def failure_message_when_negated
48
66
  if @valid
49
- "expected response code not to be #@expected, but #@actual"
67
+ "expected response code not to be #@expected, got #@actual"
50
68
  else
51
69
  "expected #{method_name} to return false, got true"
52
70
  end
@@ -11,6 +11,11 @@ Gem::Specification.new do |gem|
11
11
  gem.description = "Provide rspec matchers to match http response code"
12
12
  gem.summary = "RSpec utility matchers for http response code"
13
13
  gem.homepage = "https://github.com/r7kamura/response_code_matchers"
14
+ gem.license = "MIT"
15
+ gem.required_ruby_version = ">= 3.3"
16
+
17
+ gem.metadata["rubygems_mfa_required"] = "true"
18
+ gem.metadata["source_code_uri"] = gem.homepage
14
19
 
15
20
  gem.files = `git ls-files`.split($/)
16
21
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
@@ -18,5 +23,4 @@ Gem::Specification.new do |gem|
18
23
  gem.require_paths = ["lib"]
19
24
 
20
25
  gem.add_dependency "rack"
21
- gem.add_development_dependency "rspec"
22
26
  end
@@ -20,7 +20,6 @@ describe ResponseCodeMatchers do
20
20
  303 be_see_other
21
21
  304 be_not_modified
22
22
  305 be_use_proxy
23
- 306 be_reserved
24
23
  307 be_temporary_redirect
25
24
  400 be_bad_request
26
25
  401 be_unauthorized
@@ -35,12 +34,12 @@ describe ResponseCodeMatchers do
35
34
  410 be_gone
36
35
  411 be_length_required
37
36
  412 be_precondition_failed
38
- 413 be_request_entity_too_large
39
- 414 be_request_uri_too_long
37
+ 413 be_content_too_large
38
+ 414 be_uri_too_long
40
39
  415 be_unsupported_media_type
41
- 416 be_requested_range_not_satisfiable
40
+ 416 be_range_not_satisfiable
42
41
  417 be_expectation_failed
43
- 422 be_unprocessable_entity
42
+ 422 be_unprocessable_content
44
43
  423 be_locked
45
44
  424 be_failed_dependency
46
45
  426 be_upgrade_required
@@ -52,11 +51,10 @@ describe ResponseCodeMatchers do
52
51
  505 be_http_version_not_supported
53
52
  506 be_variant_also_negotiates
54
53
  507 be_insufficient_storage
55
- 510 be_not_extended
56
54
  ].each_slice(2) do |code, matcher|
57
55
  describe "##{matcher}" do
58
56
  let(:response) do
59
- double(:code => code)
57
+ double(:code => code, :header => [], :body => "")
60
58
  end
61
59
 
62
60
  it "matches http response code #{code}" do
@@ -67,7 +65,7 @@ describe ResponseCodeMatchers do
67
65
 
68
66
  context "when receiver responds to #status" do
69
67
  let(:receiver) do
70
- double(:status => 406)
68
+ double(:status => 406, :header => [], :body => "")
71
69
  end
72
70
 
73
71
  it "calls original receiver.xxx?" do
@@ -77,7 +75,7 @@ describe ResponseCodeMatchers do
77
75
 
78
76
  context "when receiver does not have a method #code" do
79
77
  let(:receiver) do
80
- double(:accepted? => true)
78
+ double(:accepted? => true, :header => [], :body => "")
81
79
  end
82
80
 
83
81
  it "calls original receiver.xxx?" do
data/spec/spec_helper.rb CHANGED
@@ -4,7 +4,7 @@ RSpec.configure do |config|
4
4
  if config.respond_to?(:raise_errors_for_deprecations!)
5
5
  config.raise_errors_for_deprecations!
6
6
  end
7
- config.treat_symbols_as_metadata_keys_with_true_values = true
7
+ config.treat_symbols_as_metadata_keys_with_true_values = true if RSpec::Core::Version::STRING < '3'
8
8
  config.run_all_when_everything_filtered = true
9
9
  config.filter_run :focus
10
10
 
metadata CHANGED
@@ -1,41 +1,26 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: response_code_matchers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo NAKAMURA
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2014-03-12 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: rack
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
- - - '>='
16
+ - - ">="
18
17
  - !ruby/object:Gem::Version
19
18
  version: '0'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: '0'
27
- - !ruby/object:Gem::Dependency
28
- name: rspec
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - '>='
32
- - !ruby/object:Gem::Version
33
- version: '0'
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - '>='
23
+ - - ">="
39
24
  - !ruby/object:Gem::Version
40
25
  version: '0'
41
26
  description: Provide rspec matchers to match http response code
@@ -45,41 +30,42 @@ executables: []
45
30
  extensions: []
46
31
  extra_rdoc_files: []
47
32
  files:
48
- - .gitignore
49
- - .travis.yml
33
+ - ".github/release.yml"
34
+ - ".github/workflows/actions.lock"
35
+ - ".github/workflows/bump-request.yml"
36
+ - ".github/workflows/ci.yml"
37
+ - ".github/workflows/release.yml"
38
+ - ".gitignore"
50
39
  - Gemfile
51
40
  - LICENSE.txt
52
41
  - README.md
53
42
  - Rakefile
54
- - gemfiles/rspec-2.14.gemfile
55
- - gemfiles/rspec-2.99.gemfile
56
- - gemfiles/rspec-3.0.gemfile
57
43
  - lib/response_code_matchers.rb
58
44
  - lib/response_code_matchers/version.rb
59
45
  - response_code_matchers.gemspec
60
46
  - spec/response_code_matchers_spec.rb
61
47
  - spec/spec_helper.rb
62
48
  homepage: https://github.com/r7kamura/response_code_matchers
63
- licenses: []
64
- metadata: {}
65
- post_install_message:
49
+ licenses:
50
+ - MIT
51
+ metadata:
52
+ rubygems_mfa_required: 'true'
53
+ source_code_uri: https://github.com/r7kamura/response_code_matchers
66
54
  rdoc_options: []
67
55
  require_paths:
68
56
  - lib
69
57
  required_ruby_version: !ruby/object:Gem::Requirement
70
58
  requirements:
71
- - - '>='
59
+ - - ">="
72
60
  - !ruby/object:Gem::Version
73
- version: '0'
61
+ version: '3.3'
74
62
  required_rubygems_version: !ruby/object:Gem::Requirement
75
63
  requirements:
76
- - - '>='
64
+ - - ">="
77
65
  - !ruby/object:Gem::Version
78
66
  version: '0'
79
67
  requirements: []
80
- rubyforge_project:
81
- rubygems_version: 2.0.3
82
- signing_key:
68
+ rubygems_version: 4.0.20
83
69
  specification_version: 4
84
70
  summary: RSpec utility matchers for http response code
85
71
  test_files:
data/.travis.yml DELETED
@@ -1,7 +0,0 @@
1
- language: ruby
2
- gemfile:
3
- - gemfiles/rspec-2.14.gemfile
4
- - gemfiles/rspec-3.0.gemfile
5
- - gemfiles/rspec-2.99.gemfile
6
-
7
- script: 'bundle exec rspec'
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rspec', '~> 2.14.0'
4
-
5
- gemspec path: '../'
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rspec', '~> 2.99.0.beta1'
4
-
5
- gemspec path: '../'
@@ -1,5 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gem 'rspec', '~> 3.0.0.beta1'
4
-
5
- gemspec path: '../'