Sha256: 2b3a37cba316c5c06d6d840924f35d44fe4cf4a19eefb0a8f871d8e9e69c0376

Contents?: true

Size: 934 Bytes

Versions: 13

Compression:

Stored size: 934 Bytes

Contents

# frozen_string_literal: true

require 'rails_helper'
require 'shared_examples/calculator_shared_examples'

module Spree
  module Calculator::Shipping
    RSpec.describe FlatPercentItemTotal, type: :model do
      let(:variant1) { build(:variant, price: 10.11) }
      let(:variant2) { build(:variant, price: 20.2222) }

      it_behaves_like 'a calculator with a description'

      let(:line_item1) { build(:line_item, variant: variant1) }
      let(:line_item2) { build(:line_item, variant: variant2) }

      let(:package) do
        build(:stock_package, variants_contents: { variant1 => 2, variant2 => 1 })
      end

      subject { FlatPercentItemTotal.new(preferred_flat_percent: 10) }

      it "should round result correctly" do
        expect(subject.compute(package)).to eq(4.04)
      end

      it "should return a bigdecimal" do
        expect(subject.compute(package)).to be_a(BigDecimal)
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
solidus_core-2.6.6 spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb
solidus_core-2.7.4 spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb
solidus_core-2.7.3 spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb
solidus_core-2.6.5 spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb
solidus_core-2.7.2 spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb
solidus_core-2.6.4 spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb
solidus_core-2.6.3 spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb
solidus_core-2.7.1 spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb
solidus_core-2.6.2 spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb
solidus_core-2.7.0 spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb
solidus_core-2.6.1 spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb
solidus_core-2.6.0 spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb
solidus_core-2.6.0.rc1 spec/models/spree/calculator/shipping/flat_percent_item_total_spec.rb