aliyunsdkcore 0.0.9 → 0.0.10
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 +5 -5
- data/CHANGELOG.md +4 -0
- data/LICENSE.md +21 -0
- data/README-CN.md +92 -0
- data/lib/aliyunsdkcore.rb +1 -1
- data/lib/aliyunsdkcore/roa_client.rb +2 -1
- metadata +11 -61
- data/spec/roa_client_integration_spec.rb +0 -35
- data/spec/roa_client_spec.rb +0 -279
- data/spec/rpc_client_integration_spec.rb +0 -43
- data/spec/rpc_client_spec.rb +0 -227
- data/spec/spec_helper.rb +0 -111
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5f4ffb5c02acb861abf8fb45098c108f935f03c80f6eb3d4ec4950c5e8f1a1ec
|
4
|
+
data.tar.gz: 6e2a1a49c7bd1a4706224e7ff8db665f83a68e811c9d9027a805fffc068974a6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b50a9bd351b5cc8e6611c8c3f8e2e4a9ffb335a580cc3d729bc1bbc06545c34f395724a8eafbc8d0230f10c56df52aa3eebce19cd4a8278074b37af9c138eada
|
7
|
+
data.tar.gz: c4651933b8a53a8e780c1cb23543a2e5eca01d3a9b950ade6830db8501b74c3bf9273628fb1fa991c629ed0fe4e8230805a0ac82a7baea490ff923edc5439fb3
|
data/CHANGELOG.md
ADDED
data/LICENSE.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright 1999-2019 Alibaba Group Holding Ltd.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README-CN.md
ADDED
@@ -0,0 +1,92 @@
|
|
1
|
+
[English](./README.md) | 简体中文
|
2
|
+
|
3
|
+
|
4
|
+
<p align="center">
|
5
|
+
<a href=" https://www.alibabacloud.com"><img src="https://aliyunsdk-pages.alicdn.com/icons/Aliyun.svg"></a>
|
6
|
+
</p>
|
7
|
+
|
8
|
+
<h1 align="center">Alibaba Cloud Core SDK for Ruby</h1>
|
9
|
+
|
10
|
+
<p align="center">
|
11
|
+
<a href="https://badge.fury.io/rb/aliyunsdkcore"><img src="https://badge.fury.io/rb/aliyunsdkcore.svg" alt="Gem Version"></a>
|
12
|
+
<a href="https://travis-ci.org/aliyun/openapi-core-ruby-sdk"><img src="https://travis-ci.org/aliyun/openapi-core-ruby-sdk.svg?branch=master" alt="Build Status"></a>
|
13
|
+
<a href="https://ci.appveyor.com/project/aliyun/openapi-core-ruby-sdk/branch/master"><img src="https://ci.appveyor.com/api/projects/status/uyepkk5bjbynofvu/branch/master?svg=true" alt="Build status"></a>
|
14
|
+
<a href="https://codecov.io/gh/aliyun/openapi-core-ruby-sdk"><img src="https://codecov.io/gh/aliyun/openapi-core-ruby-sdk/branch/master/graph/badge.svg" alt="codecov"></a>
|
15
|
+
</p>
|
16
|
+
|
17
|
+
|
18
|
+
Alibaba Cloud Core SDK for Ruby 支持 Ruby 开发者轻松访问阿里云服务,例如:弹性云主机(ECS)、负载均衡(SLB)、云监控(CloudMonitor)等。 您无需处理API相关业务(如签名和构建请求)即可访问阿里云服务。
|
19
|
+
|
20
|
+
本文档介绍如何安装和使用 Alibaba Cloud Core SDK for Ruby。
|
21
|
+
|
22
|
+
## 安装
|
23
|
+
|
24
|
+
```sh
|
25
|
+
$ gem install aliyunsdkcore
|
26
|
+
```
|
27
|
+
|
28
|
+
## 使用
|
29
|
+
|
30
|
+
RPC 示例;
|
31
|
+
|
32
|
+
```ruby
|
33
|
+
require 'aliyunsdkcore'
|
34
|
+
|
35
|
+
client = RPCClient.new(
|
36
|
+
endpoint: 'https://ecs.aliyuncs.com',
|
37
|
+
api_version: '2014-05-26',
|
38
|
+
access_key_id: ENV['ACCESS_KEY_ID'],
|
39
|
+
access_key_secret: ENV['ACCESS_KEY_SECRET'],
|
40
|
+
)
|
41
|
+
|
42
|
+
params = { key: (1..11).to_a.map(&:to_s) }
|
43
|
+
request_option = { method: 'POST', timeout: 15000 }
|
44
|
+
response = client.request(
|
45
|
+
action: 'DescribeRegions',
|
46
|
+
params: params,
|
47
|
+
opts: request_option
|
48
|
+
)
|
49
|
+
|
50
|
+
print response
|
51
|
+
```
|
52
|
+
|
53
|
+
|
54
|
+
ROA 示例:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
require 'aliyunsdkcore'
|
58
|
+
|
59
|
+
client = ROAClient.new(
|
60
|
+
endpoint: 'http://ros.aliyuncs.com',
|
61
|
+
api_version: '2015-09-01',
|
62
|
+
access_key_id: ENV['ACCESS_KEY_ID'],
|
63
|
+
access_key_secret: ENV['ACCESS_KEY_SECRET'],
|
64
|
+
)
|
65
|
+
|
66
|
+
response = client.request(
|
67
|
+
method: 'GET',
|
68
|
+
uri: '/regions',
|
69
|
+
options: {
|
70
|
+
timeout: 15000
|
71
|
+
}
|
72
|
+
)
|
73
|
+
|
74
|
+
print response.body
|
75
|
+
```
|
76
|
+
|
77
|
+
## 问题
|
78
|
+
[提交 Issue](https://github.com/aliyun/openapi-core-ruby-sdk/issues/new/choose),不符合指南的问题可能会立即关闭。
|
79
|
+
|
80
|
+
|
81
|
+
## 发行说明
|
82
|
+
每个版本的详细更改记录在[发行说明](CHANGELOG.md)中。
|
83
|
+
|
84
|
+
|
85
|
+
## 贡献
|
86
|
+
提交 Pull Request 之前请阅读[贡献指南](CONTRIBUTING.md)。
|
87
|
+
|
88
|
+
|
89
|
+
## 许可证
|
90
|
+
[MIT](LICENSE.md)
|
91
|
+
|
92
|
+
版权所有 1999-2019 阿里巴巴集团
|
data/lib/aliyunsdkcore.rb
CHANGED
@@ -2,7 +2,7 @@ require 'aliyunsdkcore/rpc_client'
|
|
2
2
|
require 'aliyunsdkcore/roa_client'
|
3
3
|
|
4
4
|
module AliyunSDKCore
|
5
|
-
VERSION = "0.0.
|
5
|
+
VERSION = "0.0.10"
|
6
6
|
DEFAULT_UA = "AlibabaCloud (#{Gem::Platform.local.os}; " +
|
7
7
|
"#{Gem::Platform.local.cpu}) Ruby/#{RUBY_VERSION} Core/#{VERSION}"
|
8
8
|
end
|
@@ -20,7 +20,8 @@ module AliyunSDKCore
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def request(method:, uri:, params: {}, body: {}, headers: {}, options: {})
|
23
|
-
|
23
|
+
# :"Content-Type" => "application/json" to "content-type" => "application/json"
|
24
|
+
headers.deep_transform_keys! { |key| key.to_s.downcase }
|
24
25
|
mix_headers = default_headers.merge(headers)
|
25
26
|
|
26
27
|
response = connection.send(method.downcase) do |request|
|
metadata
CHANGED
@@ -1,29 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aliyunsdkcore
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alibaba Cloud SDK
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: faraday
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 0.15.4
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 0.15.4
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: activesupport
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,47 +25,19 @@ dependencies:
|
|
39
25
|
- !ruby/object:Gem::Version
|
40
26
|
version: 4.0.0
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: 0.16.1
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: 0.16.1
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: 3.8.0
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: 3.8.0
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: codecov
|
28
|
+
name: faraday
|
71
29
|
requirement: !ruby/object:Gem::Requirement
|
72
30
|
requirements:
|
73
31
|
- - ">="
|
74
32
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.
|
76
|
-
type: :
|
33
|
+
version: 0.15.4
|
34
|
+
type: :runtime
|
77
35
|
prerelease: false
|
78
36
|
version_requirements: !ruby/object:Gem::Requirement
|
79
37
|
requirements:
|
80
38
|
- - ">="
|
81
39
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.
|
40
|
+
version: 0.15.4
|
83
41
|
description: Alibaba Cloud Ruby Core SDK
|
84
42
|
email:
|
85
43
|
- sdk-team@alibabacloud.com
|
@@ -87,15 +45,13 @@ executables: []
|
|
87
45
|
extensions: []
|
88
46
|
extra_rdoc_files: []
|
89
47
|
files:
|
48
|
+
- CHANGELOG.md
|
49
|
+
- LICENSE.md
|
50
|
+
- README-CN.md
|
90
51
|
- README.md
|
91
52
|
- lib/aliyunsdkcore.rb
|
92
53
|
- lib/aliyunsdkcore/roa_client.rb
|
93
54
|
- lib/aliyunsdkcore/rpc_client.rb
|
94
|
-
- spec/roa_client_integration_spec.rb
|
95
|
-
- spec/roa_client_spec.rb
|
96
|
-
- spec/rpc_client_integration_spec.rb
|
97
|
-
- spec/rpc_client_spec.rb
|
98
|
-
- spec/spec_helper.rb
|
99
55
|
homepage: http://www.alibabacloud.com/
|
100
56
|
licenses:
|
101
57
|
- MIT
|
@@ -115,14 +71,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
71
|
- !ruby/object:Gem::Version
|
116
72
|
version: '0'
|
117
73
|
requirements: []
|
118
|
-
|
119
|
-
rubygems_version: 2.5.2.3
|
74
|
+
rubygems_version: 3.0.4
|
120
75
|
signing_key:
|
121
76
|
specification_version: 4
|
122
77
|
summary: Alibaba Cloud Ruby Core SDK
|
123
|
-
test_files:
|
124
|
-
- spec/roa_client_integration_spec.rb
|
125
|
-
- spec/roa_client_spec.rb
|
126
|
-
- spec/rpc_client_integration_spec.rb
|
127
|
-
- spec/rpc_client_spec.rb
|
128
|
-
- spec/spec_helper.rb
|
78
|
+
test_files: []
|
@@ -1,35 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'webmock/rspec'
|
3
|
-
|
4
|
-
require 'aliyunsdkcore'
|
5
|
-
|
6
|
-
describe 'roa request' do
|
7
|
-
|
8
|
-
WebMock.allow_net_connect!
|
9
|
-
|
10
|
-
let(:roa_client) do
|
11
|
-
ROAClient.new(
|
12
|
-
endpoint: 'http://ros.aliyuncs.com',
|
13
|
-
api_version: '2015-09-01',
|
14
|
-
access_key_id: ENV['ACCESS_KEY_ID'],
|
15
|
-
access_key_secret: ENV['ACCESS_KEY_SECRET'],
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'request' do
|
20
|
-
response = roa_client.request(method: 'GET', uri: '/regions', options: { timeout: 15000 })
|
21
|
-
expect(JSON.parse(response.body).keys.include?('Regions')).to be true
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'get should ok' do
|
25
|
-
response = roa_client.request(method: 'GET', uri: '/regions', options: { timeout: 10000 })
|
26
|
-
expect(JSON.parse(response.body).keys.include?('Regions')).to be true
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'get raw body should ok' do
|
30
|
-
options = { raw_body: true, timeout: 10000 }
|
31
|
-
response = roa_client.request(method: 'GET', uri: '/regions', options: options)
|
32
|
-
expect(response.body.instance_of? String).to be true
|
33
|
-
end
|
34
|
-
|
35
|
-
end
|
data/spec/roa_client_spec.rb
DELETED
@@ -1,279 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'webmock/rspec'
|
3
|
-
|
4
|
-
require "aliyunsdkcore"
|
5
|
-
|
6
|
-
describe 'ROAClient' do
|
7
|
-
|
8
|
-
describe 'initialize' do
|
9
|
-
|
10
|
-
it 'should pass into "config"' do
|
11
|
-
expect {
|
12
|
-
ROAClient.new(nil)
|
13
|
-
}.to raise_error(ArgumentError, 'must pass "config"')
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should pass into "config[:endpoint]"' do
|
17
|
-
expect {
|
18
|
-
ROAClient.new({})
|
19
|
-
}.to raise_error(ArgumentError, 'must pass "config[:endpoint]"')
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should pass into valid "config[:endpoint]"' do
|
23
|
-
expect {
|
24
|
-
ROAClient.new(endpoint: 'ros.aliyuncs.com/')
|
25
|
-
}.to raise_error(ArgumentError, '"config.endpoint" must starts with \'https://\' or \'http://\'.')
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'should pass into "config[:api_version]"' do
|
29
|
-
expect {
|
30
|
-
ROAClient.new(endpoint: 'http://ros.aliyuncs.com/')
|
31
|
-
}.to raise_error(ArgumentError, 'must pass "config[:api_version]"')
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'should pass into "config[:access_key_id]"' do
|
35
|
-
expect {
|
36
|
-
ROAClient.new(endpoint: 'http://ros.aliyuncs.com/', api_version: '1.0')
|
37
|
-
}.to raise_error(ArgumentError, 'must pass "config[:access_key_id]"')
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'should pass into "config[:access_key_secret]"' do
|
41
|
-
expect {
|
42
|
-
ROAClient.new(endpoint: 'http://ros.aliyuncs.com/', api_version: '1.0', access_key_id: 'access_key_id')
|
43
|
-
}.to raise_error(ArgumentError, 'must pass "config[:access_key_secret]"')
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'should ok with http protocol' do
|
47
|
-
roa_client = ROAClient.new(
|
48
|
-
endpoint: 'http://ros.aliyuncs.com/',
|
49
|
-
api_version: '1.0',
|
50
|
-
access_key_id: 'access_key_id',
|
51
|
-
access_key_secret: 'access_key_secret'
|
52
|
-
)
|
53
|
-
expect(roa_client.endpoint).to eq('http://ros.aliyuncs.com/')
|
54
|
-
end
|
55
|
-
|
56
|
-
it 'should ok with https protocol' do
|
57
|
-
roa_client = ROAClient.new(
|
58
|
-
endpoint: 'https://ros.aliyuncs.com/',
|
59
|
-
api_version: '1.0',
|
60
|
-
access_key_id: 'access_key_id',
|
61
|
-
access_key_secret: 'access_key_secret'
|
62
|
-
)
|
63
|
-
expect(roa_client.endpoint).to eq('https://ros.aliyuncs.com/')
|
64
|
-
end
|
65
|
-
|
66
|
-
let(:roa_client) do
|
67
|
-
ROAClient.new(
|
68
|
-
endpoint: 'https://ros.aliyuncs.com/',
|
69
|
-
api_version: '1.0',
|
70
|
-
access_key_id: 'access_key_id',
|
71
|
-
access_key_secret: 'access_key_secret'
|
72
|
-
)
|
73
|
-
end
|
74
|
-
|
75
|
-
let(:default_header_keys) do
|
76
|
-
%w(accept date host
|
77
|
-
x-acs-signature-nonce
|
78
|
-
x-acs-signature-method
|
79
|
-
x-acs-signature-version
|
80
|
-
x-acs-version
|
81
|
-
x-sdk-client
|
82
|
-
user-agent)
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'default headers should ok' do
|
86
|
-
expect(roa_client.default_headers.keys).to match_array(default_header_keys)
|
87
|
-
expect(roa_client.default_headers['accept']).to eq('application/json')
|
88
|
-
expect(roa_client.default_headers['date']).to match(/[A-Z][a-z]{2}, \d{2} [A-Z][a-z]{2} \d{4} \d{2}:\d{2}:\d{2} GMT/)
|
89
|
-
expect(roa_client.default_headers['host']).to eq('ros.aliyuncs.com')
|
90
|
-
expect(roa_client.default_headers['user-agent']).to match(/AlibabaCloud \(.*; .*\) Ruby\/\d+.\d+.\d+ Core\/\d+.\d+.\d+/)
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'default_headers should ok with security_token' do
|
94
|
-
roa_client = ROAClient.new(
|
95
|
-
endpoint: 'https://ros.aliyuncs.com/',
|
96
|
-
api_version: '1.0',
|
97
|
-
access_key_id: 'access_key_id',
|
98
|
-
access_key_secret: 'access_key_secret',
|
99
|
-
security_token: 'security_token'
|
100
|
-
)
|
101
|
-
|
102
|
-
default_header_keys = %w(
|
103
|
-
accept
|
104
|
-
date
|
105
|
-
host
|
106
|
-
x-acs-signature-nonce
|
107
|
-
x-acs-signature-method
|
108
|
-
x-acs-signature-version
|
109
|
-
x-acs-version
|
110
|
-
x-sdk-client
|
111
|
-
x-acs-accesskey-id
|
112
|
-
x-acs-security-token
|
113
|
-
user-agent
|
114
|
-
)
|
115
|
-
|
116
|
-
expect(roa_client.default_headers['accept']).to eq('application/json')
|
117
|
-
expect(roa_client.default_headers.keys).to match_array(default_header_keys)
|
118
|
-
expect(roa_client.default_headers['date']).to match(/[A-Z][a-z]{2}, \d{2} [A-Z][a-z]{2} \d{4} \d{2}:\d{2}:\d{2} GMT/)
|
119
|
-
expect(roa_client.default_headers['accept']).to eq('application/json')
|
120
|
-
expect(roa_client.default_headers['user-agent']).to match(/AlibabaCloud \(.*; .*\) Ruby\/\d+.\d+.\d+ Core\/\d+.\d+.\d+/)
|
121
|
-
end
|
122
|
-
|
123
|
-
describe 'request with json response should ok' do
|
124
|
-
it 'json response should ok' do
|
125
|
-
stub_request(:get, "https://ros.aliyuncs.com/")
|
126
|
-
.to_return(status: 200, headers: { 'Content-Type': 'application/json' }, body: { ok: true }.to_json)
|
127
|
-
response = roa_client.get(uri: '/')
|
128
|
-
expect(response.body).to eq({ ok: true }.to_json)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
describe 'request(204) with json response should ok' do
|
133
|
-
it 'json response should ok' do
|
134
|
-
stub_request(:get, "https://ros.aliyuncs.com/")
|
135
|
-
.to_return(status: 204, headers: { 'Content-Type': 'application/json' }, body: '')
|
136
|
-
response = roa_client.get(uri: '/')
|
137
|
-
expect(response.body).to eq('')
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
describe 'request(400) with json response should ok' do
|
142
|
-
let(:status) { 400 }
|
143
|
-
let(:headers) { { 'Content-Type': 'application/json' } }
|
144
|
-
let(:body) { { 'Message': 'error message', 'RequestId': 'requestid', 'Code': 'errorcode' }.to_json }
|
145
|
-
it 'json response should ok' do
|
146
|
-
stub_request(:get, "https://ros.aliyuncs.com/")
|
147
|
-
.to_return(status: status, headers: headers, body: body)
|
148
|
-
expect {
|
149
|
-
roa_client.get(uri: '/')
|
150
|
-
}.to raise_error(StandardError, 'code: 400, error message requestid: requestid')
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
describe 'request with xml response should ok' do
|
155
|
-
let(:status) { 200 }
|
156
|
-
let(:headers) { { 'Content-Type': 'text/xml' } }
|
157
|
-
let(:body) do
|
158
|
-
<<-XML
|
159
|
-
<note>
|
160
|
-
<to>George</to>
|
161
|
-
<from>John</from>
|
162
|
-
<heading>Reminder</heading>
|
163
|
-
<body>Don't forget the meeting!</body>
|
164
|
-
</note>
|
165
|
-
XML
|
166
|
-
end
|
167
|
-
it 'xml response should ok' do
|
168
|
-
stub_request(:get, "https://ros.aliyuncs.com/")
|
169
|
-
.to_return(status: status, headers: headers, body: body)
|
170
|
-
response = roa_client.get(uri: '/')
|
171
|
-
expect(response.body).to eq(body)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
describe 'request(400) with xml response should ok' do
|
176
|
-
let(:status) { 400 }
|
177
|
-
let(:headers) { { 'Content-Type': 'text/xml' } }
|
178
|
-
let(:body) do
|
179
|
-
<<-XML
|
180
|
-
<Error>
|
181
|
-
<Message>error message</Message>
|
182
|
-
<RequestId>requestid</RequestId>
|
183
|
-
<HostId>hostid</HostId>
|
184
|
-
<Code>errorcode</Code>
|
185
|
-
</Error>
|
186
|
-
XML
|
187
|
-
end
|
188
|
-
it 'xml response should ok' do
|
189
|
-
stub_request(:get, "https://ros.aliyuncs.com/")
|
190
|
-
.to_return(status: status, headers: headers, body: body)
|
191
|
-
expect {
|
192
|
-
roa_client.get(uri: '/')
|
193
|
-
}.to raise_error(ROAClient::ACSError, 'error message host_id: hostid, request_id: requestid')
|
194
|
-
end
|
195
|
-
end
|
196
|
-
|
197
|
-
describe 'request(200) with plain response should ok' do
|
198
|
-
it 'plain response should ok' do
|
199
|
-
stub_request(:get, "https://ros.aliyuncs.com/").to_return(status: 200, body: 'plain text')
|
200
|
-
response = roa_client.get(uri: '/')
|
201
|
-
expect(response.body).to eq('plain text')
|
202
|
-
end
|
203
|
-
end
|
204
|
-
|
205
|
-
describe 'post should ok' do
|
206
|
-
it 'should ok' do
|
207
|
-
stub_request(:get, "https://ros.aliyuncs.com/")
|
208
|
-
.to_return(status: 200, headers: { 'content-type': 'application/json' }, body: { ok: true }.to_json)
|
209
|
-
response = roa_client.post(uri: '/', body: 'text')
|
210
|
-
expect(response.body).to eq('{"ok":true}')
|
211
|
-
end
|
212
|
-
it 'should ok with query' do
|
213
|
-
stub_request(:get, "https://ros.aliyuncs.com/?k=v")
|
214
|
-
.to_return(status: 200, headers: { 'content-type': 'application/json' }, body: { ok: true }.to_json)
|
215
|
-
response = roa_client.post(uri: '/', params: { k: 'v' }, body: 'text')
|
216
|
-
expect(response.body).to eq('{"ok":true}')
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
describe 'put should ok' do
|
221
|
-
it 'should ok' do
|
222
|
-
stub_request(:get, "https://ros.aliyuncs.com/")
|
223
|
-
.to_return(status: 200, headers: { 'content-type': 'application/json' }, body: { ok: true }.to_json)
|
224
|
-
response = roa_client.put(uri: '/', body: 'text')
|
225
|
-
expect(response.body).to eq('{"ok":true}')
|
226
|
-
end
|
227
|
-
end
|
228
|
-
|
229
|
-
describe 'delete should ok' do
|
230
|
-
it 'should ok' do
|
231
|
-
stub_request(:get, "https://ros.aliyuncs.com/")
|
232
|
-
.to_return(status: 200, headers: { 'content-type': 'application/json' }, body: { ok: true }.to_json)
|
233
|
-
response = roa_client.delete(uri: '/')
|
234
|
-
expect(response.body).to eq('{"ok":true}')
|
235
|
-
end
|
236
|
-
end
|
237
|
-
|
238
|
-
it 'signature should ok' do
|
239
|
-
expect(roa_client.send(:signature, '123456')).to eq('BeAYlq/e5iWAoTNmzf8jbcBxdq0=')
|
240
|
-
end
|
241
|
-
|
242
|
-
it 'authorization should ok' do
|
243
|
-
expect(roa_client.send(:authorization, '123456')).to eq('acs access_key_id:BeAYlq/e5iWAoTNmzf8jbcBxdq0=')
|
244
|
-
end
|
245
|
-
|
246
|
-
it 'canonicalized_headers should ok' do
|
247
|
-
expect(roa_client.send(:canonicalized_headers, {})).to be_empty
|
248
|
-
expect(roa_client.send(:canonicalized_headers, { key: 'value' })).to be_empty
|
249
|
-
expect(roa_client.send(:canonicalized_headers, { 'x-acs-key': 'value' })).to eq("x-acs-key:value\n")
|
250
|
-
end
|
251
|
-
|
252
|
-
it 'canonicalized_resource should ok' do
|
253
|
-
expect(roa_client.send(:canonicalized_resource, '/')).to eq('/')
|
254
|
-
expect(roa_client.send(:canonicalized_resource, '/', { key: 'value' })).to eq('/?key=value')
|
255
|
-
expect(roa_client.send(:canonicalized_resource, '/', { key: 'value', 'key1': 'value2' })).to eq('/?key=value&key1=value2')
|
256
|
-
end
|
257
|
-
|
258
|
-
it 'string_to_sign should ok ' do
|
259
|
-
expect(
|
260
|
-
roa_client.send(:string_to_sign, 'GET', '/', { 'accept' => 'application/json' })
|
261
|
-
).to eq("GET\napplication/json\n\n\n\n/")
|
262
|
-
end
|
263
|
-
|
264
|
-
describe 'ROAClient::ACSError class' do
|
265
|
-
it 'ACSError should ok' do
|
266
|
-
expect {
|
267
|
-
error_info = {
|
268
|
-
'Message' => 'error message',
|
269
|
-
'Code' => 'errorcode',
|
270
|
-
'HostId' => 'hostid',
|
271
|
-
'RequestId' => 'requestid',
|
272
|
-
}
|
273
|
-
raise ROAClient::ACSError, error_info
|
274
|
-
}.to raise_error(ROAClient::ACSError, 'error message host_id: hostid, request_id: requestid')
|
275
|
-
end
|
276
|
-
end
|
277
|
-
|
278
|
-
end
|
279
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'webmock/rspec'
|
3
|
-
|
4
|
-
require "aliyunsdkcore"
|
5
|
-
|
6
|
-
describe 'rpc request' do
|
7
|
-
|
8
|
-
WebMock.allow_net_connect!
|
9
|
-
|
10
|
-
let(:rpc_client) do
|
11
|
-
RPCClient.new(
|
12
|
-
endpoint: 'https://ecs.aliyuncs.com',
|
13
|
-
api_version: '2014-05-26',
|
14
|
-
access_key_id: ENV['ACCESS_KEY_ID'],
|
15
|
-
access_key_secret: ENV['ACCESS_KEY_SECRET'],
|
16
|
-
)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should ok' do
|
20
|
-
params = { key: (1..11).to_a.map(&:to_s) }
|
21
|
-
request_option = { method: 'POST', timeout: 15000 }
|
22
|
-
response = rpc_client.request(action: 'DescribeRegions', params: params, opts: request_option)
|
23
|
-
expect(response.keys.include?('Regions')).to be true
|
24
|
-
expect(response.keys.include?('RequestId')).to be true
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should ok with repeat list less 10 item' do
|
28
|
-
params = { key: (1..9).to_a.map(&:to_s) }
|
29
|
-
request_option = { method: 'POST', timeout: 15000 }
|
30
|
-
response = rpc_client.request(action: 'DescribeRegions', params: params, opts: request_option)
|
31
|
-
expect(response.keys.include?('Regions')).to be true
|
32
|
-
expect(response.keys.include?('RequestId')).to be true
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'should ok with space' do
|
36
|
-
params = { key: 'the string with spaces' }
|
37
|
-
request_option = { method: 'POST', timeout: 15000 }
|
38
|
-
response = rpc_client.request(action: 'DescribeRegions', params: params, opts: request_option)
|
39
|
-
expect(response.keys.include?('Regions')).to be true
|
40
|
-
expect(response.keys.include?('RequestId')).to be true
|
41
|
-
end
|
42
|
-
|
43
|
-
end
|
data/spec/rpc_client_spec.rb
DELETED
@@ -1,227 +0,0 @@
|
|
1
|
-
require 'rspec'
|
2
|
-
require 'webmock/rspec'
|
3
|
-
|
4
|
-
require "aliyunsdkcore"
|
5
|
-
|
6
|
-
describe 'RPCClient' do
|
7
|
-
|
8
|
-
describe 'initialize' do
|
9
|
-
it 'should pass into "config"' do
|
10
|
-
expect {
|
11
|
-
RPCClient.new(nil)
|
12
|
-
}.to raise_error(ArgumentError, 'must pass "config"')
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should pass into "config[:endpoint]"' do
|
16
|
-
expect {
|
17
|
-
RPCClient.new({})
|
18
|
-
}.to raise_error(ArgumentError, 'must pass "config[:endpoint]"')
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should pass into valid "config[:endpoint]"' do
|
22
|
-
expect {
|
23
|
-
RPCClient.new(endpoint: 'ecs.aliyuncs.com/')
|
24
|
-
}.to raise_error(ArgumentError, '"config.endpoint" must starts with \'https://\' or \'http://\'.')
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should pass into "config[:api_version]"' do
|
28
|
-
expect {
|
29
|
-
RPCClient.new(endpoint: 'http://ecs.aliyuncs.com/')
|
30
|
-
}.to raise_error(ArgumentError, 'must pass "config[:api_version]"')
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'should pass into "config[:access_key_id]"' do
|
34
|
-
expect {
|
35
|
-
RPCClient.new(endpoint: 'http://ecs.aliyuncs.com/', api_version: '1.0')
|
36
|
-
}.to raise_error(ArgumentError, 'must pass "config[:access_key_id]"')
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'should pass into "config[:access_key_secret]"' do
|
40
|
-
expect {
|
41
|
-
RPCClient.new(endpoint: 'http://ecs.aliyuncs.com/', api_version: '1.0', access_key_id: 'access_key_id')
|
42
|
-
}.to raise_error(ArgumentError, 'must pass "config[:access_key_secret]"')
|
43
|
-
end
|
44
|
-
|
45
|
-
it 'should ok with http protocol' do
|
46
|
-
rpc_client = RPCClient.new(
|
47
|
-
endpoint: 'http://ecs.aliyuncs.com/',
|
48
|
-
api_version: '1.0',
|
49
|
-
access_key_id: 'access_key_id',
|
50
|
-
access_key_secret: 'access_key_secret'
|
51
|
-
)
|
52
|
-
expect(rpc_client.endpoint).to eq('http://ecs.aliyuncs.com/')
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'should ok with https protocol' do
|
56
|
-
rpc_client = RPCClient.new(
|
57
|
-
endpoint: 'https://ecs.aliyuncs.com/',
|
58
|
-
api_version: '1.0',
|
59
|
-
access_key_id: 'access_key_id',
|
60
|
-
access_key_secret: 'access_key_secret'
|
61
|
-
)
|
62
|
-
expect(rpc_client.endpoint).to eq('https://ecs.aliyuncs.com/')
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should ok with codes' do
|
66
|
-
rpc_client = RPCClient.new(
|
67
|
-
endpoint: 'https://ecs.aliyuncs.com/',
|
68
|
-
api_version: '1.0',
|
69
|
-
access_key_id: 'access_key_id',
|
70
|
-
access_key_secret: 'access_key_secret',
|
71
|
-
codes: ['True']
|
72
|
-
)
|
73
|
-
expect(rpc_client.codes.include? 'True').to be true
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe 'default params' do
|
78
|
-
|
79
|
-
it 'should ok' do
|
80
|
-
rpc_client = RPCClient.new(
|
81
|
-
endpoint: 'https://ecs.aliyuncs.com/',
|
82
|
-
api_version: '1.0',
|
83
|
-
access_key_id: 'access_key_id',
|
84
|
-
access_key_secret: 'access_key_secret',
|
85
|
-
)
|
86
|
-
default_params_keys = %w(Format SignatureMethod SignatureNonce SignatureVersion Timestamp AccessKeyId Version)
|
87
|
-
expect(rpc_client.send(:default_params).keys).to match_array default_params_keys
|
88
|
-
end
|
89
|
-
end
|
90
|
-
|
91
|
-
it 'should ok with securityToken' do
|
92
|
-
rpc_client = RPCClient.new(
|
93
|
-
endpoint: 'https://ecs.aliyuncs.com/',
|
94
|
-
api_version: '1.0',
|
95
|
-
access_key_id: 'access_key_id',
|
96
|
-
access_key_secret: 'access_key_secret',
|
97
|
-
security_token: 'security_token'
|
98
|
-
)
|
99
|
-
default_params_keys = %w(Format SignatureMethod SignatureNonce SignatureVersion Timestamp AccessKeyId Version SecurityToken)
|
100
|
-
expect(rpc_client.send(:default_params).keys).to match_array default_params_keys
|
101
|
-
end
|
102
|
-
|
103
|
-
describe 'request' do
|
104
|
-
it 'get with raw body should ok' do
|
105
|
-
rpc_client = RPCClient.new(
|
106
|
-
endpoint: 'https://ecs.aliyuncs.com/',
|
107
|
-
api_version: '1.0',
|
108
|
-
access_key_id: 'access_key_id',
|
109
|
-
access_key_secret: 'access_key_secret',
|
110
|
-
)
|
111
|
-
stub_request(:get, /https:\/\/ecs.aliyuncs.com/).to_return(status: 200, body: {}.to_json)
|
112
|
-
expect(rpc_client.request(action: 'action')).to eql({})
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
describe 'request with post' do
|
117
|
-
|
118
|
-
let(:rpc_client) do
|
119
|
-
RPCClient.new(
|
120
|
-
endpoint: 'https://ecs.aliyuncs.com/',
|
121
|
-
api_version: '1.0',
|
122
|
-
access_key_id: 'access_key_id',
|
123
|
-
access_key_secret: 'access_key_secret',
|
124
|
-
security_token: 'security_token'
|
125
|
-
)
|
126
|
-
end
|
127
|
-
|
128
|
-
it 'should ok' do
|
129
|
-
stub_request(:get, /https:\/\/ecs.aliyuncs.com/).to_return(status: 200, body: {}.to_json)
|
130
|
-
expect(rpc_client.request(action: 'action')).to eql({})
|
131
|
-
end
|
132
|
-
|
133
|
-
it 'should ok with format_action' do
|
134
|
-
stub_request(:get, /https:\/\/ecs.aliyuncs.com/).to_return(status: 200, body: {}.to_json)
|
135
|
-
response = rpc_client.request(action: 'action', opts: { format_action: false })
|
136
|
-
expect(response).to eql({})
|
137
|
-
end
|
138
|
-
|
139
|
-
it 'should ok with format_params' do
|
140
|
-
stub_request(:get, /https:\/\/ecs.aliyuncs.com/).to_return(status: 200, body: {}.to_json)
|
141
|
-
response = rpc_client.request(action: 'action', opts: { format_params: false })
|
142
|
-
expect(response).to eql({})
|
143
|
-
end
|
144
|
-
|
145
|
-
it 'get with raw body should ok' do
|
146
|
-
stub_request(:post, "https://ecs.aliyuncs.com").to_return(status: 200, body: {}.to_json)
|
147
|
-
response = rpc_client.request(action: 'action', opts: { method: 'POST' })
|
148
|
-
expect(response).to eql({})
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe 'request with error' do
|
153
|
-
|
154
|
-
let(:rpc_client) do
|
155
|
-
RPCClient.new(
|
156
|
-
endpoint: 'https://ecs.aliyuncs.com/',
|
157
|
-
api_version: '1.0',
|
158
|
-
access_key_id: 'access_key_id',
|
159
|
-
access_key_secret: 'access_key_secret',
|
160
|
-
)
|
161
|
-
end
|
162
|
-
|
163
|
-
it 'request with 400 should ok' do
|
164
|
-
mock_response = { Code: 400, Message: 'error message' }.to_json
|
165
|
-
stub_request(:get, /https:\/\/ecs.aliyuncs.com/).to_return(status: 400, body: mock_response)
|
166
|
-
expect {
|
167
|
-
rpc_client.request(action: 'action')
|
168
|
-
}.to raise_error(StandardError, /error message, URL:/)
|
169
|
-
end
|
170
|
-
end
|
171
|
-
|
172
|
-
describe 'RPC private methods' do
|
173
|
-
|
174
|
-
let(:rpc_client) do
|
175
|
-
RPCClient.new(
|
176
|
-
endpoint: 'https://ecs.aliyuncs.com/',
|
177
|
-
api_version: '1.0',
|
178
|
-
access_key_id: 'access_key_id',
|
179
|
-
access_key_secret: 'access_key_secret',
|
180
|
-
security_token: 'security_token'
|
181
|
-
)
|
182
|
-
end
|
183
|
-
|
184
|
-
it 'formatParams should ok' do
|
185
|
-
expect(rpc_client.send(:format_params, { foo: 1, bar: 2 })).to eq(Foo: 1, Bar: 2)
|
186
|
-
end
|
187
|
-
|
188
|
-
it 'encode should ok' do
|
189
|
-
expect(rpc_client.send(:encode, 'str')).to eq 'str'
|
190
|
-
expect(rpc_client.send(:encode, 'str\'str')).to eq 'str%27str'
|
191
|
-
expect(rpc_client.send(:encode, 'str(str')).to eq 'str%28str'
|
192
|
-
expect(rpc_client.send(:encode, 'str)str')).to eq 'str%29str'
|
193
|
-
expect(rpc_client.send(:encode, 'str*str')).to eq 'str%2Astr'
|
194
|
-
end
|
195
|
-
|
196
|
-
it 'replace_repeat_list should ok' do
|
197
|
-
expect(rpc_client.send(:replace_repeat_list, {}, 'key', [])).to eq({})
|
198
|
-
expect(rpc_client.send(:replace_repeat_list, {}, 'key', ['value'])).to eq({ 'key.1' => 'value' })
|
199
|
-
expect(rpc_client.send(:replace_repeat_list, {}, 'key', [{ :Domain => '1.com' }])).to eq({ 'key.1.Domain' => '1.com' })
|
200
|
-
end
|
201
|
-
|
202
|
-
it 'flat_params should ok' do
|
203
|
-
expect(rpc_client.send(:flat_params, {})).to eq({})
|
204
|
-
expect(rpc_client.send(:flat_params, { key: ['value'] })).to eq({ 'key.1' => 'value' })
|
205
|
-
expect(rpc_client.send(:flat_params, { key: 'value' })).to eq({ 'key' => 'value' })
|
206
|
-
expect(rpc_client.send(:flat_params, { key: [{ Domain: '1.com' }] })).to eq({ 'key.1.Domain' => '1.com' })
|
207
|
-
end
|
208
|
-
|
209
|
-
it 'normalize should ok' do
|
210
|
-
expect(rpc_client.send(:normalize, {})).to be_empty
|
211
|
-
expect(rpc_client.send(:normalize, { key: ['value'] })).to match_array [%w(key.1 value)]
|
212
|
-
expect(rpc_client.send(:normalize, { key: 'value' })).to match_array [%w(key value)]
|
213
|
-
expect(rpc_client.send(:normalize, { key: [{ Domain: '1.com' }] })).to match_array [%w(key.1.Domain 1.com)]
|
214
|
-
expect(rpc_client.send(:normalize, { a: 'value', c: 'value', b: 'value' }))
|
215
|
-
.to match_array [%w(a value), %w(b value), %w(c value)]
|
216
|
-
end
|
217
|
-
|
218
|
-
it 'canonicalize should ok' do
|
219
|
-
expect(rpc_client.send(:canonicalize, [])).to be_empty
|
220
|
-
expect(rpc_client.send(:canonicalize, { foo: 1 })).to eq 'foo=1'
|
221
|
-
expect(rpc_client.send(:canonicalize, [['foo', 1]])).to eq 'foo=1'
|
222
|
-
expect(rpc_client.send(:canonicalize, { foo: 1, bar: 2 })).to eq 'foo=1&bar=2'
|
223
|
-
expect(rpc_client.send(:canonicalize, [['foo', 1], ['bar', 2]])).to eq 'foo=1&bar=2'
|
224
|
-
end
|
225
|
-
end
|
226
|
-
|
227
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,111 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
|
3
|
-
SimpleCov.start do
|
4
|
-
add_filter "/spec/"
|
5
|
-
end
|
6
|
-
|
7
|
-
if ENV['CI'] == 'true'
|
8
|
-
require 'codecov'
|
9
|
-
SimpleCov.formatter = SimpleCov::Formatter::Codecov
|
10
|
-
end
|
11
|
-
|
12
|
-
# This file was generated by the `rspec --init` command. Conventionally, all
|
13
|
-
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
14
|
-
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
15
|
-
# this file to always be loaded, without a need to explicitly require it in any
|
16
|
-
# files.
|
17
|
-
#
|
18
|
-
# Given that it is always loaded, you are encouraged to keep this file as
|
19
|
-
# light-weight as possible. Requiring heavyweight dependencies from this file
|
20
|
-
# will add to the boot time of your test suite on EVERY test run, even for an
|
21
|
-
# individual file that may not need all of that loaded. Instead, consider making
|
22
|
-
# a separate helper file that requires the additional dependencies and performs
|
23
|
-
# the additional setup, and require it from the spec files that actually need
|
24
|
-
# it.
|
25
|
-
#
|
26
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
27
|
-
RSpec.configure do |config|
|
28
|
-
# rspec-expectations config goes here. You can use an alternate
|
29
|
-
# assertion/expectation library such as wrong or the stdlib/minitest
|
30
|
-
# assertions if you prefer.
|
31
|
-
config.expect_with :rspec do |expectations|
|
32
|
-
# This option will default to `true` in RSpec 4. It makes the `description`
|
33
|
-
# and `failure_message` of custom matchers include text for helper methods
|
34
|
-
# defined using `chain`, e.g.:
|
35
|
-
# be_bigger_than(2).and_smaller_than(4).description
|
36
|
-
# # => "be bigger than 2 and smaller than 4"
|
37
|
-
# ...rather than:
|
38
|
-
# # => "be bigger than 2"
|
39
|
-
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
40
|
-
end
|
41
|
-
|
42
|
-
# rspec-mocks config goes here. You can use an alternate test double
|
43
|
-
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
44
|
-
config.mock_with :rspec do |mocks|
|
45
|
-
# Prevents you from mocking or stubbing a method that does not exist on
|
46
|
-
# a real object. This is generally recommended, and will default to
|
47
|
-
# `true` in RSpec 4.
|
48
|
-
mocks.verify_partial_doubles = true
|
49
|
-
end
|
50
|
-
|
51
|
-
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
52
|
-
# have no way to turn it off -- the option exists only for backwards
|
53
|
-
# compatibility in RSpec 3). It causes shared context metadata to be
|
54
|
-
# inherited by the metadata hash of host groups and examples, rather than
|
55
|
-
# triggering implicit auto-inclusion in groups with matching metadata.
|
56
|
-
config.shared_context_metadata_behavior = :apply_to_host_groups
|
57
|
-
|
58
|
-
# The settings below are suggested to provide a good initial experience
|
59
|
-
# with RSpec, but feel free to customize to your heart's content.
|
60
|
-
=begin
|
61
|
-
# This allows you to limit a spec run to individual examples or groups
|
62
|
-
# you care about by tagging them with `:focus` metadata. When nothing
|
63
|
-
# is tagged with `:focus`, all examples get run. RSpec also provides
|
64
|
-
# aliases for `it`, `describe`, and `context` that include `:focus`
|
65
|
-
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
66
|
-
config.filter_run_when_matching :focus
|
67
|
-
|
68
|
-
# Allows RSpec to persist some state between runs in order to support
|
69
|
-
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
70
|
-
# you configure your source control system to ignore this file.
|
71
|
-
config.example_status_persistence_file_path = "spec/examples.txt"
|
72
|
-
|
73
|
-
# Limits the available syntax to the non-monkey patched syntax that is
|
74
|
-
# recommended. For more details, see:
|
75
|
-
# - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/
|
76
|
-
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
77
|
-
# - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode
|
78
|
-
config.disable_monkey_patching!
|
79
|
-
|
80
|
-
# This setting enables warnings. It's recommended, but in some cases may
|
81
|
-
# be too noisy due to issues in dependencies.
|
82
|
-
config.warnings = true
|
83
|
-
|
84
|
-
# Many RSpec users commonly either run the entire suite or an individual
|
85
|
-
# file, and it's useful to allow more verbose output when running an
|
86
|
-
# individual spec file.
|
87
|
-
if config.files_to_run.one?
|
88
|
-
# Use the documentation formatter for detailed output,
|
89
|
-
# unless a formatter has already been configured
|
90
|
-
# (e.g. via a command-line flag).
|
91
|
-
config.default_formatter = "doc"
|
92
|
-
end
|
93
|
-
|
94
|
-
# Print the 10 slowest examples and example groups at the
|
95
|
-
# end of the spec run, to help surface which specs are running
|
96
|
-
# particularly slow.
|
97
|
-
config.profile_examples = 10
|
98
|
-
|
99
|
-
# Run specs in random order to surface order dependencies. If you find an
|
100
|
-
# order dependency and want to debug it, you can fix the order by providing
|
101
|
-
# the seed, which is printed after each run.
|
102
|
-
# --seed 1234
|
103
|
-
config.order = :random
|
104
|
-
|
105
|
-
# Seed global randomization in this process using the `--seed` CLI option.
|
106
|
-
# Setting this allows you to use `--seed` to deterministically reproduce
|
107
|
-
# test failures related to randomization by passing the same `--seed` value
|
108
|
-
# as the one that triggered the failure.
|
109
|
-
Kernel.srand config.seed
|
110
|
-
=end
|
111
|
-
end
|