spec/client_spec.rb in bitbank-0.1.1 vs spec/client_spec.rb in bitbank-0.1.2
- old
+ new
@@ -27,10 +27,33 @@
Bitbank::Account.any_instance.expects(:address).returns(true) # check
@client.account('newaccount').should == Bitbank::Account.new(@client, 'newaccount')
end
end
+ describe 'account_by_address' do
+ before(:each) do
+ Bitbank::Account.any_instance.stubs(:address).returns(true) # check
+ end
+
+ context 'when the address exists locally' do
+ use_vcr_cassette 'client/address_by_account'
+
+ it 'should retrieve the appropriate account' do
+ account = @client.account_by_address('16FEfkbJHEXnEhZbuNGyFaoCYgVyUtqX6j')
+ account.should == Bitbank::Account.new(@client, 'adent')
+ end
+ end
+
+ context 'when the address does not exist locally' do
+ use_vcr_cassette 'client/address_by_account_not_found'
+
+ it 'should return false' do
+ @client.account_by_address('badaddress').should be_nil
+ end
+ end
+ end
+
describe 'accounts' do
use_vcr_cassette 'client/accounts'
it 'should retrieve all accounts' do
accounts = @client.accounts
@@ -171,9 +194,35 @@
it 'should retrieve transactions for the account' do
transactions = @client.transactions('adent')
transactions.length.should == 1
transactions.last.txid.should == 'txid1'
+ end
+ end
+ end
+
+ describe 'validate_address' do
+ context 'with an invalid address' do
+ use_vcr_cassette 'client/validate_address_invalid'
+
+ it 'should be false' do
+ @client.validate_address('heartofgold').should be_false
+ end
+ end
+
+ context 'with a valid address' do
+ use_vcr_cassette 'client/validate_address_valid'
+
+ it 'should be true' do
+ @client.validate_address('1DSwyVqyhKKQwrdFw3jpAEqnrXEjTcTKMB').should be_true
+ end
+ end
+
+ context 'when local address are not desired' do
+ use_vcr_cassette 'client/validate_address_nolocal'
+
+ it 'should be false and generate a warning' do
+ @client.validate_address('1DSwyVqyhKKQwrdFw3jpAEqnrXEjTcTKMB', true).should be_false
end
end
end
end