diff --git a/spec/features/admin/shipping_methods_spec.rb b/spec/features/admin/shipping_methods_spec.rb index 1395b2bee8..7df6c810f2 100644 --- a/spec/features/admin/shipping_methods_spec.rb +++ b/spec/features/admin/shipping_methods_spec.rb @@ -20,23 +20,25 @@ feature 'shipping methods' do # Shows appropriate fields when logged in as admin visit spree.new_admin_shipping_method_path - page.should have_field 'shipping_method_name' - page.should have_field 'shipping_method_description' - page.should have_select 'shipping_method_display_on' - page.should have_field 'shipping_method_require_ship_address_true', checked: true + expect(page).to have_field 'shipping_method_name' + expect(page).to have_field 'shipping_method_description' + expect(page).to have_select 'shipping_method_display_on' + expect(page).to have_css 'div#shipping_method_zones_field' + expect(page).to have_field 'shipping_method_require_ship_address_true', checked: true # When I create a shipping method and set the distributors fill_in 'shipping_method_name', with: 'Carrier Pidgeon' check "shipping_method_distributor_ids_#{d1.id}" check "shipping_method_distributor_ids_#{d2.id}" + check "shipping_method_shipping_categories_" click_button 'Create' # Then the shipping method should have its distributor set - flash_message.should == 'Shipping method "Carrier Pidgeon" has been successfully created!' + expect(flash_message).to eq('Shipping method "Carrier Pidgeon" has been successfully created!') sm = Spree::ShippingMethod.last - sm.name.should == 'Carrier Pidgeon' - sm.distributors.should match_array [d1, d2] + expect(sm.name).to eq('Carrier Pidgeon') + expect(sm.distributors).to match_array [d1, d2] end it "at checkout, user can only see shipping methods for their current distributor (checkout spec)" @@ -45,8 +47,8 @@ feature 'shipping methods' do scenario "deleting a shipping method" do visit_delete spree.admin_shipping_method_path(@sm) - page.should have_content "Shipping method \"#{@sm.name}\" has been successfully removed!" - Spree::ShippingMethod.where(:id => @sm.id).should be_empty + expect(page).to have_content "Shipping method \"#{@sm.name}\" has been successfully removed!" + expect(Spree::ShippingMethod.where(:id => @sm.id)).to be_empty end scenario "deleting a shipping method referenced by an order" do @@ -58,8 +60,8 @@ feature 'shipping methods' do visit_delete spree.admin_shipping_method_path(@sm) - page.should have_content "That shipping method cannot be deleted as it is referenced by an order: #{o.number}." - Spree::ShippingMethod.find(@sm.id).should_not be_nil + expect(page).to have_content "That shipping method cannot be deleted as it is referenced by an order: #{o.number}." + expect(Spree::ShippingMethod.find(@sm.id)).not_to be_nil end end @@ -87,24 +89,26 @@ feature 'shipping methods' do click_link 'Create One Now' # Show the correct fields - page.should have_field 'shipping_method_name' - page.should have_field 'shipping_method_description' - page.should_not have_select 'shipping_method_display_on' - page.should have_field 'shipping_method_require_ship_address_true', checked: true + expect(page).to have_field 'shipping_method_name' + expect(page).to have_field 'shipping_method_description' + expect(page).not_to have_select 'shipping_method_display_on' + expect(page).to have_css 'div#shipping_method_zones_field' + expect(page).to have_field 'shipping_method_require_ship_address_true', checked: true fill_in 'shipping_method_name', :with => 'Teleport' check "shipping_method_distributor_ids_#{distributor1.id}" + check "shipping_method_shipping_categories_" find(:css, "tags-input .tags input").set "local\n" click_button 'Create' - flash_message.should == 'Shipping method "Teleport" has been successfully created!' + expect(flash_message).to eq('Shipping method "Teleport" has been successfully created!') expect(first('tags-input .tag-list ti-tag-item')).to have_content "local" shipping_method = Spree::ShippingMethod.find_by_name('Teleport') - shipping_method.distributors.should == [distributor1] - shipping_method.tag_list.should == ["local"] + expect(shipping_method.distributors).to eq([distributor1]) + expect(shipping_method.tag_list).to eq(["local"]) end it "shows me only shipping methods I have access to" do @@ -114,9 +118,9 @@ feature 'shipping methods' do visit spree.admin_shipping_methods_path - page.should have_content sm1.name - page.should have_content sm2.name - page.should_not have_content sm3.name + expect(page).to have_content sm1.name + expect(page).to have_content sm2.name + expect(page).not_to have_content sm3.name end it "does not show duplicates of shipping methods" do @@ -125,7 +129,7 @@ feature 'shipping methods' do visit spree.admin_shipping_methods_path - page.should have_selector 'td', text: 'Two', count: 1 + expect(page).to have_selector 'td', text: 'Two', count: 1 end pending "shows me only shipping methods for the enterprise I select" do @@ -137,8 +141,8 @@ feature 'shipping methods' do within(".side_menu") do click_link "Shipping Methods" end - page.should have_content sm1.name - page.should have_content sm2.name + expect(page).to have_content sm1.name + expect(page).to have_content sm2.name click_link 'Enterprises' within("#e_#{distributor2.id}") { click_link 'Settings' } @@ -146,8 +150,8 @@ feature 'shipping methods' do click_link "Shipping Methods" end - page.should_not have_content sm1.name - page.should have_content sm2.name + expect(page).not_to have_content sm1.name + expect(page).to have_content sm2.name end end end