Use rspec 3 syntax in order_cycle_distributed_variants_spec and checkout_controller_spec

This commit is contained in:
luisramos0
2019-04-15 12:39:52 +01:00
parent fce3d69345
commit e8ccb55f47
2 changed files with 7 additions and 8 deletions

View File

@@ -40,8 +40,8 @@ describe CheckoutController, type: :controller do
let(:order_cycle_distributed_variants) { double(:order_cycle_distributed_variants) }
before do
controller.stub(:current_order).and_return(order)
order.stub(:distributor).and_return(distributor)
allow(controller).to receive(:current_order).and_return(order)
allow(order).to receive(:distributor).and_return(distributor)
order.order_cycle = order_cycle
allow(OrderCycleDistributedVariants).to receive(:new).with(order_cycle, distributor).and_return(order_cycle_distributed_variants)
@@ -62,7 +62,6 @@ describe CheckoutController, type: :controller do
expect(response).to redirect_to spree.cart_path
end
it "does not redirect when items are available and in stock" do
allow(order).to receive_message_chain(:insufficient_stock_lines, :empty?).and_return true
expect(order_cycle_distributed_variants).to receive(:distributes_order_variants?).with(order).and_return(true)

View File

@@ -9,14 +9,14 @@ describe OrderCycleDistributedVariants do
describe "checking if an order can change to a specified new distribution" do
it "returns false when a variant is not available for the specified distribution" do
order.should_receive(:line_item_variants) { [1] }
subject.should_receive(:available_variants) { [] }
allow(order).to receive(:line_item_variants).and_return([1])
allow(subject).to receive(:available_variants).and_return([])
expect(subject.distributes_order_variants?(order)).to be false
end
it "returns true when all variants are available for the specified distribution" do
order.should_receive(:line_item_variants) { [1] }
subject.should_receive(:available_variants) { [1] }
allow(order).to receive(:line_item_variants).and_return([1])
allow(subject).to receive(:available_variants).and_return([1])
expect(subject.distributes_order_variants?(order)).to be true
end
end
@@ -24,7 +24,7 @@ describe OrderCycleDistributedVariants do
describe "finding variants that are available through a particular order cycle" do
it "finds variants distributed by order cycle" do
variant = double(:variant)
order_cycle.should_receive(:variants_distributed_by).with(distributor) { [variant] }
allow(order_cycle).to receive(:variants_distributed_by).with(distributor).and_return([variant])
expect(subject.available_variants).to eq [variant]
end