Sha256: 0ce31f5c6aae1f159d120a9ce0fd994d492f6c29b44a95489cca26e8ab5c65c0
Contents?: true
Size: 1.1 KB
Versions: 6
Compression:
Stored size: 1.1 KB
Contents
require 'spec_helper' describe Spree::Calculator::TieredFlatRate, type: :model do let(:calculator) { Spree::Calculator::TieredFlatRate.new } describe "#valid?" do subject { calculator.valid? } context "when tiers is not a hash" do before { calculator.preferred_tiers = ["nope", 0] } it { is_expected.to be false } end context "when tiers is a hash" do context "and one of the keys is not a positive number" do before { calculator.preferred_tiers = { "nope" => 20 } } it { is_expected.to be false } end end end describe "#compute" do let(:line_item) { mock_model Spree::LineItem, amount: amount } before do calculator.preferred_base_amount = 10 calculator.preferred_tiers = { 100 => 15, 200 => 20 } end subject { calculator.compute(line_item) } context "when amount falls within the first tier" do let(:amount) { 50 } it { is_expected.to eq 10 } end context "when amount falls within the second tier" do let(:amount) { 150 } it { is_expected.to eq 15 } end end end
Version data entries
6 entries across 6 versions & 1 rubygems