Initial commit
This commit is contained in:
commit
4b5f7906d7
33 files changed
+933
No files matched your search
@@ -0,0 +1,54 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe StrikeMe::API::Account::Balances do
|
||||
subject { StrikeMe::API::Account.new.balances }
|
||||
context 'good response' do
|
||||
let(:server_response) do
|
||||
[
|
||||
{
|
||||
'currency' => 'BTC',
|
||||
'current' => '0.003169',
|
||||
'pending' => '0',
|
||||
'outgoing' => '0',
|
||||
'reserved' => '0',
|
||||
'available' => '0.003169',
|
||||
'total' => '0.00316976'
|
||||
},
|
||||
{
|
||||
'currency' => 'USDT',
|
||||
'current' => '50.73',
|
||||
'pending' => '0.00',
|
||||
'outgoing' => '0.00',
|
||||
'reserved' => '0.00',
|
||||
'available' => '50.73',
|
||||
'total' => '50.73'
|
||||
}
|
||||
]
|
||||
end
|
||||
before { allow_any_instance_of(StrikeMe::API::Client).to receive(:get).and_return double(success?: true, body: server_response) }
|
||||
|
||||
it '#to_a returns a simple object representation, where number string inputs are real numbers' do
|
||||
expected = [
|
||||
{
|
||||
'currency' => 'BTC',
|
||||
'current' => 0.003169,
|
||||
'pending' => 0.0,
|
||||
'outgoing' => 0.0,
|
||||
'reserved' => 0.0,
|
||||
'available' => 0.003169,
|
||||
'total' => 0.00316976
|
||||
},
|
||||
{
|
||||
'currency' => 'USDT',
|
||||
'current' => 50.73,
|
||||
'pending' => 0.0,
|
||||
'outgoing' => 0.0,
|
||||
'reserved' => 0.0,
|
||||
'available' => 50.73,
|
||||
'total' => 50.73
|
||||
}
|
||||
]
|
||||
expect(subject.to_a).to eq expected
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe StrikeMe::API::Account::Profile do
|
||||
context 'good response' do
|
||||
let(:server_response) do
|
||||
{
|
||||
'id' => '02ad532c-2bd0-4b4b-8c06-a2b2dd3f2b0c',
|
||||
'handle' => 'strikerrr3',
|
||||
'canReceive' => true,
|
||||
'currencies' => [
|
||||
{ 'currency' => 'USDT', 'isDefaultCurrency' => false, 'isAvailable' => true, 'isInvoiceable' => true },
|
||||
{ 'currency' => 'BTC', 'isDefaultCurrency' => true, 'isAvailable' => true, 'isInvoiceable' => true }
|
||||
]
|
||||
}
|
||||
end
|
||||
before { allow_any_instance_of(StrikeMe::API::Client).to receive(:get).and_return double(success?: true, body: server_response) }
|
||||
end
|
||||
subject { described_class.new }
|
||||
end
|
||||
@@ -0,0 +1,34 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe StrikeMe::API::Account do
|
||||
subject { described_class.new }
|
||||
|
||||
describe 'profile' do
|
||||
subject { described_class.new.profile }
|
||||
|
||||
it 'works with STRIKE_ACCOUNT_ID' do
|
||||
allow(ENV).to receive(:[])
|
||||
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: 200, body: '{"id":"abc44"}')
|
||||
expect(subject.id).to eq 'abc44'
|
||||
end
|
||||
|
||||
it 'works with STRIKE_ACCOUNT_HANDLE without account id' do
|
||||
allow(ENV).to receive(:[])
|
||||
allow(ENV).to receive(:fetch)
|
||||
expect(ENV).to receive(:fetch).with('STRIKE_ACCOUNT_HANDLE').and_return 'abcd'
|
||||
stub_request(:get, %r{https://api.strike.me/v1/accounts/handles/abcd/profile})
|
||||
.to_return(status: 200, body: '{"id":"abc44"}')
|
||||
expect(subject.id).to eq 'abc44'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'balances' do
|
||||
subject { described_class.new.balances }
|
||||
|
||||
before { stub_request(:get, 'https://api.strike.me/v1/balances').to_return(status: 200, body: []) }
|
||||
|
||||
it { is_expected.to be_an_instance_of StrikeMe::API::Account::Balances }
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe StrikeMe::API::Client do
|
||||
subject { described_class.new }
|
||||
|
||||
it 'does things', pending: 'await more structure' do
|
||||
expect(2).to eq 3
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
RSpec.describe StrikeMe::API::InvoiceResponse do
|
||||
let(:valid_attributes) { { ok: true, checking_id: 'abc1', payment_request: 'abc2', error_message: 'abc3' } }
|
||||
let(:invalid_attributes) { valid_attributes.merge(ok: false) }
|
||||
|
||||
context 'valid response' do
|
||||
subject { described_class.new(valid_attributes) }
|
||||
|
||||
it { is_expected.to be_a StrikeMe::API::BaseModel }
|
||||
it { is_expected.to be_valid }
|
||||
it { is_expected.to have_attributes checking_id: 'abc1', payment_request: 'abc2', error_message: 'abc3' }
|
||||
end
|
||||
|
||||
context 'invalid response' do
|
||||
subject { described_class.new(invalid_attributes) }
|
||||
|
||||
it { is_expected.to_not be_valid }
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user