From 1d60732581df4e7e377660f009ba8e15ee015cc6 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Thu, 17 Jan 2019 16:43:02 +0000 Subject: [PATCH] Improve readability of payment_method_spec --- spec/models/spree/payment_method_spec.rb | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/spec/models/spree/payment_method_spec.rb b/spec/models/spree/payment_method_spec.rb index 28707876d3..8b62281c26 100644 --- a/spec/models/spree/payment_method_spec.rb +++ b/spec/models/spree/payment_method_spec.rb @@ -28,16 +28,20 @@ module Spree end it "computes the amount of fees" do - pickup = create(:payment_method) order = create(:order) - expect(pickup.compute_amount(order)).to eq 0 - transaction = create(:payment_method, calculator: Calculator::FlatRate.new(preferred_amount: 10)) - expect(transaction.compute_amount(order)).to eq 10 - transaction = create(:payment_method, calculator: Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10)) - expect(transaction.compute_amount(order)).to eq 0 + + free_payment_method = create(:payment_method) # flat rate calculator with preferred_amount of 0 + expect(free_payment_method.compute_amount(order)).to eq 0 + + flat_rate_payment_method = create(:payment_method, calculator: Calculator::FlatRate.new(preferred_amount: 10)) + expect(flat_rate_payment_method.compute_amount(order)).to eq 10 + + flat_percent_payment_method = create(:payment_method, calculator: Calculator::FlatPercentItemTotal.new(preferred_flat_percent: 10)) + expect(flat_percent_payment_method.compute_amount(order)).to eq 0 + product = create(:product) order.add_variant(product.master) - expect(transaction.compute_amount(order)).to eq 2.0 + expect(flat_percent_payment_method.compute_amount(order)).to eq 2.0 end end end