From 167a69d2ef24037171722ebdb13e766afb498a84 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Wed, 23 Oct 2024 14:46:12 +1100 Subject: [PATCH] Spec change in order state more precisely --- spec/models/spree/order_spec.rb | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/spec/models/spree/order_spec.rb b/spec/models/spree/order_spec.rb index 54f2fda70d..8845335a42 100644 --- a/spec/models/spree/order_spec.rb +++ b/spec/models/spree/order_spec.rb @@ -378,21 +378,25 @@ RSpec.describe Spree::Order do describe "#cancel!" do let(:order) { create(:order_with_totals_and_distribution, :completed) } - before { order.cancel! } - it "should cancel the order" do - expect(order.state).to eq 'canceled' + expect { order.cancel! }.to change { order.state }.to("canceled") end it "should cancel the shipments" do - expect(order.shipments.pluck(:state)).to eq ['canceled'] + expect { order.cancel! }.to change { + order.shipments.pluck(:state) + }.to(["canceled"]) end context "when payment has not been taken" do context "and payment is in checkout state" do it "should change the state of the payment to void" do - order.payments.reload - expect(order.payments.pluck(:state)).to eq ['void'] + expect { + order.cancel! + order.payments.reload + }.to change { + order.payments.pluck(:state) + }.to(["void"]) end end end