crapi 1.0.0 → 1.0.1

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.
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: crapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nestor Custodio
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2023-01-02 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: activesupport
@@ -16,34 +15,34 @@ dependencies:
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: '6.0'
18
+ version: 6.1.0
20
19
  - - "<"
21
20
  - !ruby/object:Gem::Version
22
- version: '7.1'
21
+ version: '9'
23
22
  type: :runtime
24
23
  prerelease: false
25
24
  version_requirements: !ruby/object:Gem::Requirement
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- version: '6.0'
28
+ version: 6.1.0
30
29
  - - "<"
31
30
  - !ruby/object:Gem::Version
32
- version: '7.1'
31
+ version: '9'
33
32
  - !ruby/object:Gem::Dependency
34
33
  name: bundler
35
34
  requirement: !ruby/object:Gem::Requirement
36
35
  requirements:
37
36
  - - "~>"
38
37
  - !ruby/object:Gem::Version
39
- version: '2'
38
+ version: '4'
40
39
  type: :development
41
40
  prerelease: false
42
41
  version_requirements: !ruby/object:Gem::Requirement
43
42
  requirements:
44
43
  - - "~>"
45
44
  - !ruby/object:Gem::Version
46
- version: '2'
45
+ version: '4'
47
46
  - !ruby/object:Gem::Dependency
48
47
  name: rspec
49
48
  requirement: !ruby/object:Gem::Requirement
@@ -114,9 +113,8 @@ dependencies:
114
113
  - - ">="
115
114
  - !ruby/object:Gem::Version
116
115
  version: '0'
117
- description:
118
116
  email:
119
- - sakimorix@gmail.com
117
+ - nestor@custodio.org
120
118
  executables: []
121
119
  extensions: []
122
120
  extra_rdoc_files: []
@@ -161,17 +159,11 @@ files:
161
159
  - lib/crapi/errors.rb
162
160
  - lib/crapi/proxy.rb
163
161
  - lib/crapi/version.rb
164
- - spec/crapi_client_spec.rb
165
- - spec/crapi_errors_spec.rb
166
- - spec/crapi_proxy_spec.rb
167
- - spec/crapi_spec.rb
168
- - spec/spec_helper.rb
169
162
  homepage: https://github.com/nestor-custodio/crapi
170
163
  licenses:
171
164
  - MIT
172
165
  metadata:
173
166
  rubygems_mfa_required: 'true'
174
- post_install_message:
175
167
  rdoc_options: []
176
168
  require_paths:
177
169
  - lib
@@ -179,19 +171,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
179
171
  requirements:
180
172
  - - ">="
181
173
  - !ruby/object:Gem::Version
182
- version: '3.0'
183
- - - "<"
184
- - !ruby/object:Gem::Version
185
- version: '3.2'
174
+ version: '3'
186
175
  required_rubygems_version: !ruby/object:Gem::Requirement
187
176
  requirements:
188
177
  - - ">="
189
178
  - !ruby/object:Gem::Version
190
179
  version: '0'
191
180
  requirements: []
192
- rubygems_version: 3.2.33
193
- signing_key:
181
+ rubygems_version: 3.6.9
194
182
  specification_version: 4
195
- summary: A simple API client with built-in segment/header proxy support. "... It could
196
- be better." ™️
183
+ summary: A simple API client with built-in segment/header proxy support.
197
184
  test_files: []
