Sha256: b30324efd90d42be783e576a1e2263b4126250f5171fabc65604f9c561bafdc0

Contents?: true

Size: 1004 Bytes

Versions: 6

Compression:

Stored size: 1004 Bytes

Contents

RSpec.shared_examples_for "default_price" do
  let(:model)        { described_class }
  subject(:instance) { FactoryBot.build(model.name.demodulize.downcase.to_sym) }

  describe '.has_one :default_price' do
    let(:default_price_association) { model.reflect_on_association(:default_price) }

    it 'should be a has one association' do
      expect(default_price_association.macro).to eql :has_one
    end

    it 'should have a dependent destroy' do
      expect(default_price_association.options[:dependent]).to eql :destroy
    end

    it 'should have the class name of Spree::Price' do
      expect(default_price_association.options[:class_name]).to eql 'Spree::Price'
    end
  end

  describe '#default_price' do
    subject { instance.default_price }

    describe '#class' do
      subject { super().class }
      it { is_expected.to eql Spree::Price }
    end
  end

  describe '#has_default_price?' do
    subject { super().has_default_price? }
    it { is_expected.to be_truthy }
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
solidus_core-2.5.2 spec/support/concerns/default_price.rb
solidus_core-2.5.1 spec/support/concerns/default_price.rb
solidus_core-2.5.0 spec/support/concerns/default_price.rb
solidus_core-2.5.0.rc1 spec/support/concerns/default_price.rb
solidus_core-2.5.0.beta2 spec/support/concerns/default_price.rb
solidus_core-2.5.0.beta1 spec/support/concerns/default_price.rb