diff --git a/lib/glueby/wallet.rb b/lib/glueby/wallet.rb index fc8f0af..6ff72a2 100644 --- a/lib/glueby/wallet.rb +++ b/lib/glueby/wallet.rb @@ -5,8 +5,8 @@ class Wallet attr_reader :internal_wallet class << self - def create - new(Glueby::Internal::Wallet.create) + def create(wallet_id = nil) + new(Glueby::Internal::Wallet.create(wallet_id)) end def load(wallet_id) diff --git a/spec/glueby/wallet_spec.rb b/spec/glueby/wallet_spec.rb index d9578f9..0edcc4d 100644 --- a/spec/glueby/wallet_spec.rb +++ b/spec/glueby/wallet_spec.rb @@ -3,7 +3,7 @@ RSpec.describe 'Glueby::Wallet' do class TestWalletAdapter < Glueby::Internal::Wallet::AbstractWalletAdapter def create_wallet(wallet_id = nil) - "wallet_id:1" + wallet_id ? wallet_id : "wallet_id:1" end def list_unspent(wallet_id, only_finalized = true, label = nil, color_id: nil) utxos = [ @@ -112,6 +112,23 @@ def token_utxos(wallet_id, color_id, only_finalized, per, page) end end + describe '#create' do + subject { Glueby::Wallet.create } + + it 'returns Glueby::Wallet instance' do + expect(subject).to be_a Glueby::Wallet + end + + context 'with wallet_id' do + let(:wallet_id) { 'wallet_id' } + subject { Glueby::Wallet.create(wallet_id) } + + it 'created wallet has specified wallet_id' do + expect(subject.id).to eq(wallet_id) + end + end + end + describe '#balances' do subject { wallet.balances(only_finalized) }