@@ -1,121 +0,0 @@
1
- RSpec.describe CrAPI::Client do
2
- subject do
3
- client = CrAPI::Client.new API_DOMAIN
4
- client.default_headers.merge! client: '1'
5
-
6
- client
7
- end
8
-
9
- let(:payload_hash) { { string_value: 'abc', numeric_value: 123, a_list: %w[one two three] } }
10
- let(:payload_json) { JSON.generate payload_hash }
11
-
12
- let(:empty_response_spec) { { status: 204, body: nil } }
13
- let(:payload_response_spec) { { status: 200, headers: { 'content-type': 'application/json' }, body: payload_json } }
14
-
15
- def stub(method, uri, headers: {})
16
- stub_request(method, "#{API_DOMAIN}/#{uri.delete_prefix '/'}").with(headers: full_request_headers(headers))
17
- end
18
-
19
- def full_request_headers(custom_values = {})
20
- subject.default_headers.merge custom_values
21
- end
22
-
23
- def crud_header_test(method, with_header:)
24
- uri = '/resource/1'
25
-
26
- if with_header
27
- unique_header = { 'X-Test' => SecureRandom.hex }
28
- stub(method, uri, headers: unique_header).to_return(status: 204)
29
- expect { subject.send(method, uri, headers: unique_header) }.not_to raise_error
30
- else
31
- stub(method, uri).to_return(status: 204)
32
- expect { subject.send(method, uri) }.not_to raise_error
33
- end
34
- end
35
-
36
- def crud_parsing_test(method, with_body:)
37
- uri = '/resource/1'
38
-
39
- if with_body
40
- stub(method, uri).to_return(payload_response_spec)
41
- expect(subject.send(method, uri)).to eq(payload_hash)
42
- else
43
- stub(method, uri).to_return(empty_response_spec)
44
- expect(subject.send(method, uri)).to eq(nil)
45
- end
46
- end
47
-
48
- # ---
49
-
50
- describe '#new_proxy' do
51
- it('is defined') { is_expected.to respond_to :new_proxy }
52
- it('returns a CrAPI::Proxy') { expect(subject.new_proxy).to be_a(CrAPI::Proxy) }
53
- end
54
-
55
- # ---
56
-
57
- describe '#delete' do
58
- let(:method) { :delete }
59
-
60
- describe 'sends correctly' do
61
- it('w/ headers') { crud_header_test(method, with_header: true) }
62
- it('w/o headers') { crud_header_test(method, with_header: false) }
63
- end
64
- end
65
-
66
- describe '#get' do
67
- let(:method) { :get }
68
-
69
- describe 'sends correctly' do
70
- it('w/ headers') { crud_header_test(method, with_header: true) }
71
- it('w/o headers') { crud_header_test(method, with_header: false) }
72
- end
73
-
74
- describe 'parses responses' do
75
- it('w/ response body') { crud_parsing_test(method, with_body: true) }
76
- it('w/o response body') { crud_parsing_test(method, with_body: false) }
77
- end
78
- end
79
-
80
- describe '#patch' do
81
- let(:method) { :patch }
82
-
83
- describe 'sends correctly' do
84
- it('w/ headers') { crud_header_test(method, with_header: true) }
85
- it('w/o headers') { crud_header_test(method, with_header: false) }
86
- end
87
-
88
- describe 'parses responses' do
89
- it('w/ response body') { crud_parsing_test(method, with_body: true) }
90
- it('w/o response body') { crud_parsing_test(method, with_body: false) }
91
- end
92
- end
93
-
94
- describe '#post' do
95
- let(:method) { :post }
96
-
97
- describe 'sends correctly' do
98
- it('w/ headers') { crud_header_test(method, with_header: true) }
99
- it('w/o headers') { crud_header_test(method, with_header: false) }
100
- end
101
-
102
- describe 'parses responses' do
103
- it('w/ response body') { crud_parsing_test(method, with_body: true) }
104
- it('w/o response body') { crud_parsing_test(method, with_body: false) }
105
- end
106
- end
107
-
108
- describe '#put' do
109
- let(:method) { :put }
110
-
111
- describe 'sends correctly' do
112
- it('w/ headers') { crud_header_test(method, with_header: true) }
113
- it('w/o headers') { crud_header_test(method, with_header: false) }
114
- end
115
-
116
- describe 'parses responses' do
117
- it('w/ response body') { crud_parsing_test(method, with_body: true) }
118
- it('w/o response body') { crud_parsing_test(method, with_body: false) }
119
- end
120
- end
121
- end
@@ -1,17 +0,0 @@
1
- RSpec.describe CrAPI::Error do
2
- it 'is defined' do
3
- expect(defined? CrAPI::Error).not_to be(nil)
4
- end
5
-
6
- describe 'is subclassed as ...' do
7
- it 'CrAPI::ArgumentError' do
8
- expect(defined? CrAPI::ArgumentError).not_to be(nil)
9
- expect(CrAPI::ArgumentError.superclass).to be(CrAPI::Error)
10
- end
11
-
12
- it 'CrAPI::BadHttpResponseError' do
13
- expect(defined? CrAPI::BadHttpResponseError).not_to be(nil)
14
- expect(CrAPI::BadHttpResponseError.superclass).to be(CrAPI::Error)
15
- end
16
- end
17
- end
@@ -1,121 +0,0 @@
1
- RSpec.describe CrAPI::Proxy do
2
- subject do
3
- client = CrAPI::Client.new API_DOMAIN
4
- client.default_headers.merge! client: '1'
5
-
6
- client.new_proxy '/proxy_path', headers: { client: '0', proxy: '1' }
7
- end
8
-
9
- let(:payload_hash) { { string_value: 'abc', numeric_value: 123, a_list: %w[one two three] } }
10
- let(:payload_json) { JSON.generate payload_hash }
11
-
12
- let(:empty_response_spec) { { status: 204, body: nil } }
13
- let(:payload_response_spec) { { status: 200, headers: { 'content-type': 'application/json' }, body: payload_json } }
14
-
15
- def stub(method, uri, headers: {})
16
- stub_request(method, "#{API_DOMAIN}/proxy_path/#{uri.delete_prefix '/'}").with(headers: full_request_headers(headers))
17
- end
18
-
19
- def full_request_headers(custom_values = {})
20
- subject.default_headers.merge custom_values
21
- end
22
-
23
- def crud_header_test(method, with_header:)
24
- uri = '/resource/1'
25
-
26
- if with_header
27
- unique_header = { 'X-Test' => SecureRandom.hex }
28
- stub(method, uri, headers: unique_header).to_return(status: 204)
29
- expect { subject.send(method, uri, headers: unique_header) }.not_to raise_error
30
- else
31
- stub(method, uri).to_return(status: 204)
32
- expect { subject.send(method, uri) }.not_to raise_error
33
- end
34
- end
35
-
36
- def crud_parsing_test(method, with_body:)
37
- uri = '/resource/1'
38
-
39
- if with_body
40
- stub(method, uri).to_return(payload_response_spec)
41
- expect(subject.send(method, uri)).to eq(payload_hash)
42
- else
43
- stub(method, uri).to_return(empty_response_spec)
44
- expect(subject.send(method, uri)).to eq(nil)
45
- end
46
- end
47
-
48
- # ---
49
-
50
- describe '#new_proxy' do
51
- it('is defined') { is_expected.to respond_to :new_proxy }
52
- it('returns a CrAPI::Proxy') { expect(subject.new_proxy).to be_a(CrAPI::Proxy) }
53
- end
54
-
55
- # ---
56
-
57
- describe '#delete' do
58
- let(:method) { :delete }
59
-
60
- describe 'sends correctly' do
61
- it('w/ headers') { crud_header_test(method, with_header: true) }
62
- it('w/o headers') { crud_header_test(method, with_header: false) }
63
- end
64
- end
65
-
66
- describe '#get' do
67
- let(:method) { :get }
68
-
69
- describe 'sends correctly' do
70
- it('w/ headers') { crud_header_test(method, with_header: true) }
71
- it('w/o headers') { crud_header_test(method, with_header: false) }
72
- end
73
-
74
- describe 'parses responses' do
75
- it('w/ response body') { crud_parsing_test(method, with_body: true) }
76
- it('w/o response body') { crud_parsing_test(method, with_body: false) }
77
- end
78
- end
79
-
80
- describe '#patch' do
81
- let(:method) { :patch }
82
-
83
- describe 'sends correctly' do
84
- it('w/ headers') { crud_header_test(method, with_header: true) }
85
- it('w/o headers') { crud_header_test(method, with_header: false) }
86
- end
87
-
88
- describe 'parses responses' do
89
- it('w/ response body') { crud_parsing_test(method, with_body: true) }
90
- it('w/o response body') { crud_parsing_test(method, with_body: false) }
91
- end
92
- end
93
-
94
- describe '#post' do
95
- let(:method) { :post }
96
-
97
- describe 'sends correctly' do
98
- it('w/ headers') { crud_header_test(method, with_header: true) }
99
- it('w/o headers') { crud_header_test(method, with_header: false) }
100
- end
101
-
102
- describe 'parses responses' do
103
- it('w/ response body') { crud_parsing_test(method, with_body: true) }
104
- it('w/o response body') { crud_parsing_test(method, with_body: false) }
105
- end
106
- end
107
-
108
- describe '#put' do
109
- let(:method) { :put }
110
-
111
- describe 'sends correctly' do
112
- it('w/ headers') { crud_header_test(method, with_header: true) }
113
- it('w/o headers') { crud_header_test(method, with_header: false) }
114
- end
115
-
116
- describe 'parses responses' do
117
- it('w/ response body') { crud_parsing_test(method, with_body: true) }
118
- it('w/o response body') { crud_parsing_test(method, with_body: false) }
119
- end
120
- end
121
- end
data/spec/crapi_spec.rb DELETED
@@ -1,5 +0,0 @@
1
- RSpec.describe CrAPI do
2
- it 'has a version number' do
3
- expect(CrAPI::VERSION).not_to be nil
4
- end
5
- end
data/spec/spec_helper.rb DELETED
@@ -1,19 +0,0 @@
1
- require 'bundler/setup'
2
- require 'crapi'
3
- require 'json'
4
- require 'securerandom'
5
- require 'webmock/rspec'
6
-
7
- RSpec.configure do |config|
8
- # Enable flags like --only-failures and --next-failure
9
- config.example_status_persistence_file_path = '.rspec_status'
10
-
11
- # Disable RSpec exposing methods globally on `Module` and `main`
12
- config.disable_monkey_patching!
13
-
14
- config.expect_with :rspec do |c|
15
- c.syntax = :expect
16
- end
17
-
18
- API_DOMAIN = 'https://fake-domain.lol'.freeze
19
- end