Sha256: 60b0cd339c10b858671503be6399273104c99d9faa741d5fccff8233277846fa

Contents?: true

Size: 1.12 KB

Versions: 16

Compression:

Stored size: 1.12 KB

Contents

shared_examples_for "default_price" do
  let(:model)        { described_class }
  subject(:instance) { FactoryGirl.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 }

    its(:class) { should eql Spree::Price }
    it 'delegates price' do
      expect(instance.default_price). to receive(:price)
      instance.price
    end

    it 'delegates price_including_vat_for' do
      expect(instance.default_price). to receive(:price_including_vat_for)
      instance.price_including_vat_for
    end
  end

  its(:has_default_price?) { should be_truthy }
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
spree_core-3.3.0.rc1 spec/support/concerns/default_price.rb
spree_core-3.1.5 spec/support/concerns/default_price.rb
spree_core-3.2.1 spec/support/concerns/default_price.rb
spree_core-3.2.0 spec/support/concerns/default_price.rb
spree_core-3.1.4 spec/support/concerns/default_price.rb
spree_core-3.2.0.rc3 spec/support/concerns/default_price.rb
spree_core-3.2.0.rc2 spec/support/concerns/default_price.rb
spree_core-3.2.0.rc1 spec/support/concerns/default_price.rb
spree_core-3.1.3 spec/support/concerns/default_price.rb
spree_core-3.1.2 spec/support/concerns/default_price.rb
spree_core-3.1.1 spec/support/concerns/default_price.rb
spree_core-3.1.0 spec/support/concerns/default_price.rb
spree_core-3.1.0.rc4 spec/support/concerns/default_price.rb
spree_core-3.1.0.rc3 spec/support/concerns/default_price.rb
spree_core-3.1.0.rc2 spec/support/concerns/default_price.rb
spree_core-3.1.0.rc1 spec/support/concerns/default_price.rb