spec/lib/aba/transaction_spec.rb in aba-1.0.1 vs spec/lib/aba/transaction_spec.rb in aba-1.0.2
- old
+ new
@@ -1,5 +1,7 @@
+# frozen_string_literal: true
+
# encoding: UTF-8
require "spec_helper"
describe Aba::Transaction do
@@ -40,12 +42,33 @@
describe "#valid?" do
it "should be valid" do
expect(subject.valid?).to eq true
end
- it "should not be valid" do
- transaction_params.delete(:bsb)
- expect(subject.valid?).to eq false
- expect(subject.errors).to eq ["bsb format is incorrect"]
+ context "without bsb param" do
+ before do
+ transaction_params.delete(:bsb)
+ end
+
+ it "is invalid" do
+ expect(subject.valid?).to eq false
+ expect(subject.errors).to eq ["bsb format is incorrect"]
+ end
+ end
+
+ describe ":amount" do
+ subject(:transaction) { Aba::Transaction.new(transaction_params.merge(amount: amount)) }
+
+ context "with 10 digits" do
+ let(:amount) { "1234567890" }
+
+ it { is_expected.to be_valid }
+ end
+
+ context "with 11 digits" do
+ let(:amount) { "12345678901" }
+
+ it { is_expected.not_to be_valid }
+ end
end
end
end