Sha256: 220053d179050453db09c4986c8f8b2f00a13557dff040f178d3804f5a78bff9
Contents?: true
Size: 1.41 KB
Versions: 1
Compression:
Stored size: 1.41 KB
Contents
require 'spec_helper' RSpec.describe SolidusPaypalBraintree::Address do describe '#to_json' do subject(:address_json) { JSON.parse(described_class.new(spree_address).to_json) } let(:german_address) { create(:address, country_iso: 'DE', state: nil) } # Does not require states let(:us_address) { create(:address, country_iso: 'US') } # Requires states let(:spree_address) { us_address } before do create(:country, iso: 'DE', states_required: false) create(:country, iso: 'US', states_required: true) end it 'has all the required keys' do expect(address_json.keys).to contain_exactly( 'line1', 'line2', 'city', 'postalCode', 'countryCode', 'recipientName', 'state', 'phone' ) end context 'with a country that does not require state' do let(:spree_address) { german_address } it { is_expected.not_to have_key('state') } end context 'with states turned off globally' do before do allow(::Spree::Config).to receive(:address_requires_state).and_return(false) end context 'with a country that requires states' do it { is_expected.not_to have_key('state') } end context 'with a country that does not require state' do let(:spree_address) { german_address } it { is_expected.not_to have_key('state') } end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
solidus_paypal_braintree-1.0.0 | spec/models/solidus_paypal_braintree/address_spec.rb |