Sha256: 51214ea600d7dce59930b371351fbeafdec3b2a5356e2a8be3f4064228751418
Contents?: true
Size: 1.22 KB
Versions: 13
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true require 'rails_helper' module Spree RSpec.describe ShippingCalculator, type: :model do let(:variant1) { build(:variant, price: 10) } let(:variant2) { build(:variant, price: 20) } let(:package) do build(:stock_package, variants_contents: { variant1 => 2, variant2 => 1 }) end subject { ShippingCalculator.new } it 'computes with a shipment' do shipment = mock_model(Spree::Shipment) expect(subject).to receive(:compute_shipment).with(shipment) subject.compute(shipment) end it 'computes with a package' do expect(subject).to receive(:compute_package).with(package) subject.compute(package) end it 'compute_shipment must be overridden' do expect { subject.compute_shipment(shipment) }.to raise_error NameError end it 'compute_package must be overridden' do expect { subject.compute_package(package) }.to raise_error NotImplementedError end it 'checks availability for a package' do expect(subject.available?(package)).to be true end it 'calculates totals for content_items' do expect(subject.send(:total, package.contents)).to eq 40.00 end end end
Version data entries
13 entries across 13 versions & 1 rubygems