summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorJared Norman <jared@super.gd>2019-01-21 20:57:29 -0800
committerJared Norman <jared@super.gd>2019-01-21 21:08:50 -0800
commit40b63f8f069b6d869619bbfcb1554a7e7cbcbe57 (patch)
tree32a576e4f61e59a36111912b232622fd4f094780 /spec
parentd5b84c70cfad6bcb98bee422ce2865dbf8ae386f (diff)
Handle errors gracefully
Diffstat (limited to 'spec')
-rw-r--r--spec/super_good/solidus_taxjar/tax_calculator_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
index 875f428..87d30c4 100644
--- a/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
+++ b/spec/super_good/solidus_taxjar/tax_calculator_spec.rb
@@ -71,6 +71,34 @@ RSpec.describe ::SuperGood::SolidusTaxJar::TaxCalculator do
end
end
+ context "when the API encounters an error" do
+ let(:address) do
+ ::Spree::Address.new(
+ first_name: "Ronnie James",
+ country: ::Spree::Country.new(iso: "US")
+ )
+ end
+
+ before do
+ allow(dummy_api).to receive(:tax_for).with(order).and_raise("A bad thing happened.")
+ end
+
+ it "calls the configured error handler" do
+ expect(described_class.exception_handler).to receive(:call) do |e|
+ expect(e).to be_a StandardError
+ expect(e.message).to eq "A bad thing happened."
+ end
+
+ subject
+ end
+
+ it "returns no taxes" do
+ expect(subject.order_id).to eq order.id
+ expect(subject.shipment_taxes).to be_empty
+ expect(subject.line_item_taxes).to be_empty
+ end
+ end
+
context "when the order has a non-empty tax address" do
let(:address) do
::Spree::Address.new(