spec/account_spec.rb in bitbank-0.1.1 vs spec/account_spec.rb in bitbank-0.1.2

- old
+ new

@@ -12,11 +12,11 @@ describe 'address' do use_vcr_cassette 'account/address' it 'should retrieve the address for this account' do - @account.address.should == '1NqwGDRi9Gs4xm1BmPnGeMwgz1CowP6CeQ' + @account.address.should == '16FEfkbJHEXnEhZbuNGyFaoCYgVyUtqX6j' end it 'should be validated on account creation if a check was requested (default)' do Bitbank::Account.any_instance.expects(:address) Bitbank::Account.new(@client, 'trill', nil, true) @@ -56,15 +56,34 @@ @account.new_address.should == '15GsE7o3isyQ7ygzh8Cya58oetrGYygdoi' end end describe 'pay' do - use_vcr_cassette 'account/pay' + context 'when the recipient address is valid' do + use_vcr_cassette 'account/pay' - it 'should return a new transaction' do - transaction = @account.pay('destinationaddress', 0.01) - transaction.amount.should == 0.01 - transaction.account.should == @account + it 'should return a new transaction' do + transaction = @account.pay('15VjRaDX9zpbA8LVnbrCAFzrVzN7ixHNsC', 0.02) + transaction.amount.should == -0.02 + transaction.account.should == @account + end + end + + context 'when the recipient address is invalid' do + use_vcr_cassette 'account/pay_invalid' + + it 'should return false' do + @account.pay('invalidaddress', 0.01).should be_false + end + end + + context 'when the recipient address is a local address' do + use_vcr_cassette 'account/pay_local' + + it 'should warn the user and return false' do + @client.expects(:warn) + @account.pay('1DSwyVqyhKKQwrdFw3jpAEqnrXEjTcTKMB', 0.01).should be_false + end end end describe 'transactions' do use_vcr_cassette 'account/transactions'