response_code_matchers 0.0.4 → 0.1.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 +4 -4
- data/.gitignore +1 -0
- data/CHANGELOG.md +14 -0
- data/README.md +6 -7
- data/lib/response_code_matchers.rb +8 -6
- data/lib/response_code_matchers/version.rb +1 -1
- data/spec/response_code_matchers_spec.rb +6 -7
- data/spec/spec_helper.rb +1 -1
- metadata +13 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b78ac4f439eb1d0ed6fba9883a0db62492dfaea
|
4
|
+
data.tar.gz: bd6caaced45e902dcfe04c9a0f76114c4a13b274
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9319d0bc63e4154724305fd7153c6282b2fdd1bc54d806214300a8e674f073873aa844bec86fc3e93f83a79583d383c615b28a6da2b96d562548eeb8f110d1b
|
7
|
+
data.tar.gz: 0895baa44cc05fe24d55fbabdbe8a82b1884eaf0a36bf07723c96ea514f6ef3ddeed78d47b0cd6d6249bf049e62c98a2143f8a008fb625f6c0b0141b1c553b9c
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
# ResponseCodeMatchers
|
2
|
-
|
1
|
+
# ResponseCodeMatchers [](https://travis-ci.org/r7kamura/response_code_matchers)
|
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
|
```
|
@@ -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
|
115
|
-
414: response.should
|
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
|
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
|
@@ -20,15 +20,17 @@ module ResponseCodeMatchers
|
|
20
20
|
@name = name
|
21
21
|
end
|
22
22
|
|
23
|
-
def matches?(
|
24
|
-
|
25
|
-
|
23
|
+
def matches?(obj)
|
24
|
+
return obj.__send__(method_name) unless obj.respond_to?(:header) && obj.respond_to?(:body)
|
25
|
+
|
26
|
+
if @valid = obj.respond_to?(:code)
|
27
|
+
@actual = obj.code
|
26
28
|
@actual == @expected
|
27
|
-
elsif @valid =
|
28
|
-
@actual =
|
29
|
+
elsif @valid = obj.respond_to?(:status)
|
30
|
+
@actual = obj.status.to_s
|
29
31
|
@actual == @expected
|
30
32
|
else
|
31
|
-
|
33
|
+
obj.__send__(method_name)
|
32
34
|
end
|
33
35
|
end
|
34
36
|
|
@@ -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,10 +34,10 @@ describe ResponseCodeMatchers do
|
|
35
34
|
410 be_gone
|
36
35
|
411 be_length_required
|
37
36
|
412 be_precondition_failed
|
38
|
-
413
|
39
|
-
414
|
37
|
+
413 be_payload_too_large
|
38
|
+
414 be_uri_too_long
|
40
39
|
415 be_unsupported_media_type
|
41
|
-
416
|
40
|
+
416 be_range_not_satisfiable
|
42
41
|
417 be_expectation_failed
|
43
42
|
422 be_unprocessable_entity
|
44
43
|
423 be_locked
|
@@ -56,7 +55,7 @@ describe ResponseCodeMatchers do
|
|
56
55
|
].each_slice(2) do |code, matcher|
|
57
56
|
describe "##{matcher}" do
|
58
57
|
let(:response) do
|
59
|
-
double(:code => code)
|
58
|
+
double(:code => code, :header => [], :body => "")
|
60
59
|
end
|
61
60
|
|
62
61
|
it "matches http response code #{code}" do
|
@@ -67,7 +66,7 @@ describe ResponseCodeMatchers do
|
|
67
66
|
|
68
67
|
context "when receiver responds to #status" do
|
69
68
|
let(:receiver) do
|
70
|
-
double(:status => 406)
|
69
|
+
double(:status => 406, :header => [], :body => "")
|
71
70
|
end
|
72
71
|
|
73
72
|
it "calls original receiver.xxx?" do
|
@@ -77,7 +76,7 @@ describe ResponseCodeMatchers do
|
|
77
76
|
|
78
77
|
context "when receiver does not have a method #code" do
|
79
78
|
let(:receiver) do
|
80
|
-
double(:accepted? => true)
|
79
|
+
double(:accepted? => true, :header => [], :body => "")
|
81
80
|
end
|
82
81
|
|
83
82
|
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,41 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: response_code_matchers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.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:
|
11
|
+
date: 2015-02-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
description: Provide rspec matchers to match http response code
|
@@ -45,8 +45,9 @@ executables: []
|
|
45
45
|
extensions: []
|
46
46
|
extra_rdoc_files: []
|
47
47
|
files:
|
48
|
-
- .gitignore
|
49
|
-
- .travis.yml
|
48
|
+
- ".gitignore"
|
49
|
+
- ".travis.yml"
|
50
|
+
- CHANGELOG.md
|
50
51
|
- Gemfile
|
51
52
|
- LICENSE.txt
|
52
53
|
- README.md
|
@@ -68,20 +69,21 @@ require_paths:
|
|
68
69
|
- lib
|
69
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
71
|
requirements:
|
71
|
-
- -
|
72
|
+
- - ">="
|
72
73
|
- !ruby/object:Gem::Version
|
73
74
|
version: '0'
|
74
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
75
76
|
requirements:
|
76
|
-
- -
|
77
|
+
- - ">="
|
77
78
|
- !ruby/object:Gem::Version
|
78
79
|
version: '0'
|
79
80
|
requirements: []
|
80
81
|
rubyforge_project:
|
81
|
-
rubygems_version: 2.
|
82
|
+
rubygems_version: 2.4.5
|
82
83
|
signing_key:
|
83
84
|
specification_version: 4
|
84
85
|
summary: RSpec utility matchers for http response code
|
85
86
|
test_files:
|
86
87
|
- spec/response_code_matchers_spec.rb
|
87
88
|
- spec/spec_helper.rb
|
89
|
+
has_rdoc:
|