From f9f81086fdb5d85bcdf82dfe96aedeb9f02631a7 Mon Sep 17 00:00:00 2001 From: luisramos0 Date: Fri, 20 Sep 2019 09:02:43 +0100 Subject: [PATCH] Transpec features/consumer/shopping/variant_overrides_spec --- .../shopping/variant_overrides_spec.rb | 50 +++++++++---------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/spec/features/consumer/shopping/variant_overrides_spec.rb b/spec/features/consumer/shopping/variant_overrides_spec.rb index 0d789745f8..8b37f5d22e 100644 --- a/spec/features/consumer/shopping/variant_overrides_spec.rb +++ b/spec/features/consumer/shopping/variant_overrides_spec.rb @@ -43,26 +43,26 @@ feature "shopping with variant overrides defined", js: true do describe "viewing products" do it "shows price and stock from the override" do - page.should have_price with_currency(61.11) # product1_variant1_override.price ($55.55) + 10% fee - page.should_not have_price with_currency(12.22) # product1_variant1.price ($11.11) + 10% fee + expect(page).to have_price with_currency(61.11) # product1_variant1_override.price ($55.55) + 10% fee + expect(page).not_to have_price with_currency(12.22) # product1_variant1.price ($11.11) + 10% fee # Product should appear but one of the variants is out of stock - page.should_not have_content product1_variant2.options_text + expect(page).not_to have_content product1_variant2.options_text # Entire product should not appear - no stock - page.should_not have_content product2.name - page.should_not have_content product2_variant1.options_text + expect(page).not_to have_content product2.name + expect(page).not_to have_content product2_variant1.options_text # On-demand product with VO of no stock should NOT appear - page.should_not have_content product3_variant1.options_text + expect(page).not_to have_content product3_variant1.options_text end it "calculates fees correctly" do page.find("#variant-#{product1_variant1.id} .graph-button").click page.find(".price_breakdown a").click - page.should have_selector 'li.cost div', text: with_currency(55.55) - page.should have_selector 'li.packing-fee div', text: with_currency(5.56) - page.should have_selector 'li.total div', text: "= #{with_currency(61.11)}" + expect(page).to have_selector 'li.cost div', text: with_currency(55.55) + expect(page).to have_selector 'li.packing-fee div', text: with_currency(5.56) + expect(page).to have_selector 'li.total div', text: "= #{with_currency(61.11)}" end it "shows the correct prices when products are in the cart" do @@ -70,7 +70,7 @@ feature "shopping with variant overrides defined", js: true do show_cart wait_until_enabled 'li.cart a.button' visit shop_path - page.should have_price with_currency(61.11) + expect(page).to have_price with_currency(61.11) end # The two specs below reveal an unrelated issue with fee calculation. See: @@ -79,30 +79,30 @@ feature "shopping with variant overrides defined", js: true do it "shows the overridden price with fees in the quick cart" do fill_in "variants[#{product1_variant1.id}]", with: "2" show_cart - page.should have_selector "#cart-variant-#{product1_variant1.id} .quantity", text: '2' - page.should have_selector "#cart-variant-#{product1_variant1.id} .price", text: with_currency(61.11) - page.should have_selector "#cart-variant-#{product1_variant1.id} .total-price", text: with_currency(122.22) + expect(page).to have_selector "#cart-variant-#{product1_variant1.id} .quantity", text: '2' + expect(page).to have_selector "#cart-variant-#{product1_variant1.id} .price", text: with_currency(61.11) + expect(page).to have_selector "#cart-variant-#{product1_variant1.id} .total-price", text: with_currency(122.22) end it "shows the correct prices in the shopping cart" do fill_in "variants[#{product1_variant1.id}]", with: "2" add_to_cart - page.should have_selector "tr.line-item.variant-#{product1_variant1.id} .cart-item-price", text: with_currency(61.11) - page.should have_field "order[line_items_attributes][0][quantity]", with: '2' - page.should have_selector "tr.line-item.variant-#{product1_variant1.id} .cart-item-total", text: with_currency(122.22) + expect(page).to have_selector "tr.line-item.variant-#{product1_variant1.id} .cart-item-price", text: with_currency(61.11) + expect(page).to have_field "order[line_items_attributes][0][quantity]", with: '2' + expect(page).to have_selector "tr.line-item.variant-#{product1_variant1.id} .cart-item-total", text: with_currency(122.22) - page.should have_selector "#edit-cart .item-total", text: with_currency(122.22) - page.should have_selector "#edit-cart .grand-total", text: with_currency(122.22) + expect(page).to have_selector "#edit-cart .item-total", text: with_currency(122.22) + expect(page).to have_selector "#edit-cart .grand-total", text: with_currency(122.22) end it "shows the correct prices in the checkout" do fill_in "variants[#{product1_variant1.id}]", with: "2" click_checkout - page.should have_selector 'form.edit_order .cart-total', text: with_currency(122.22) - page.should have_selector 'form.edit_order .shipping', text: with_currency(0.00) - page.should have_selector 'form.edit_order .total', text: with_currency(122.22) + expect(page).to have_selector 'form.edit_order .cart-total', text: with_currency(122.22) + expect(page).to have_selector 'form.edit_order .shipping', text: with_currency(0.00) + expect(page).to have_selector 'form.edit_order .total', text: with_currency(122.22) end end @@ -114,8 +114,8 @@ feature "shopping with variant overrides defined", js: true do complete_checkout o = Spree::Order.complete.last - o.line_items.first.price.should == 55.55 - o.total.should == 122.22 + expect(o.line_items.first.price).to eq(55.55) + expect(o.total).to eq(122.22) end it "subtracts stock from the override" do @@ -146,7 +146,7 @@ feature "shopping with variant overrides defined", js: true do expect do complete_checkout end.to change { product1_variant1.reload.on_hand }.by(-2) - product1_variant1_override.reload.count_on_hand.should be_nil + expect(product1_variant1_override.reload.count_on_hand).to be_nil end it "does not subtract stock from variants where the override has on_demand: true" do @@ -165,7 +165,7 @@ feature "shopping with variant overrides defined", js: true do complete_checkout - page.should_not have_content "Out of Stock" + expect(page).not_to have_content "Out of Stock" end end