Sha256: a27958efdf302cb0d143a376dfaa200fbee715729eb7ba23eb19de6875ef3b4c

Contents?: true

Size: 839 Bytes

Versions: 1

Compression:

Stored size: 839 Bytes

Contents

RSpec.shared_examples 'addressable' do
  it { should have_one(:billing_address).dependent(:destroy) }
  it { should have_one(:shipping_address).dependent(:destroy) }

  describe 'addresses' do
    subject do
      name = described_class.name.split(':').last.downcase.to_sym
      create name, :with_addresses
    end

    it 'can create and delete addresses' do
      expect(subject.billing_address.type).to eq 'Shopper::BillingAddress'
      subject.billing_address.delete
      subject.reload
      expect(subject.billing_address).to eq nil
      expect(subject.shipping_address).to be_present
      expect(subject.shipping_address.type).to eq 'Shopper::ShippingAddress'
      expect(subject.shipping_address.addressable_type).to eq described_class.name
      expect(subject.shipping_address.addressable).to eq subject
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
shoppper-0.1.0 spec/support/shared_examples/addressable.rb