Sha256: 97ba47b424e821c21bcc339f05e00e8390e06ffd70b9fd25390943de074dd1fa

Contents?: true

Size: 1.17 KB

Versions: 3

Compression:

Stored size: 1.17 KB

Contents

require 'spec_helper'

module SpreeSignifyd
  describe AddressSerializer do
    let(:serialized_address) { JSON.parse(AddressSerializer.new(ship_address).to_json) }

    def ship_address(options = {})
      @ship_address ||= create(:address, options)
    end

    context "node values" do
      let(:address) { serialized_address['address'] }

      it "streetAddress" do
        expect(address['streetAddress']).to eq ship_address.address1
      end

      it "unit" do
        expect(address['unit']).to eq ship_address.address2
      end

      it "city" do
        expect(address['city']).to eq ship_address.city
      end

      describe "provinceCode" do
        it "with a state entity associated" do
          expect(address['provinceCode']).to eq ship_address.state.abbr
        end
        it "with a state_name and no state entity" do
          ship_address(state_name: 'AL', state_id: nil)
          expect(address['provinceCode']).to eq 'AL'
        end
      end

      it "postalCode" do
        expect(address['postalCode']).to eq ship_address.zipcode
      end

      it "countryCode" do
        expect(address['countryCode']).to eq ship_address.country.iso
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_signifyd-1.1.0 spec/serializers/spree_signifyd/address_serializer_spec.rb
solidus_signifyd-1.0.1 spec/serializers/spree_signifyd/address_serializer_spec.rb
solidus_signifyd-1.0.0 spec/serializers/spree_signifyd/address_serializer_spec.rb