From f33b978be8d08cec6529ecd0ad62fa92c2db290b Mon Sep 17 00:00:00 2001 From: Chris Todorov Date: Fri, 20 Jan 2023 13:25:50 -0800 Subject: [PATCH] Update spec setup to reset state in `before` block In a recent change to core, an `after(:build)` hook was added to set the state on the address record for countries which require states. This interferes with the spec setup by ignoring the state attribute we were setting to `nil`. Instead we have moved that to a `before` block so that we can correctly setup the test address to not have a state. Relevant change upstream - https://github.com/solidusio/solidus/pull/4272 Co-authored-by: Andrew Stewart --- .../solidus_taxjar/calculator_helper_spec.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/spec/super_good/solidus_taxjar/calculator_helper_spec.rb b/spec/super_good/solidus_taxjar/calculator_helper_spec.rb index 14472ffc..93bc9121 100644 --- a/spec/super_good/solidus_taxjar/calculator_helper_spec.rb +++ b/spec/super_good/solidus_taxjar/calculator_helper_spec.rb @@ -24,12 +24,18 @@ class TestProxy end context "with a missing state in CA" do - let(:address) { build :address, country_iso_code: "CA", state: nil } + let(:address) { build :address, country_iso_code: "CA" } + + before { address.state = nil } + it { is_expected.to eq(true) } end context "with a missing state in US" do - let(:address) { build :address, country_iso_code: "US", state: nil } + let(:address) { build :address, country_iso_code: "US" } + + before { address.state = nil } + it { is_expected.to eq(true) } end