Convert specs to RSpec 3.8.0 syntax with Transpec

This conversion is done by Transpec 3.4.0 with the following command:
    transpec spec/features/consumer/shopping/checkout_spec.rb

* 43 conversions
    from: obj.should
      to: expect(obj).to

* 8 conversions
    from: obj.should_not
      to: expect(obj).not_to

* 3 conversions
    from: == expected
      to: eq(expected)

For more details: https://github.com/yujinakayama/transpec#supported-conversions
This commit is contained in:
Maikel Linke
2019-09-06 11:32:44 +10:00
parent e3ce2a7486
commit 8e8c77c5bd

View File

@@ -55,9 +55,9 @@ feature "As a consumer I want to check out my cart", js: true do
it "returns me to the cart with an error message" do
visit checkout_path
page.should_not have_selector 'closing', text: "Checkout now"
page.should have_selector 'closing', text: "Your shopping cart"
page.should have_content "An item in your cart has become unavailable"
expect(page).not_to have_selector 'closing', text: "Checkout now"
expect(page).to have_selector 'closing', text: "Your shopping cart"
expect(page).to have_content "An item in your cart has become unavailable"
end
end
@@ -75,23 +75,23 @@ feature "As a consumer I want to check out my cart", js: true do
end
it "allows user to save default billing address and shipping address" do
user.bill_address.should be_nil
user.ship_address.should be_nil
expect(user.bill_address).to be_nil
expect(user.ship_address).to be_nil
order.bill_address.should be_nil
order.ship_address.should be_nil
expect(order.bill_address).to be_nil
expect(order.ship_address).to be_nil
place_order
page.should have_content "Your order has been processed successfully"
expect(page).to have_content "Your order has been processed successfully"
order.reload.bill_address.address1.should eq '123 Your Head'
order.reload.ship_address.address1.should eq '123 Your Head'
expect(order.reload.bill_address.address1).to eq '123 Your Head'
expect(order.reload.ship_address.address1).to eq '123 Your Head'
order.customer.bill_address.address1.should eq '123 Your Head'
order.customer.ship_address.address1.should eq '123 Your Head'
expect(order.customer.bill_address.address1).to eq '123 Your Head'
expect(order.customer.ship_address.address1).to eq '123 Your Head'
user.reload.bill_address.address1.should eq '123 Your Head'
user.reload.ship_address.address1.should eq '123 Your Head'
expect(user.reload.bill_address.address1).to eq '123 Your Head'
expect(user.reload.ship_address.address1).to eq '123 Your Head'
end
it "it doesn't tell about previous orders" do
@@ -127,7 +127,7 @@ feature "As a consumer I want to check out my cart", js: true do
expect do
place_order
page.should have_content "Your order has been processed successfully"
expect(page).to have_content "Your order has been processed successfully"
end.to enqueue_job ConfirmOrderJob
end
end
@@ -215,8 +215,8 @@ feature "As a consumer I want to check out my cart", js: true do
visit shop_path
# The presence of the control product ensures the list of products is fully loaded
# before we verify the sold product is not present
page.should have_content control_product.name
page.should_not have_content product.name
expect(page).to have_content control_product.name
expect(page).not_to have_content product.name
end
end
@@ -228,25 +228,25 @@ feature "As a consumer I want to check out my cart", js: true do
it "shows the current distributor" do
visit checkout_path
page.should have_content distributor.name
expect(page).to have_content distributor.name
end
it 'does not show the save as default address checkbox' do
page.should_not have_content "Save as default billing address"
page.should_not have_content "Save as default shipping address"
expect(page).not_to have_content "Save as default billing address"
expect(page).not_to have_content "Save as default shipping address"
end
it "shows a breakdown of the order price" do
choose sm2.name
page.should have_selector 'orderdetails .cart-total', text: with_currency(11.23)
page.should have_selector 'orderdetails .shipping', text: with_currency(4.56)
page.should have_selector 'orderdetails .total', text: with_currency(15.79)
expect(page).to have_selector 'orderdetails .cart-total', text: with_currency(11.23)
expect(page).to have_selector 'orderdetails .shipping', text: with_currency(4.56)
expect(page).to have_selector 'orderdetails .total', text: with_currency(15.79)
# Tax should not be displayed in checkout, as the customer's choice of shipping method
# affects the tax and we haven't written code to live-update the tax amount when they
# make a change.
page.should_not have_content product.tax_category.name
expect(page).not_to have_content product.tax_category.name
end
it "shows all shipping methods in order by name" do
@@ -265,7 +265,7 @@ feature "As a consumer I want to check out my cart", js: true do
end
it "shows ship address forms when 'same as billing address' is unchecked" do
uncheck "Shipping address same as billing address?"
find("#ship_address > div.visible").visible?.should be true
expect(find("#ship_address > div.visible").visible?).to be true
end
end
@@ -275,9 +275,9 @@ feature "As a consumer I want to check out my cart", js: true do
it "shows shipping methods allowed by the rule" do
# No rules in effect
page.should have_content "Frogs"
page.should have_content "Donkeys"
page.should have_content "Local"
expect(page).to have_content "Frogs"
expect(page).to have_content "Donkeys"
expect(page).to have_content "Local"
create(:filter_shipping_methods_tag_rule,
enterprise: distributor,
@@ -293,25 +293,25 @@ feature "As a consumer I want to check out my cart", js: true do
checkout_as_guest
# Default rule in effect, disallows access to 'Local'
page.should have_content "Frogs"
page.should have_content "Donkeys"
page.should_not have_content "Local"
expect(page).to have_content "Frogs"
expect(page).to have_content "Donkeys"
expect(page).not_to have_content "Local"
quick_login_as(user)
visit checkout_path
# Default rule in still effect, disallows access to 'Local'
page.should have_content "Frogs"
page.should have_content "Donkeys"
page.should_not have_content "Local"
expect(page).to have_content "Frogs"
expect(page).to have_content "Donkeys"
expect(page).not_to have_content "Local"
customer.update_attribute(:tag_list, "local")
visit checkout_path
# #local Customer can access 'Local' shipping method
page.should have_content "Frogs"
page.should have_content "Donkeys"
page.should have_content "Local"
expect(page).to have_content "Frogs"
expect(page).to have_content "Donkeys"
expect(page).to have_content "Local"
end
end
end
@@ -323,9 +323,9 @@ feature "As a consumer I want to check out my cart", js: true do
end
it "shows all available payment methods" do
page.should have_content pm1.name
page.should have_content pm2.name
page.should have_content pm3.name
expect(page).to have_content pm1.name
expect(page).to have_content pm2.name
expect(page).to have_content pm3.name
end
describe "purchasing" do
@@ -375,7 +375,7 @@ feature "As a consumer I want to check out my cart", js: true do
it "takes us to the order confirmation page when submitted with 'same as billing address' checked" do
place_order
page.should have_content "Your order has been processed successfully"
expect(page).to have_content "Your order has been processed successfully"
end
it "takes us to the cart page with an error when a product becomes out of stock just before we purchase", js: true do
@@ -385,9 +385,9 @@ feature "As a consumer I want to check out my cart", js: true do
place_order
page.should_not have_content "Your order has been processed successfully"
page.should have_selector 'closing', text: "Your shopping cart"
page.should have_content "An item in your cart has become unavailable."
expect(page).not_to have_content "Your order has been processed successfully"
expect(page).to have_selector 'closing', text: "Your shopping cart"
expect(page).to have_content "An item in your cart has become unavailable."
end
context "when we are charged a shipping fee" do
@@ -395,12 +395,12 @@ feature "As a consumer I want to check out my cart", js: true do
it "creates a payment for the full amount inclusive of shipping" do
place_order
page.should have_content "Your order has been processed successfully"
expect(page).to have_content "Your order has been processed successfully"
# There are two orders - our order and our new cart
o = Spree::Order.complete.first
o.adjustments.shipping.first.amount.should == 4.56
o.payments.first.amount.should == 10 + 1.23 + 4.56 # items + fees + shipping
expect(o.adjustments.shipping.first.amount).to eq(4.56)
expect(o.payments.first.amount).to eq(10 + 1.23 + 4.56) # items + fees + shipping
end
end
@@ -437,11 +437,11 @@ feature "As a consumer I want to check out my cart", js: true do
fill_in 'Security Code', with: '123'
place_order
page.should have_content "Your order has been processed successfully"
expect(page).to have_content "Your order has been processed successfully"
# Order should have a payment with the correct amount
o = Spree::Order.complete.first
o.payments.first.amount.should == 11.23
expect(o.payments.first.amount).to eq(11.23)
end
it "shows the payment processing failed message when submitted with an invalid credit card" do
@@ -451,11 +451,11 @@ feature "As a consumer I want to check out my cart", js: true do
fill_in 'Security Code', with: '123'
place_order
page.should have_content 'Bogus Gateway: Forced failure'
expect(page).to have_content 'Bogus Gateway: Forced failure'
# Does not show duplicate shipping fee
visit checkout_path
page.should have_selector "th", text: "Shipping", count: 1
expect(page).to have_selector "th", text: "Shipping", count: 1
end
end
end