rubocop corrections

This commit is contained in:
bterkuile committed 2025-10-18 09:29:55 -05:00
1 parent 4b84df0af9
commit 4a7b752ace
4 files changed
+50 -39

No files matched your search

+14
View File
@@ -13,3 +13,17 @@ Style/Documentation:
Metrics/BlockLength:
Exclude:
- 'spec/**/*'
# The next 3 rubocop enabled disallow visual alignment (EasyAlign)
Layout/ExtraSpacing:
Enabled: false
Layout/HashAlignment:
Enabled: false
Layout/SpaceBeforeFirstArg:
Enabled: false
Layout/SpaceInsideHashLiteralBraces:
Enabled: false
Layout/LineLength:
Exclude:
- 'spec/**/*'
+10 -14
View File
@@ -2,7 +2,6 @@
module StrikeMe
module API
# Factory helper object connecting the client to the models
class Account
include BaseClient
@@ -16,14 +15,13 @@ module StrikeMe
url = profile_url
response = client.get url
#body = response.body.presence
#body = JSON.parse(body) if body.is_a? String
if response.success?
@profile = Profile.new response.body.merge(account: self)
else
# if you see this, something went wrong, this is test code
raise ResponseError.new(url, response.body)
end
# body = response.body.presence
# body = JSON.parse(body) if body.is_a? String
raise ResponseError.new(url, response.body) unless response.success?
@profile = Profile.new response.body.merge(account: self)
# if you see this, something went wrong, this is test code
end
def profile_url
@@ -39,11 +37,9 @@ module StrikeMe
return @balances if @balances.present?
response = client.get 'balances'
if response.success?
@balances = Balances.new self, response.body
else
raise ResponseError.new('balances', response.body)
end
raise ResponseError.new('balances', response.body) unless response.success?
@balances = Balances.new self, response.body
end
def inspect
+1 -1
View File
@@ -22,7 +22,7 @@ module StrikeMe
end
end
#delegate :get, to: :connection
# delegate :get, to: :connection
def get(...)
@last_response = connection.get(...)
end
+25 -24
View File
@@ -28,7 +28,7 @@ RSpec.describe StrikeMe::API::Account do
expect(ENV).to receive(:[]).with('STRIKE_ACCOUNT_ID').and_return 'abc'
stub_request(:get, %r{https://api.strike.me/v1/accounts/abc/profile})
.to_return(status: 401, body: '{"data":{"status":401,"code":"UNAUTHORIZED","message":"Invalid or unspecified identity."}}', headers: {'Content-Type' => 'application/json'})
expect{ subject.id }.to raise_error '[401, {}, ["Invalid or unspecified identity."]]'
expect { subject.id }.to raise_error '[401, {}, ["Invalid or unspecified identity."]]'
end
end
@@ -42,22 +42,23 @@ RSpec.describe StrikeMe::API::Account do
it '#to_a properly returns the attributes' do
expect(subject.to_a).to eq [
{
"currency" => "BTC",
"current" => 0.00085408,
"pending" => 2.3e-05,
"outgoing" => 5.32e-06,
"reserved" => 0.00234,
"available" => 0.00085408,
"total" => 0.00085408
'currency' => 'BTC',
'current' => 0.00085408,
'pending' => 2.3e-05,
'outgoing' => 5.32e-06,
'reserved' => 0.00234,
'available' => 0.00085408,
'total' => 0.00085408
}, {
"currency" => "USDT",
"current" => 50.04,
"pending" => 40.06,
"outgoing" => 60.15,
"reserved" => 0.0,
"available" => 0.0,
"total" => 0.0
}]
'currency' => 'USDT',
'current' => 50.04,
'pending' => 40.06,
'outgoing' => 60.15,
'reserved' => 0.0,
'available' => 0.0,
'total' => 0.0
}
]
end
it '#btc returns the BTC balance' do
@@ -65,20 +66,20 @@ RSpec.describe StrikeMe::API::Account do
expect(btc).to be_present
expect(btc).to be_a StrikeMe::API::Account::Balance
expect(btc.attributes).to eq(
"available" => 0.00085408,
"currency" => "BTC",
"current" => 0.00085408,
"outgoing" => 5.32e-06,
"pending" => 2.3e-05,
"reserved" => 0.00234,
"total" => 0.00085408
'available' => 0.00085408,
'currency' => 'BTC',
'current' => 0.00085408,
'outgoing' => 5.32e-06,
'pending' => 2.3e-05,
'reserved' => 0.00234,
'total' => 0.00085408
)
end
it 'raises error when not authorized' do
stub_request(:get, %r{https://api.strike.me/v1/balances})
.to_return(status: 401, body: '{"data":{"status":403,"code":"FORBIDDEN","message":"Insufficient permissions."}}', headers: {'Content-Type' => 'application/json'})
expect{ subject }.to raise_error '[403, {}, ["Insufficient permissions."]]'
expect { subject }.to raise_error '[403, {}, ["Insufficient permissions."]]'
end
end
end