webmock-symbol-http-status 0.1.0 → 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 +4 -4
- data/.circleci/config.yml +20 -4
- data/README.md +3 -0
- data/lib/symbol_http_status_able.rb +37 -0
- data/lib/webmock_symbol_http_status.rb +2 -15
- data/webmock-symbol-http-status.gemspec +1 -1
- metadata +3 -3
- data/lib/numeric_status.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b0dd100f0f4d025357cfbc74ec7afa870690797
|
4
|
+
data.tar.gz: 2dce4bb2a69318f1b349572ee93161df49e48040
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ec7068d1ad8d0f74e5dc84cc50795a8649e3e9c7c629cce6b66743e80b5eb83f2d3d8828b607c510be173cb09ae362629719533647dea46f523609cb315293fd
|
7
|
+
data.tar.gz: 7a8e52e2eae037bb5c8549dd1f050a0e9ddd25ed9386d231ca168dc08d1ecc9460247abca6d648c7a73f7693b5d1a6a985c0f26d025a3e77d1c6f05f9943f827
|
data/.circleci/config.yml
CHANGED
@@ -1,12 +1,28 @@
|
|
1
1
|
version: 2
|
2
2
|
jobs:
|
3
|
-
|
3
|
+
test_2_3:
|
4
4
|
docker:
|
5
|
-
- image: circleci/ruby:2.
|
5
|
+
- image: circleci/ruby:2.3.5
|
6
6
|
steps:
|
7
7
|
- checkout
|
8
|
+
- run: bundle install
|
9
|
+
- run: bundle exec rake spec
|
8
10
|
|
11
|
+
test_2_4:
|
12
|
+
docker:
|
13
|
+
- image: circleci/ruby:2.4.2
|
14
|
+
steps:
|
15
|
+
- checkout
|
9
16
|
- run: bundle install
|
17
|
+
- run: bundle exec rake spec
|
18
|
+
|
19
|
+
workflows:
|
20
|
+
version: 2
|
21
|
+
test_multi_ruby_version:
|
22
|
+
jobs:
|
23
|
+
- test_2_3
|
24
|
+
- test_2_4
|
10
25
|
|
11
|
-
|
12
|
-
|
26
|
+
notify:
|
27
|
+
webhooks:
|
28
|
+
- url: https://idobata.io/hook/circle_ci/52bbf489-8c7a-44f0-a702-59b5a1243c0f
|
data/README.md
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'webmock/util/hash_keys_stringifier'
|
2
|
+
require 'webmock/util/hash_validator'
|
3
|
+
require 'webmock/util/headers'
|
4
|
+
|
5
|
+
require 'rack'
|
6
|
+
|
7
|
+
module SymbolHttpStatusAble
|
8
|
+
def options=(options)
|
9
|
+
options = WebMock::Util::HashKeysStringifier.stringify_keys!(options)
|
10
|
+
WebMock::HashValidator.new(options).validate_keys('headers', 'status', 'body', 'exception', 'should_timeout')
|
11
|
+
self.headers = options['headers']
|
12
|
+
self.status = convert_numeric_status(options['status'])
|
13
|
+
self.body = options['body']
|
14
|
+
self.exception = options['exception']
|
15
|
+
@should_timeout = options['should_timeout']
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def convert_numeric_status(response)
|
21
|
+
if response.is_a?(Array)
|
22
|
+
[numeric_status(response[0]), response[1]]
|
23
|
+
elsif response.is_a?(Proc)
|
24
|
+
response
|
25
|
+
else
|
26
|
+
numeric_status(response)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def numeric_status(status)
|
31
|
+
if status.is_a?(Integer)
|
32
|
+
status
|
33
|
+
else
|
34
|
+
Rack::Utils::SYMBOL_TO_STATUS_CODE[status]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -1,22 +1,9 @@
|
|
1
|
-
require 'webmock/util/hash_keys_stringifier'
|
2
|
-
require 'webmock/util/hash_validator'
|
3
|
-
require 'webmock/util/headers'
|
4
|
-
|
5
1
|
require 'webmock/response'
|
6
2
|
|
7
|
-
require '
|
3
|
+
require 'symbol_http_status_able'
|
8
4
|
|
9
|
-
# Open class
|
10
5
|
module WebMock
|
11
6
|
class Response
|
12
|
-
|
13
|
-
options = WebMock::Util::HashKeysStringifier.stringify_keys!(options)
|
14
|
-
HashValidator.new(options).validate_keys('headers', 'status', 'body', 'exception', 'should_timeout')
|
15
|
-
self.headers = options['headers']
|
16
|
-
self.status = NumericStatus.new(options['status']).response
|
17
|
-
self.body = options['body']
|
18
|
-
self.exception = options['exception']
|
19
|
-
@should_timeout = options['should_timeout']
|
20
|
-
end
|
7
|
+
prepend SymbolHttpStatusAble
|
21
8
|
end
|
22
9
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: webmock-symbol-http-status
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- taki3
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webmock
|
@@ -109,7 +109,7 @@ files:
|
|
109
109
|
- LICENSE.txt
|
110
110
|
- README.md
|
111
111
|
- Rakefile
|
112
|
-
- lib/
|
112
|
+
- lib/symbol_http_status_able.rb
|
113
113
|
- lib/webmock_symbol_http_status.rb
|
114
114
|
- webmock-symbol-http-status.gemspec
|
115
115
|
homepage: https://github.com/ayindi/webmock-symbol-http-status
|
data/lib/numeric_status.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'rack'
|
2
|
-
|
3
|
-
class NumericStatus
|
4
|
-
def initialize(response)
|
5
|
-
if response.is_a?(Array)
|
6
|
-
@status = numeric_status(response[0])
|
7
|
-
@body = response[1]
|
8
|
-
elsif response.is_a?(Proc)
|
9
|
-
@proc = response
|
10
|
-
else
|
11
|
-
@status = numeric_status(response)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def response
|
16
|
-
if instance_variable_defined?(:@body)
|
17
|
-
[@status, @body]
|
18
|
-
elsif instance_variable_defined?(:@proc)
|
19
|
-
@proc
|
20
|
-
else
|
21
|
-
@status
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def numeric_status(status)
|
28
|
-
if status.is_a?(Integer)
|
29
|
-
status
|
30
|
-
else
|
31
|
-
Rack::Utils::SYMBOL_TO_STATUS_CODE[status]
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|