bitget.rb 0.8.0 → 0.9.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 +21 -0
- data/README.md +27 -23
- data/lib/Bitget/V2/Client.rb +19 -12
- data/lib/Bitget/VERSION.rb +1 -1
- data/test/V2/Client_test.rb +66 -0
- data/test/helper.rb +14 -7
- metadata +2 -4
- data/lib/Bitget/Configuration.rb +0 -32
- data/test/Configuration_test.rb +0 -87
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3bd1994cc4ea95cfc2714a150370fc1e57e980d4863a4469d86ad8d47730dacb
|
|
4
|
+
data.tar.gz: 750189227ba39d64b44150b52bd10ca04828b6e80c18a4165a4626a484e276e7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d50ee7d4f450ec7eeaa1f58ac8b8c731ad1a9d57d9f1d39ceffb8a5fa8bafc30624bdb6fc66d51d26271b0e82235af1535b24de03e88a26553139ef40ffa9485
|
|
7
|
+
data.tar.gz: ab32e33cade60ba97923a72d18c4fb669a8c76a1b061a5fcde7d07300351882b5ea0464ff656dd1e71c72765ef3edcfba6ded4f644bf8b02d1245f997f34aa06
|
data/CHANGELOG
CHANGED
|
@@ -1,5 +1,26 @@
|
|
|
1
1
|
# bitget/CHANGELOG
|
|
2
2
|
|
|
3
|
+
## 20261115
|
|
4
|
+
|
|
5
|
+
0.9.0: ~ Bitget::Client#initialize: - options:; - Bitget.configure, Bitget::Configuration.
|
|
6
|
+
|
|
7
|
+
1. ~ Bitget::V2::Client#initialize: + debug:, + logger:, - options:. Nothing falls back upon Bitget.configuration, under which a client worked or failed according to what had run before it.
|
|
8
|
+
2. ~ Bitget::V2::Client#initialize: It yields the client being built.
|
|
9
|
+
3. + Bitget::V2::Client#validate_args: The credentials not given raise ArgumentError naming each of them, rather than as a TypeError from OpenSSL or a refusal from Bitget.
|
|
10
|
+
4. ~ Bitget::V2::Client#do_request: The credentials are validated before the request is signed.
|
|
11
|
+
5. - lib/Bitget/Configuration.rb: Bitget::Configuration, Bitget.configure, .configuration, .configuration= and .reset_configuration!.
|
|
12
|
+
6. - test/Configuration_test.rb
|
|
13
|
+
7. ~ test/V2/Client_test.rb: The debug: and logger: keywords and the block set a client; it defaults to nothing; missing credentials raise naming each, before any request; Bitget keeps no configuration.
|
|
14
|
+
8. ~ test/helper.rb: - the reset of Bitget.configuration before each test.
|
|
15
|
+
9. ~ README.md: The Setup and Logging sections give everything to the client, and the Configuration section is gone. The installation instructions name the gem bitget, not bitget.rb.
|
|
16
|
+
10. ~ Bitget::VERSION: /0.8.1/0.9.0/
|
|
17
|
+
|
|
18
|
+
0.8.1: Fix the tests failing to load WebMock.
|
|
19
|
+
|
|
20
|
+
1. ~ test/helper.rb: + skip_webmocks_http_rb_adapter, so as to disambiguate the http gem from the http.rb gem.
|
|
21
|
+
2. ~ Bitget::VERSION: /0.8.0/0.8.1/
|
|
22
|
+
|
|
23
|
+
|
|
3
24
|
## 20260925
|
|
4
25
|
|
|
5
26
|
0.8.0: /lib/Bitget.rb/lib/bitget.rb/, a lowercase load file.
|
data/README.md
CHANGED
|
@@ -9,7 +9,7 @@ Access the Bitget API with Ruby.
|
|
|
9
9
|
Add this line to your application's Gemfile:
|
|
10
10
|
|
|
11
11
|
```ruby
|
|
12
|
-
gem 'bitget
|
|
12
|
+
gem 'bitget'
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
And then execute:
|
|
@@ -21,7 +21,7 @@ $ bundle
|
|
|
21
21
|
Or install it yourself as:
|
|
22
22
|
|
|
23
23
|
```bash
|
|
24
|
-
$ gem install bitget
|
|
24
|
+
$ gem install bitget
|
|
25
25
|
```
|
|
26
26
|
|
|
27
27
|
## Usage
|
|
@@ -36,32 +36,35 @@ bitget_client = Bitget::Client.new(
|
|
|
36
36
|
)
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
Everything a client uses is given to it: `api_key:`, `api_secret:`, `api_passphrase:`,
|
|
40
|
+
`debug:` and `logger:`. Each has a setter of its own, and the client is yielded while it is
|
|
41
|
+
being built, so these are the same:
|
|
42
42
|
|
|
43
43
|
```ruby
|
|
44
|
-
Bitget.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
44
|
+
bitget_client = Bitget::Client.new do |c|
|
|
45
|
+
c.api_key = 'api_key0'
|
|
46
|
+
c.api_secret = 'api_secret0'
|
|
47
|
+
c.api_passphrase = 'api_passphrase0'
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
bitget_client = Bitget::Client.new
|
|
51
|
+
bitget_client.api_key = 'api_key0'
|
|
52
|
+
bitget_client.api_secret = 'api_secret0'
|
|
53
|
+
bitget_client.api_passphrase = 'api_passphrase0'
|
|
51
54
|
```
|
|
52
55
|
|
|
53
|
-
The
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
credentials are named arguments; the rest go under `options`.
|
|
56
|
+
The client keeps nothing in common with any other, and reads nothing from the environment
|
|
57
|
+
or from a file: where the settings come from is the program's business. Credentials not
|
|
58
|
+
given raise at the first request, before anything is sent, naming each of them:
|
|
57
59
|
|
|
58
60
|
```ruby
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
options: {logger: Logger.new('bitget.log', 'daily')}
|
|
62
|
-
)
|
|
61
|
+
Bitget::Client.new(api_key: 'api_key0', api_secret: 'api_secret0').spot_public_coins
|
|
62
|
+
# => ArgumentError: api_passphrase is missing.
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
+
Before 0.9.0 the settings could be declared once with `Bitget.configure`, and every client
|
|
66
|
+
fell back upon them, the rest going under `options:`. Pass them to each client instead.
|
|
67
|
+
|
|
65
68
|
### Logging
|
|
66
69
|
|
|
67
70
|
A client logs when it has somewhere to log to, and not at all when it does not. Hand it any
|
|
@@ -70,9 +73,12 @@ object answering to `#info` and `#error`; the standard library's `Logger` will d
|
|
|
70
73
|
```ruby
|
|
71
74
|
require 'logger'
|
|
72
75
|
|
|
73
|
-
Bitget.
|
|
74
|
-
|
|
75
|
-
|
|
76
|
+
bitget_client = Bitget::Client.new(
|
|
77
|
+
api_key: 'api_key0',
|
|
78
|
+
api_secret: 'api_secret0',
|
|
79
|
+
api_passphrase: 'api_passphrase0',
|
|
80
|
+
logger: Logger.new($stdout)
|
|
81
|
+
)
|
|
76
82
|
```
|
|
77
83
|
|
|
78
84
|
`Logger` rotates by itself, so a daily log file wants no more than its second argument. It
|
|
@@ -85,9 +91,7 @@ require 'logger'
|
|
|
85
91
|
log_file_path = File.expand_path(File.join(%w{~ log bitget log.txt}))
|
|
86
92
|
FileUtils.mkdir_p(File.dirname(log_file_path))
|
|
87
93
|
|
|
88
|
-
|
|
89
|
-
config.logger = Logger.new(log_file_path, 'daily')
|
|
90
|
-
end
|
|
94
|
+
bitget_client.logger = Logger.new(log_file_path, 'daily')
|
|
91
95
|
```
|
|
92
96
|
|
|
93
97
|
Before 0.6.0 the client chose the path, created the directory and rotated the file itself. It
|
data/lib/Bitget/V2/Client.rb
CHANGED
|
@@ -8,7 +8,6 @@ require 'json'
|
|
|
8
8
|
require 'logger'
|
|
9
9
|
require 'openssl'
|
|
10
10
|
|
|
11
|
-
require_relative '../Configuration'
|
|
12
11
|
require_relative '../Error'
|
|
13
12
|
|
|
14
13
|
module Bitget
|
|
@@ -1812,17 +1811,24 @@ module Bitget
|
|
|
1812
1811
|
|
|
1813
1812
|
private
|
|
1814
1813
|
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1814
|
+
def initialize(api_key: nil, api_secret: nil, api_passphrase: nil, debug: false, logger: nil)
|
|
1815
|
+
@api_key = api_key
|
|
1816
|
+
@api_secret = api_secret
|
|
1817
|
+
@api_passphrase = api_passphrase
|
|
1818
|
+
@debug = debug
|
|
1819
|
+
@logger = logger
|
|
1820
|
+
yield(self) if block_given?
|
|
1821
|
+
end
|
|
1822
|
+
|
|
1823
|
+
def validate_args(args)
|
|
1824
|
+
missing_args = []
|
|
1825
|
+
args.each do |arg_name, value|
|
|
1826
|
+
missing_args << arg_name unless value
|
|
1827
|
+
end
|
|
1828
|
+
return if missing_args.empty?
|
|
1829
|
+
aggregate_error = missing_args.join(', ')
|
|
1830
|
+
copula = missing_args.count > 1 ? 'are' : 'is'
|
|
1831
|
+
raise ArgumentError, "#{aggregate_error} #{copula} missing."
|
|
1826
1832
|
end
|
|
1827
1833
|
|
|
1828
1834
|
def full_path(path)
|
|
@@ -1907,6 +1913,7 @@ module Bitget
|
|
|
1907
1913
|
end
|
|
1908
1914
|
|
|
1909
1915
|
def do_request(verb:, path:, args: {})
|
|
1916
|
+
validate_args(api_key: @api_key, api_secret: @api_secret, api_passphrase: @api_passphrase)
|
|
1910
1917
|
sorted_args = args.reject{|_, v| v.nil?}.sort.to_h
|
|
1911
1918
|
message = message(verb: verb, path: path, args: sorted_args)
|
|
1912
1919
|
signature = signature(message)
|
data/lib/Bitget/VERSION.rb
CHANGED
data/test/V2/Client_test.rb
CHANGED
|
@@ -13,6 +13,72 @@ describe Bitget::V2::Client do
|
|
|
13
13
|
)
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
describe "#initialize" do
|
|
17
|
+
it "takes debug and logger as keywords" do
|
|
18
|
+
logger = Logger.new(StringIO.new)
|
|
19
|
+
client = Bitget::V2::Client.new(debug: true, logger: logger)
|
|
20
|
+
_(client.debug).must_equal(true)
|
|
21
|
+
_(client.logger).must_equal(logger)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "defaults to no credentials, no debugging and no logger" do
|
|
25
|
+
client = Bitget::V2::Client.new
|
|
26
|
+
_(client.api_key).must_be_nil
|
|
27
|
+
_(client.api_secret).must_be_nil
|
|
28
|
+
_(client.api_passphrase).must_be_nil
|
|
29
|
+
_(client.debug).must_equal(false)
|
|
30
|
+
_(client.logger).must_be_nil
|
|
31
|
+
_(client.send(:use_logging?)).must_equal(false)
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
it "yields the client being built" do
|
|
35
|
+
yielded = nil
|
|
36
|
+
client = Bitget::V2::Client.new do |c|
|
|
37
|
+
yielded = c
|
|
38
|
+
c.api_key = 'a_key'
|
|
39
|
+
c.api_secret = 'a_secret'
|
|
40
|
+
c.api_passphrase = 'a_passphrase'
|
|
41
|
+
end
|
|
42
|
+
_(yielded).must_be_same_as(client)
|
|
43
|
+
_(client.api_key).must_equal('a_key')
|
|
44
|
+
_(client.api_secret).must_equal('a_secret')
|
|
45
|
+
_(client.api_passphrase).must_equal('a_passphrase')
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "is the same for Bitget::Client" do
|
|
49
|
+
client = Bitget::Client.new(api_key: 'a_key'){|c| c.api_secret = 'a_secret'}
|
|
50
|
+
_(client.api_key).must_equal('a_key')
|
|
51
|
+
_(client.api_secret).must_equal('a_secret')
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe "missing credentials" do
|
|
56
|
+
let(:credentials){{api_key: 'a_key', api_secret: 'a_secret', api_passphrase: 'a_passphrase'}}
|
|
57
|
+
|
|
58
|
+
%i{api_key api_secret api_passphrase}.each do |name|
|
|
59
|
+
it "raises naming #{name} before anything is sent" do
|
|
60
|
+
client = Bitget::V2::Client.new(**credentials.reject{|k, _| k == name})
|
|
61
|
+
error = _{client.spot_public_coins}.must_raise(ArgumentError)
|
|
62
|
+
_(error.message).must_equal("#{name} is missing.")
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "raises naming every one missing" do
|
|
67
|
+
client = Bitget::V2::Client.new(api_secret: 'a_secret')
|
|
68
|
+
error = _{client.spot_public_coins}.must_raise(ArgumentError)
|
|
69
|
+
_(error.message).must_equal('api_key, api_passphrase are missing.')
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
describe "Bitget" do
|
|
74
|
+
it "keeps no configuration of its own" do
|
|
75
|
+
%i{configure configuration configuration= reset_configuration!}.each do |name|
|
|
76
|
+
_(Bitget.respond_to?(name)).must_equal(false)
|
|
77
|
+
end
|
|
78
|
+
_(defined?(Bitget::Configuration)).must_be_nil
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
16
82
|
describe "where a request is addressed" do
|
|
17
83
|
# Written out rather than built from API_HOST and .path_prefix, which would
|
|
18
84
|
# pass however wrong either of them was.
|
data/test/helper.rb
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# webmock's http_rb adapter's require 'http' finds http.rb's lib/http.rb,
|
|
2
|
+
# takes HTTP::VERSION for the http gem's, and crashes trying to
|
|
3
|
+
# monkey-patch an HTTP::Client which isn't there.
|
|
4
|
+
def skip_webmocks_http_rb_adapter
|
|
5
|
+
gem 'webmock'
|
|
6
|
+
|
|
7
|
+
$LOADED_FEATURES << File.join(
|
|
8
|
+
Gem.loaded_specs['webmock'].full_gem_path,
|
|
9
|
+
'lib/webmock/http_lib_adapters/http_rb_adapter.rb'
|
|
10
|
+
)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
skip_webmocks_http_rb_adapter
|
|
14
|
+
|
|
1
15
|
require 'minitest/autorun'
|
|
2
16
|
require 'minitest/mock'
|
|
3
17
|
require 'minitest/spec'
|
|
@@ -18,10 +32,3 @@ VCR.configure do |config|
|
|
|
18
32
|
config.filter_sensitive_data('<API_SECRET>'){ENV['BITGET_API_SECRET'] }
|
|
19
33
|
config.filter_sensitive_data('<API_PASSPHRASE>'){ENV['BITGET_API_PASSPHRASE']}
|
|
20
34
|
end
|
|
21
|
-
|
|
22
|
-
class Minitest::Test
|
|
23
|
-
def before_setup
|
|
24
|
-
super
|
|
25
|
-
Bitget.reset_configuration!
|
|
26
|
-
end
|
|
27
|
-
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: bitget.rb
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.9.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thoran
|
|
@@ -36,7 +36,6 @@ files:
|
|
|
36
36
|
- Rakefile
|
|
37
37
|
- bitget.rb.gemspec
|
|
38
38
|
- lib/Bitget/Client.rb
|
|
39
|
-
- lib/Bitget/Configuration.rb
|
|
40
39
|
- lib/Bitget/ERROR_CODES.rb
|
|
41
40
|
- lib/Bitget/Error.rb
|
|
42
41
|
- lib/Bitget/V2/Client.rb
|
|
@@ -44,7 +43,6 @@ files:
|
|
|
44
43
|
- lib/String/url_encode.rb
|
|
45
44
|
- lib/Thoran/String/UrlEncode/url_encode.rb
|
|
46
45
|
- lib/bitget.rb
|
|
47
|
-
- test/Configuration_test.rb
|
|
48
46
|
- test/ERROR_CODES_test.rb
|
|
49
47
|
- test/Error_test.rb
|
|
50
48
|
- test/V2/Client_test.rb
|
|
@@ -69,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
69
67
|
- !ruby/object:Gem::Version
|
|
70
68
|
version: '0'
|
|
71
69
|
requirements: []
|
|
72
|
-
rubygems_version: 4.0.
|
|
70
|
+
rubygems_version: 4.0.23
|
|
73
71
|
specification_version: 4
|
|
74
72
|
summary: Access the Bitget API with Ruby.
|
|
75
73
|
test_files: []
|
data/lib/Bitget/Configuration.rb
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# Bitget/Configuration.rb
|
|
2
|
-
# Bitget::Configuration
|
|
3
|
-
|
|
4
|
-
module Bitget
|
|
5
|
-
class Configuration
|
|
6
|
-
attr_accessor :api_key, :api_secret, :api_passphrase, :debug, :logger
|
|
7
|
-
|
|
8
|
-
def initialize
|
|
9
|
-
@api_key = nil
|
|
10
|
-
@api_secret = nil
|
|
11
|
-
@api_passphrase = nil
|
|
12
|
-
@debug = false
|
|
13
|
-
@logger = nil
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
class << self
|
|
18
|
-
attr_writer :configuration
|
|
19
|
-
|
|
20
|
-
def configuration
|
|
21
|
-
@configuration ||= Configuration.new
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
def configure
|
|
25
|
-
yield(configuration)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def reset_configuration!
|
|
29
|
-
@configuration = Configuration.new
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|
data/test/Configuration_test.rb
DELETED
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
require_relative './helper'
|
|
2
|
-
|
|
3
|
-
describe Bitget::Configuration do
|
|
4
|
-
describe "#initialize" do
|
|
5
|
-
it "sets default values" do
|
|
6
|
-
config = Bitget::Configuration.new
|
|
7
|
-
_(config.debug).must_equal(false)
|
|
8
|
-
_(config.api_key).must_be_nil
|
|
9
|
-
_(config.api_secret).must_be_nil
|
|
10
|
-
_(config.api_passphrase).must_be_nil
|
|
11
|
-
_(config.logger).must_be_nil
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
it "declares a setting for everything a client reads" do
|
|
15
|
-
_(Bitget::Configuration.new.public_methods(false).grep(/[^=]\z/).sort) \
|
|
16
|
-
.must_equal(%i{api_key api_passphrase api_secret debug logger})
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
# The credentials are named arguments and fall back upon nil, having no
|
|
21
|
-
# meaningful nil of their own. The options are given under options: and fall
|
|
22
|
-
# back upon the key being absent, nil being a value a caller may mean.
|
|
23
|
-
describe "the credentials, which are named arguments" do
|
|
24
|
-
before do
|
|
25
|
-
Bitget.configure do |config|
|
|
26
|
-
config.api_key = 'configured_key'
|
|
27
|
-
config.api_secret = 'configured_secret'
|
|
28
|
-
config.api_passphrase = 'configured_passphrase'
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
it "supplies every one, so that a client needs no arguments at all" do
|
|
33
|
-
client = Bitget::Client.new
|
|
34
|
-
_(client.api_key).must_equal('configured_key')
|
|
35
|
-
_(client.api_secret).must_equal('configured_secret')
|
|
36
|
-
_(client.api_passphrase).must_equal('configured_passphrase')
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "yields to each one given, and only to that one" do
|
|
40
|
-
_(Bitget::Client.new(api_key: 'given').api_key).must_equal('given')
|
|
41
|
-
_(Bitget::Client.new(api_key: 'given').api_secret).must_equal('configured_secret')
|
|
42
|
-
_(Bitget::Client.new(api_secret: 'given').api_secret).must_equal('given')
|
|
43
|
-
_(Bitget::Client.new(api_secret: 'given').api_key).must_equal('configured_key')
|
|
44
|
-
_(Bitget::Client.new(api_passphrase: 'given').api_passphrase).must_equal('given')
|
|
45
|
-
_(Bitget::Client.new(api_passphrase: 'given').api_key).must_equal('configured_key')
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
it "is unreachable where nothing is configured and nothing is given" do
|
|
49
|
-
Bitget.reset_configuration!
|
|
50
|
-
client = Bitget::Client.new
|
|
51
|
-
_(client.api_key).must_be_nil
|
|
52
|
-
_(client.api_secret).must_be_nil
|
|
53
|
-
_(client.api_passphrase).must_be_nil
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
describe "the options, which are given under options:" do
|
|
58
|
-
let(:logger){Logger.new(StringIO.new)}
|
|
59
|
-
|
|
60
|
-
before do
|
|
61
|
-
Bitget.configure do |config|
|
|
62
|
-
config.debug = true
|
|
63
|
-
config.logger = logger
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
it "supplies every one" do
|
|
68
|
-
client = Bitget::Client.new
|
|
69
|
-
_(client.debug).must_equal(true)
|
|
70
|
-
_(client.logger).must_equal(logger)
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it "yields to each one given, and only to that one" do
|
|
74
|
-
other = Logger.new(StringIO.new)
|
|
75
|
-
_(Bitget::Client.new(options: {debug: false}).debug).must_equal(false)
|
|
76
|
-
_(Bitget::Client.new(options: {debug: false}).logger).must_equal(logger)
|
|
77
|
-
_(Bitget::Client.new(options: {logger: other}).logger).must_equal(other)
|
|
78
|
-
_(Bitget::Client.new(options: {logger: other}).debug).must_equal(true)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "takes nil as a value rather than as an absence" do
|
|
82
|
-
client = Bitget::Client.new(options: {logger: nil})
|
|
83
|
-
_(client.logger).must_be_nil
|
|
84
|
-
_(client.send(:use_logging?)).must_equal(false)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|