esa 1.18.0 → 2.0.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/CHANGELOG.md +28 -0
- data/esa.gemspec +6 -4
- data/lib/esa/api_methods.rb +3 -2
- data/lib/esa/version.rb +1 -1
- data/lib/esa.rb +2 -1
- metadata +29 -30
- data/.github/workflows/build.yml +0 -26
- data/.gitignore +0 -14
- data/.rspec +0 -3
- data/spec/esa/client_spec.rb +0 -104
- data/spec/esa/response_spec.rb +0 -42
- data/spec/spec_helper.rb +0 -27
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 529c47371a5a846f3a42ae1f942986f668d409050b876bc56625f95e6f6348ac
|
|
4
|
+
data.tar.gz: c83a9ddbb2c04f12a9af4dce93d4a13f7edd7c866b63f2cc05acd204df32e2c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 39fa6f42647662a1b55d1789201742cd6eef9fe3cc0527dffc5cfcfcd6e4a8976ed88a52a2bac3c1a1a26624752e5a01b08e5929ed2306a8fba05b15a2757c8f
|
|
7
|
+
data.tar.gz: afeeca20b238cfe254aae75f6c5e732422855403ad85802f0c145f6ebde2e6461059740b19af419401297a20d4899799b27b1c5898984c92ed95262536206535
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
nothing
|
|
4
4
|
|
|
5
|
+
## 2.0.0 (2023-04-06)
|
|
6
|
+
|
|
7
|
+
- :warning: breaking: [Support Faraday 2.0.1+ by fukayatsu · Pull Request #58 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/58)
|
|
8
|
+
- Drop support for Ruby < 2.7.0
|
|
9
|
+
- Drop support for Faraday < 2.0.1
|
|
10
|
+
|
|
5
11
|
## 1.18.0 (2020-10-19)
|
|
6
12
|
|
|
7
13
|
- add: [Relax dependencies by fukayatsu · Pull Request #47 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/47)
|
|
@@ -13,74 +19,96 @@ nothing
|
|
|
13
19
|
- **changed**: Drop support for Ruby 2.4
|
|
14
20
|
|
|
15
21
|
## 1.16.0 (2020-01-20)
|
|
22
|
+
|
|
16
23
|
- add: [Enable to set default_headers by fukayatsu · Pull Request #43 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/43)
|
|
17
24
|
|
|
18
25
|
## 1.15.0 (2019-12-27)
|
|
26
|
+
|
|
19
27
|
- add: [Add ApiMethods#delete_member by fukayatsu · Pull Request #40 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/40)
|
|
20
28
|
- ci: [Use github actions for CI by fukayatsu · Pull Request #38 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/38)
|
|
21
29
|
- ci: [Update development environment by fukayatsu · Pull Request #37 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/37)
|
|
22
30
|
|
|
23
31
|
## 1.14.0 (2018-12-13)
|
|
32
|
+
|
|
24
33
|
- changed: [Relax gem dependencies by ppworks · Pull Request #35 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/35)
|
|
25
34
|
|
|
26
35
|
## 1.13.0 (2017-11-01)
|
|
36
|
+
|
|
27
37
|
- **changed**: [Retry on rate limit exceeded by default by fukayatsu · Pull Request #31 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/31)
|
|
28
38
|
- Use `Esa::Client.new(retry_on_rate_limit_exceeded: false, ...)` for previous behavior.
|
|
29
39
|
- doc: [Fixed README typo by polidog · Pull Request #30 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/30)
|
|
30
40
|
|
|
31
41
|
## 1.12.0 (2017-10-03)
|
|
42
|
+
|
|
32
43
|
- add: [Support /api/v1/comments API by ppworks · Pull Request #29 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/29)
|
|
33
44
|
|
|
34
45
|
## 1.11.0 (2017-09-04)
|
|
46
|
+
|
|
35
47
|
- add: [Support emoji API by ppworks · Pull Request #28 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/28)
|
|
36
48
|
|
|
37
49
|
## 1.10.0 (2017-08-22)
|
|
50
|
+
|
|
38
51
|
- add: [Support invitation API by ppworks · Pull Request #27 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/27)
|
|
39
52
|
|
|
40
53
|
## 1.9.0 (2017-08-02)
|
|
54
|
+
|
|
41
55
|
- add: [Enable to set headers for remote url on #upload_attachment by nownabe · Pull Request #26 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/26)
|
|
42
56
|
|
|
43
57
|
## 1.8.0 (2017-02-25)
|
|
58
|
+
|
|
44
59
|
- add: [Add batch_move_category API by fukayatsu · Pull Request #25 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/25)
|
|
45
60
|
|
|
46
61
|
## 1.7.0 (2016-08-16)
|
|
62
|
+
|
|
47
63
|
- add: [Support signed_url API by fukayatsu · Pull Request #24 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/24)
|
|
48
64
|
- fix: [Fix a typo by ksss · Pull Request #23 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/23)
|
|
49
65
|
|
|
50
66
|
## 1.6.0 (2016-06-10)
|
|
67
|
+
|
|
51
68
|
- add: [Add Categories API and Tags API by fukayatsu · Pull Request #22 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/22)
|
|
52
69
|
|
|
53
70
|
## 1.5.0 (2016-05-05)
|
|
71
|
+
|
|
54
72
|
- add: [Add Reaction APIs: star&watch by fukayatsu · Pull Request #20 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/20)
|
|
55
73
|
|
|
56
74
|
## 1.4.0 (2016-04-17)
|
|
75
|
+
|
|
57
76
|
- add: [Add Authenticated User API by fukayatsu · Pull Request #19 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/19)
|
|
58
77
|
|
|
59
78
|
## 1.3.0 (2016-02-09)
|
|
79
|
+
|
|
60
80
|
- add: [Add Sharing API by fukayatsu · Pull Request #17 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/17)
|
|
61
81
|
|
|
62
82
|
## 1.2.0 (2015-12-03)
|
|
83
|
+
|
|
63
84
|
- add: [Add Members API by fukayatsu · Pull Request #16 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/16)
|
|
64
85
|
|
|
65
86
|
## 1.1.2 (2015-10-05)
|
|
87
|
+
|
|
66
88
|
- fix: [Esa::Client#upload_attachment needs 'multi_xml' gem by ppworks · Pull Request #15 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/15)
|
|
67
89
|
|
|
68
90
|
## 1.1.1 (2015-10-01)
|
|
91
|
+
|
|
69
92
|
- add: [Enable to set cookie for remote url on #upload_attachment by fukayatsu · Pull Request #14 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/14)
|
|
70
93
|
|
|
71
94
|
## 1.1.0 (2015-10-01)
|
|
95
|
+
|
|
72
96
|
- add: [Enable to Upload Attachment by fukayatsu · Pull Request #13 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/13)
|
|
73
97
|
|
|
74
98
|
## 1.0.0 (2015-09-25)
|
|
99
|
+
|
|
75
100
|
- Production Ready (\\( ⁰⊖⁰)/)
|
|
76
101
|
- [Add Stats API by fukayatsu · Pull Request #12 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/12)
|
|
77
102
|
- [Use Travis CI for testing by hanachin · Pull Request #11 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/11)
|
|
78
103
|
|
|
79
104
|
## 0.0.6 (2015-06-21)
|
|
105
|
+
|
|
80
106
|
- [Support Comment API by fukayatsu · Pull Request #9 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/9)
|
|
81
107
|
|
|
82
108
|
## 0.0.5 (2015-05-21)
|
|
109
|
+
|
|
83
110
|
- [Use current_team! instead of current_team by fukayatsu · Pull Request #8 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/8)
|
|
84
111
|
|
|
85
112
|
## 0.0.4 (2015-05-14)
|
|
113
|
+
|
|
86
114
|
- [Fix Esa::Response#headers and implement its spec by yasaichi · Pull Request #7 · esaio/esa-ruby](https://github.com/esaio/esa-ruby/pull/7)
|
data/esa.gemspec
CHANGED
|
@@ -13,13 +13,15 @@ Gem::Specification.new do |spec|
|
|
|
13
13
|
spec.homepage = 'https://github.com/esaio/esa-ruby/'
|
|
14
14
|
spec.license = 'MIT'
|
|
15
15
|
|
|
16
|
-
spec.files = `git ls-files -z`.split("\x0")
|
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match?(%r{^(spec/|\.)}) }
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
|
19
18
|
spec.require_paths = ['lib']
|
|
20
19
|
|
|
21
|
-
spec.
|
|
22
|
-
|
|
20
|
+
spec.required_ruby_version = ">= 2.7.0"
|
|
21
|
+
|
|
22
|
+
spec.add_runtime_dependency 'faraday', '>= 2.0.1', '< 3.0'
|
|
23
|
+
spec.add_runtime_dependency 'faraday-multipart'
|
|
24
|
+
spec.add_runtime_dependency 'faraday-xml'
|
|
23
25
|
spec.add_runtime_dependency 'mime-types', '>= 2.6', '< 4.0'
|
|
24
26
|
spec.add_runtime_dependency 'multi_xml', '>= 0.5.5', '< 1.0'
|
|
25
27
|
|
data/lib/esa/api_methods.rb
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
require 'base64'
|
|
2
|
+
require 'mime/types'
|
|
3
|
+
|
|
2
4
|
module Esa
|
|
3
5
|
module ApiMethods
|
|
4
6
|
HTTP_REGEX = %r{^https?://}
|
|
@@ -183,7 +185,7 @@ module Esa
|
|
|
183
185
|
return response unless response.status == 200
|
|
184
186
|
|
|
185
187
|
attachment = response.body['attachment']
|
|
186
|
-
form_data = response.body['form'].merge(file: Faraday::
|
|
188
|
+
form_data = response.body['form'].merge(file: Faraday::FilePart.new(file, params[:type]))
|
|
187
189
|
|
|
188
190
|
s3_response = send_s3_request(:post, attachment['endpoint'], form_data)
|
|
189
191
|
return s3_response unless s3_response.status == 204
|
|
@@ -206,7 +208,6 @@ module Esa
|
|
|
206
208
|
end
|
|
207
209
|
|
|
208
210
|
def content_type_from_file(file)
|
|
209
|
-
require 'mime/types'
|
|
210
211
|
if mime_type = MIME::Types.type_for(file.path).first
|
|
211
212
|
mime_type.content_type
|
|
212
213
|
end
|
data/lib/esa/version.rb
CHANGED
data/lib/esa.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: esa
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 2.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- fukayatsu
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2023-04-06 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|
|
@@ -16,40 +16,48 @@ dependencies:
|
|
|
16
16
|
requirements:
|
|
17
17
|
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version:
|
|
19
|
+
version: 2.0.1
|
|
20
20
|
- - "<"
|
|
21
21
|
- !ruby/object:Gem::Version
|
|
22
|
-
version: '
|
|
22
|
+
version: '3.0'
|
|
23
23
|
type: :runtime
|
|
24
24
|
prerelease: false
|
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
|
26
26
|
requirements:
|
|
27
27
|
- - ">="
|
|
28
28
|
- !ruby/object:Gem::Version
|
|
29
|
-
version:
|
|
29
|
+
version: 2.0.1
|
|
30
30
|
- - "<"
|
|
31
31
|
- !ruby/object:Gem::Version
|
|
32
|
-
version: '
|
|
32
|
+
version: '3.0'
|
|
33
33
|
- !ruby/object:Gem::Dependency
|
|
34
|
-
name:
|
|
34
|
+
name: faraday-multipart
|
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
|
36
36
|
requirements:
|
|
37
37
|
- - ">="
|
|
38
38
|
- !ruby/object:Gem::Version
|
|
39
|
-
version: '0
|
|
40
|
-
- - "<"
|
|
41
|
-
- !ruby/object:Gem::Version
|
|
42
|
-
version: '2.0'
|
|
39
|
+
version: '0'
|
|
43
40
|
type: :runtime
|
|
44
41
|
prerelease: false
|
|
45
42
|
version_requirements: !ruby/object:Gem::Requirement
|
|
46
43
|
requirements:
|
|
47
44
|
- - ">="
|
|
48
45
|
- !ruby/object:Gem::Version
|
|
49
|
-
version: '0
|
|
50
|
-
|
|
46
|
+
version: '0'
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: faraday-xml
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - ">="
|
|
51
52
|
- !ruby/object:Gem::Version
|
|
52
|
-
version: '
|
|
53
|
+
version: '0'
|
|
54
|
+
type: :runtime
|
|
55
|
+
prerelease: false
|
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
57
|
+
requirements:
|
|
58
|
+
- - ">="
|
|
59
|
+
- !ruby/object:Gem::Version
|
|
60
|
+
version: '0'
|
|
53
61
|
- !ruby/object:Gem::Dependency
|
|
54
62
|
name: mime-types
|
|
55
63
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -160,16 +168,13 @@ dependencies:
|
|
|
160
168
|
- - "~>"
|
|
161
169
|
- !ruby/object:Gem::Version
|
|
162
170
|
version: 3.7.6
|
|
163
|
-
description:
|
|
171
|
+
description:
|
|
164
172
|
email:
|
|
165
173
|
- fukayatsu@gmail.com
|
|
166
174
|
executables: []
|
|
167
175
|
extensions: []
|
|
168
176
|
extra_rdoc_files: []
|
|
169
177
|
files:
|
|
170
|
-
- ".github/workflows/build.yml"
|
|
171
|
-
- ".gitignore"
|
|
172
|
-
- ".rspec"
|
|
173
178
|
- CHANGELOG.md
|
|
174
179
|
- Gemfile
|
|
175
180
|
- LICENSE.txt
|
|
@@ -182,14 +187,11 @@ files:
|
|
|
182
187
|
- lib/esa/errors.rb
|
|
183
188
|
- lib/esa/response.rb
|
|
184
189
|
- lib/esa/version.rb
|
|
185
|
-
- spec/esa/client_spec.rb
|
|
186
|
-
- spec/esa/response_spec.rb
|
|
187
|
-
- spec/spec_helper.rb
|
|
188
190
|
homepage: https://github.com/esaio/esa-ruby/
|
|
189
191
|
licenses:
|
|
190
192
|
- MIT
|
|
191
193
|
metadata: {}
|
|
192
|
-
post_install_message:
|
|
194
|
+
post_install_message:
|
|
193
195
|
rdoc_options: []
|
|
194
196
|
require_paths:
|
|
195
197
|
- lib
|
|
@@ -197,18 +199,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
197
199
|
requirements:
|
|
198
200
|
- - ">="
|
|
199
201
|
- !ruby/object:Gem::Version
|
|
200
|
-
version:
|
|
202
|
+
version: 2.7.0
|
|
201
203
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
204
|
requirements:
|
|
203
205
|
- - ">="
|
|
204
206
|
- !ruby/object:Gem::Version
|
|
205
207
|
version: '0'
|
|
206
208
|
requirements: []
|
|
207
|
-
rubygems_version: 3.
|
|
208
|
-
signing_key:
|
|
209
|
+
rubygems_version: 3.3.26
|
|
210
|
+
signing_key:
|
|
209
211
|
specification_version: 4
|
|
210
212
|
summary: esa API v1 client library, written in Ruby
|
|
211
|
-
test_files:
|
|
212
|
-
- spec/esa/client_spec.rb
|
|
213
|
-
- spec/esa/response_spec.rb
|
|
214
|
-
- spec/spec_helper.rb
|
|
213
|
+
test_files: []
|
data/.github/workflows/build.yml
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
name: build
|
|
2
|
-
|
|
3
|
-
on: [push]
|
|
4
|
-
|
|
5
|
-
jobs:
|
|
6
|
-
build:
|
|
7
|
-
runs-on: ubuntu-latest
|
|
8
|
-
|
|
9
|
-
strategy:
|
|
10
|
-
matrix:
|
|
11
|
-
ruby:
|
|
12
|
-
# https://hub.docker.com/_/ruby
|
|
13
|
-
- '2.5'
|
|
14
|
-
- '2.6'
|
|
15
|
-
- '2.7'
|
|
16
|
-
- 'latest'
|
|
17
|
-
container:
|
|
18
|
-
image: ruby:${{ matrix.ruby }}
|
|
19
|
-
|
|
20
|
-
steps:
|
|
21
|
-
- uses: actions/checkout@v1
|
|
22
|
-
- name: Build and test with Rake
|
|
23
|
-
run: |
|
|
24
|
-
gem install bundler
|
|
25
|
-
bundle install --jobs 4 --retry 3
|
|
26
|
-
bundle exec rake
|
data/.gitignore
DELETED
data/.rspec
DELETED
data/spec/esa/client_spec.rb
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
require "spec_helper"
|
|
2
|
-
|
|
3
|
-
RSpec.describe Esa::Client do
|
|
4
|
-
let(:access_token) { nil }
|
|
5
|
-
let(:api_endpoint) { nil }
|
|
6
|
-
let(:current_team) { nil }
|
|
7
|
-
let(:default_headers) { {} }
|
|
8
|
-
let(:options) do
|
|
9
|
-
{
|
|
10
|
-
access_token: access_token,
|
|
11
|
-
api_endpoint: api_endpoint,
|
|
12
|
-
current_team: current_team,
|
|
13
|
-
default_headers: default_headers
|
|
14
|
-
}
|
|
15
|
-
end
|
|
16
|
-
subject(:client) { described_class.new(**options) }
|
|
17
|
-
|
|
18
|
-
describe "#current_team!" do
|
|
19
|
-
context 'team not specified' do
|
|
20
|
-
it 'raise error' do
|
|
21
|
-
expect do
|
|
22
|
-
client.current_team!
|
|
23
|
-
end.to raise_error Esa::TeamNotSpecifiedError
|
|
24
|
-
end
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
context 'team specified' do
|
|
28
|
-
let(:current_team) { '<team>' }
|
|
29
|
-
it 'return current_team' do
|
|
30
|
-
expect(client.current_team).to eq current_team
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
%i(get post put patch delete).each do |method|
|
|
36
|
-
describe "#send_#{method}" do
|
|
37
|
-
let(:path) { '<path>' }
|
|
38
|
-
let(:params) { '<params>' }
|
|
39
|
-
let(:headers) { '<headers>' }
|
|
40
|
-
it "call send_request with method, path, params and headers" do
|
|
41
|
-
expect(client).to receive(:send_request).with(method, path, params, headers)
|
|
42
|
-
client.__send__("send_#{method}", path, params, headers)
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
describe 'default_headers' do
|
|
48
|
-
before do
|
|
49
|
-
stub_request(:any, 'https://api.esa.io/v1/teams')
|
|
50
|
-
.to_return do |request|
|
|
51
|
-
{
|
|
52
|
-
body: request.body,
|
|
53
|
-
headers: request.headers
|
|
54
|
-
}
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
context 'no default_headers option' do
|
|
59
|
-
it 'request with basic headers' do
|
|
60
|
-
response = client.teams
|
|
61
|
-
expect(response.headers).to eq(
|
|
62
|
-
'Accept' => 'application/json',
|
|
63
|
-
'User-Agent' => "Esa Ruby Gem #{Esa::VERSION}",
|
|
64
|
-
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3'
|
|
65
|
-
)
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
it 'request with basic headers and additional headers ' do
|
|
69
|
-
response = client.teams(nil, { 'X-Foo' => 'bar' })
|
|
70
|
-
expect(response.headers).to eq(
|
|
71
|
-
'Accept' => 'application/json',
|
|
72
|
-
'User-Agent' => "Esa Ruby Gem #{Esa::VERSION}",
|
|
73
|
-
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
|
74
|
-
'X-Foo' => 'bar'
|
|
75
|
-
)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
context 'with default_headers option' do
|
|
80
|
-
let(:default_headers) { { 'X-Default-Foo' => 'Bar' } }
|
|
81
|
-
|
|
82
|
-
it 'request with basic headers and default_headers' do
|
|
83
|
-
response = client.teams
|
|
84
|
-
expect(response.headers).to eq(
|
|
85
|
-
'Accept' => 'application/json',
|
|
86
|
-
'User-Agent' => "Esa Ruby Gem #{Esa::VERSION}",
|
|
87
|
-
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
|
88
|
-
'X-Default-Foo' => 'Bar'
|
|
89
|
-
)
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it 'request with basic headers and additional headers ' do
|
|
93
|
-
response = client.teams(nil, { 'X-Foo' => 'baz', 'X-Default-Foo' => 'qux' })
|
|
94
|
-
expect(response.headers).to eq(
|
|
95
|
-
'Accept' => 'application/json',
|
|
96
|
-
'User-Agent' => "Esa Ruby Gem #{Esa::VERSION}",
|
|
97
|
-
'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3',
|
|
98
|
-
'X-Default-Foo' => 'qux',
|
|
99
|
-
'X-Foo' => 'baz'
|
|
100
|
-
)
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
end
|
data/spec/esa/response_spec.rb
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe Esa::Response do
|
|
4
|
-
let(:response_status) { 401 }
|
|
5
|
-
let(:response_body) { '{"error":"unauthorized", "message":"Unauthorized"}' }
|
|
6
|
-
let(:response_headers) do
|
|
7
|
-
{
|
|
8
|
-
'server' => 'Cowboy',
|
|
9
|
-
'content-type' => 'application/json; charset=utf-8',
|
|
10
|
-
}
|
|
11
|
-
end
|
|
12
|
-
let(:connection) do
|
|
13
|
-
Faraday.new do |c|
|
|
14
|
-
c.adapter :test, Faraday::Adapter::Test::Stubs.new do |stub|
|
|
15
|
-
stub.get('/test') { [response_status, response_headers, response_body] }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
let(:response) { described_class.new(connection.get('/test')) }
|
|
20
|
-
|
|
21
|
-
describe '#body' do
|
|
22
|
-
subject { response.body }
|
|
23
|
-
it { is_expected.to eq response_body }
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
describe '#headers' do
|
|
27
|
-
subject { response.headers }
|
|
28
|
-
let(:expectation) do
|
|
29
|
-
{
|
|
30
|
-
'Server' => 'Cowboy',
|
|
31
|
-
'Content-Type' => 'application/json; charset=utf-8',
|
|
32
|
-
}
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
it { is_expected.to eq expectation }
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
describe '#status' do
|
|
39
|
-
subject { response.status }
|
|
40
|
-
it { is_expected.to eq response_status }
|
|
41
|
-
end
|
|
42
|
-
end
|
data/spec/spec_helper.rb
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require 'esa'
|
|
2
|
-
require 'webmock/rspec'
|
|
3
|
-
|
|
4
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
5
|
-
RSpec.configure do |config|
|
|
6
|
-
config.expect_with :rspec do |expectations|
|
|
7
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
config.mock_with :rspec do |mocks|
|
|
11
|
-
mocks.verify_partial_doubles = true
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
config.filter_run :focus
|
|
15
|
-
config.run_all_when_everything_filtered = true
|
|
16
|
-
|
|
17
|
-
config.disable_monkey_patching!
|
|
18
|
-
config.warnings = true
|
|
19
|
-
|
|
20
|
-
if config.files_to_run.one?
|
|
21
|
-
config.default_formatter = 'doc'
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
config.profile_examples = 10
|
|
25
|
-
config.order = :random
|
|
26
|
-
Kernel.srand config.seed
|
|
27
|
-
end
|