Sha256: d06ae85a22480b3046107f6e1f21839c73d2fcc6e7ce9e179d205888300cbfba

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

require "spec_helper"

module BitWallet
  describe HandlesError do
    describe ".from" do
      context "error is -3" do
        it "raises InvalidAmount error" do
          expect { described_class.from("does not matter -3 meh") }.
            to raise_error(InvalidAmount, "amount is invalid")
        end
      end

      context "error is -5" do
        it "raises InvalidAddress error" do
          expect { described_class.from("some error -5 message") }.
            to raise_error(InvalidAddress, "bitcoin address is invalid")
        end
      end

      context "error is -6" do
        it "raises InsufficientFunds error" do
          expect { described_class.from("-6 message") }.
            to raise_error(InsufficientFunds, "cannot send an amount more than what this account has")
        end
      end

      context "error is unknown" do
        it "raises an ArgumentError" do
          expect { described_class.from("-99 I do not know") }.
            to raise_error(ArgumentError, "unknown error: -99 I do not know")
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
bit_wallet-0.7.6 spec/bit_wallet/handles_error_spec.rb
bit_wallet-0.7.5 spec/bit_wallet/handles_error_spec.rb
bit_wallet-0.7.3 spec/bit_wallet/handles_error_spec.rb
bit_wallet-0.7.2 spec/bit_wallet/handles_error_spec.rb
bit_wallet-0.7.1 spec/bit_wallet/handles_error_spec.rb
bit_wallet-0.7.0 spec/bit_wallet/handles_error_spec.rb
bit_wallet-0.6.1 spec/bit_wallet/handles_error_spec.rb
bit_wallet-0.6.0 spec/bit_wallet/handles_error_spec.rb