From ee937988e8a72ed0ba0b6889e4535ce35a4efc7d Mon Sep 17 00:00:00 2001 From: Luis Ramos Date: Thu, 2 Jul 2020 20:24:00 +0100 Subject: [PATCH] Fix easy rubocop issues --- .../order_management/stock/estimator_spec.rb | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/engines/order_management/spec/services/order_management/stock/estimator_spec.rb b/engines/order_management/spec/services/order_management/stock/estimator_spec.rb index 74215b031c..892b7e1cf2 100644 --- a/engines/order_management/spec/services/order_management/stock/estimator_spec.rb +++ b/engines/order_management/spec/services/order_management/stock/estimator_spec.rb @@ -13,11 +13,15 @@ module OrderManagement context "#shipping rates" do before(:each) do shipping_method.zones.first.members.create(zoneable: order.ship_address.country) - allow_any_instance_of(Spree::ShippingMethod).to receive_message_chain(:calculator, :available?).and_return(true) - allow_any_instance_of(Spree::ShippingMethod).to receive_message_chain(:calculator, :compute).and_return(4.00) allow_any_instance_of(Spree::ShippingMethod). - to receive_message_chain(:calculator, :preferences).and_return({ currency: order.currency }) - allow_any_instance_of(Spree::ShippingMethod).to receive_message_chain(:calculator, :marked_for_destruction?) + to receive_message_chain(:calculator, :available?).and_return(true) + allow_any_instance_of(Spree::ShippingMethod). + to receive_message_chain(:calculator, :compute).and_return(4.00) + allow_any_instance_of(Spree::ShippingMethod). + to receive_message_chain(:calculator, :preferences). + and_return({ currency: order.currency }) + allow_any_instance_of(Spree::ShippingMethod). + to receive_message_chain(:calculator, :marked_for_destruction?) allow(package).to receive_messages(shipping_methods: [shipping_method]) end @@ -39,7 +43,8 @@ module OrderManagement context "the calculator is not available for that order" do it "does not return shipping rates from a shipping method" do - allow_any_instance_of(Spree::ShippingMethod).to receive_message_chain(:calculator, :available?).and_return(false) + allow_any_instance_of(Spree::ShippingMethod). + to receive_message_chain(:calculator, :available?).and_return(false) shipping_rates = subject.shipping_rates(package) expect(shipping_rates).to eq [] end @@ -62,9 +67,12 @@ module OrderManagement it "sorts shipping rates by cost" do shipping_methods = 3.times.map { create(:shipping_method) } - allow(shipping_methods[0]).to receive_message_chain(:calculator, :compute).and_return(5.00) - allow(shipping_methods[1]).to receive_message_chain(:calculator, :compute).and_return(3.00) - allow(shipping_methods[2]).to receive_message_chain(:calculator, :compute).and_return(4.00) + allow(shipping_methods[0]). + to receive_message_chain(:calculator, :compute).and_return(5.00) + allow(shipping_methods[1]). + to receive_message_chain(:calculator, :compute).and_return(3.00) + allow(shipping_methods[2]). + to receive_message_chain(:calculator, :compute).and_return(4.00) allow(subject).to receive(:shipping_methods).and_return(shipping_methods) @@ -76,8 +84,10 @@ module OrderManagement let(:shipping_methods) { 2.times.map { create(:shipping_method) } } it "selects the most affordable shipping rate" do - allow(shipping_methods[0]).to receive_message_chain(:calculator, :compute).and_return(5.00) - allow(shipping_methods[1]).to receive_message_chain(:calculator, :compute).and_return(3.00) + allow(shipping_methods[0]). + to receive_message_chain(:calculator, :compute).and_return(5.00) + allow(shipping_methods[1]). + to receive_message_chain(:calculator, :compute).and_return(3.00) allow(subject).to receive(:shipping_methods).and_return(shipping_methods) @@ -86,8 +96,10 @@ module OrderManagement end it "selects the cheapest shipping rate and doesn't raise exception over nil cost" do - allow(shipping_methods[0]).to receive_message_chain(:calculator, :compute).and_return(1.00) - allow(shipping_methods[1]).to receive_message_chain(:calculator, :compute).and_return(nil) + allow(shipping_methods[0]). + to receive_message_chain(:calculator, :compute).and_return(1.00) + allow(shipping_methods[1]). + to receive_message_chain(:calculator, :compute).and_return(nil) allow(subject).to receive(:shipping_methods).and_return(shipping_methods) @@ -104,7 +116,8 @@ module OrderManagement allow(backend_method).to receive_message_chain(:calculator, :compute).and_return(0.00) allow(generic_method).to receive_message_chain(:calculator, :compute).and_return(5.00) - allow(subject).to receive(:shipping_methods).and_return([backend_method, generic_method]) + allow(subject). + to receive(:shipping_methods).and_return([backend_method, generic_method]) expect(subject.shipping_rates(package).map(&:selected)).to eq [false, true] end