From 0fd29dd32eb25e9d3ae5b29db7b9e7e472c06052 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 22 Oct 2015 13:43:15 +1100 Subject: [PATCH] use expect in bulk_order_management_spec --- .../admin/bulk_order_management_spec.rb | 348 +++++++++--------- 1 file changed, 172 insertions(+), 176 deletions(-) diff --git a/spec/features/admin/bulk_order_management_spec.rb b/spec/features/admin/bulk_order_management_spec.rb index 8d52f21b48..5bcca783bd 100644 --- a/spec/features/admin/bulk_order_management_spec.rb +++ b/spec/features/admin/bulk_order_management_spec.rb @@ -14,7 +14,7 @@ feature %q{ it "displays a message when number of line items is zero" do visit '/admin/orders/bulk_management' - page.should have_text "No orders found." + expect(page).to have_text 'No orders found.' end context "displaying the list of line items" do @@ -29,14 +29,10 @@ feature %q{ visit '/admin/orders/bulk_management' end - #it "displays a 'loading' splash for line items" do - # page.should have_selector "div.loading", :text => "Loading Line Items..." - #end - it "displays a list of line items" do - page.should have_selector "tr#li_#{li1.id}" - page.should have_selector "tr#li_#{li2.id}" - page.should_not have_selector "tr#li_#{li3.id}" + expect(page).to have_selector "tr#li_#{li1.id}" + expect(page).to have_selector "tr#li_#{li2.id}" + expect(page).to_not have_selector "tr#li_#{li3.id}" end end @@ -51,39 +47,39 @@ feature %q{ end it "displays a column for user's full name" do - page.should have_selector "th.full_name", text: "NAME", :visible => true - page.should have_selector "td.full_name", text: o1.bill_address.full_name, :visible => true - page.should have_selector "td.full_name", text: "", :visible => true + expect(page).to have_selector "th.full_name", text: "NAME", :visible => true + expect(page).to have_selector "td.full_name", text: o1.bill_address.full_name, :visible => true + expect(page).to have_selector "td.full_name", text: "", :visible => true end it "displays a column for order date" do - page.should have_selector "th.date", text: "ORDER DATE", :visible => true - page.should have_selector "td.date", text: o1.completed_at.strftime("%F %T"), :visible => true - page.should have_selector "td.date", text: o2.completed_at.strftime("%F %T"), :visible => true + expect(page).to have_selector "th.date", text: "ORDER DATE", :visible => true + expect(page).to have_selector "td.date", text: o1.completed_at.strftime("%F %T"), :visible => true + expect(page).to have_selector "td.date", text: o2.completed_at.strftime("%F %T"), :visible => true end it "displays a column for producer" do - page.should have_selector "th.producer", text: "PRODUCER", :visible => true - page.should have_selector "td.producer", text: li1.product.supplier.name, :visible => true - page.should have_selector "td.producer", text: li2.product.supplier.name, :visible => true + expect(page).to have_selector "th.producer", text: "PRODUCER", :visible => true + expect(page).to have_selector "td.producer", text: li1.product.supplier.name, :visible => true + expect(page).to have_selector "td.producer", text: li2.product.supplier.name, :visible => true end it "displays a column for variant description, which shows only product name when options text is blank" do - page.should have_selector "th.variant", text: "PRODUCT: UNIT", :visible => true - page.should have_selector "td.variant", text: li1.product.name, :visible => true - page.should have_selector "td.variant", text: (li2.product.name + ": " + li2.variant.options_text), :visible => true + expect(page).to have_selector "th.variant", text: "PRODUCT: UNIT", :visible => true + expect(page).to have_selector "td.variant", text: li1.product.name, :visible => true + expect(page).to have_selector "td.variant", text: (li2.product.name + ": " + li2.variant.options_text), :visible => true end it "displays a field for quantity" do - page.should have_selector "th.quantity", text: "QUANTITY", :visible => true - page.should have_field "quantity", with: li1.quantity.to_s, :visible => true - page.should have_field "quantity", with: li2.quantity.to_s, :visible => true + expect(page).to have_selector "th.quantity", text: "QUANTITY", :visible => true + expect(page).to have_field "quantity", with: li1.quantity.to_s, :visible => true + expect(page).to have_field "quantity", with: li2.quantity.to_s, :visible => true end it "displays a column for max quantity" do - page.should have_selector "th.max", text: "MAX", :visible => true - page.should have_selector "td.max", text: li1.max_quantity.to_s, :visible => true - page.should have_selector "td.max", text: li2.max_quantity.to_s, :visible => true + expect(page).to have_selector "th.max", text: "MAX", :visible => true + expect(page).to have_selector "td.max", text: li1.max_quantity.to_s, :visible => true + expect(page).to have_selector "td.max", text: li2.max_quantity.to_s, :visible => true end end end @@ -102,17 +98,17 @@ feature %q{ end it "adds the class 'update-pending' to input elements when value is altered" do - page.should_not have_css "input[name='quantity'].update-pending" + expect(page).to_not have_css "input[name='quantity'].update-pending" fill_in "quantity", :with => 2 - page.should have_css "input[name='quantity'].update-pending" + expect(page).to have_css "input[name='quantity'].update-pending" end it "removes the class 'update-pending' from input elements when initial (DB) value is entered" do - page.should_not have_css "input[name='quantity'].update-pending" + expect(page).to_not have_css "input[name='quantity'].update-pending" fill_in "quantity", :with => 2 - page.should have_css "input[name='quantity'].update-pending" + expect(page).to have_css "input[name='quantity'].update-pending" fill_in "quantity", :with => 5 - page.should_not have_css "input[name='quantity'].update-pending" + expect(page).to_not have_css "input[name='quantity'].update-pending" end end @@ -126,14 +122,14 @@ feature %q{ it "displays an update button which submits pending changes" do fill_in "quantity", :with => 2 - page.should have_selector "input[name='quantity'].update-pending" - page.should_not have_selector "input[name='quantity'].update-success" - page.should have_button "Update" + expect(page).to have_selector "input[name='quantity'].update-pending" + expect(page).to_not have_selector "input[name='quantity'].update-success" + expect(page).to have_button "Update" click_button "Update" - page.should_not have_selector "input[name='quantity'].update-pending" - page.should have_selector "input[name='quantity'].update-success" - page.should have_selector "input[name='final_weight_volume'].update-success", visible: false - page.should have_selector "input[name='price'].update-success", visible: false + expect(page).to_not have_selector "input[name='quantity'].update-pending" + expect(page).to have_selector "input[name='quantity'].update-success" + expect(page).to have_selector "input[name='final_weight_volume'].update-success", visible: false + expect(page).to have_selector "input[name='price'].update-success", visible: false end end end @@ -153,10 +149,10 @@ feature %q{ visit '/admin/orders/bulk_management' first("div#columns_dropdown", :text => "COLUMNS").click first("div#columns_dropdown div.menu div.menu_item", text: "Weight/Volume").click - page.should_not have_css "input[name='price'].update-pending" + expect(page).to_not have_css "input[name='price'].update-pending" li1_final_weight_volume_column = find("tr#li_#{li1.id} td.final_weight_volume") li1_final_weight_volume_column.fill_in "final_weight_volume", :with => 1200 - page.should have_css "input[name='price'].update-pending", :visible => false + expect(page).to have_css "input[name='price'].update-pending", :visible => false end end @@ -165,10 +161,10 @@ feature %q{ visit '/admin/orders/bulk_management' #first("div#columns_dropdown", :text => "COLUMNS").click #first("div#columns_dropdown div.menu div.menu_item", text: "Quantity").click - page.should_not have_css "input[name='price'].update-pending" + expect(page).to_not have_css "input[name='price'].update-pending" li1_quantity_column = find("tr#li_#{li1.id} td.quantity") li1_quantity_column.fill_in "quantity", :with => 6 - page.should have_css "input[name='price'].update-pending", :visible => false + expect(page).to have_css "input[name='price'].update-pending", :visible => false end end @@ -177,10 +173,10 @@ feature %q{ visit '/admin/orders/bulk_management' first("div#columns_dropdown", :text => "COLUMNS").click first("div#columns_dropdown div.menu div.menu_item", text: "Weight/Volume").click - page.should_not have_css "input[name='price'].update-pending" + expect(page).to_not have_css "input[name='price'].update-pending" li1_quantity_column = find("tr#li_#{li1.id} td.quantity") li1_quantity_column.fill_in "quantity", :with => 6 - page.should have_css "input[name='final_weight_volume'].update-pending", :visible => false + expect(page).to have_css "input[name='final_weight_volume'].update-pending", :visible => false end end @@ -188,22 +184,22 @@ feature %q{ it "shows a column display toggle button, which shows a list of columns when clicked" do visit '/admin/orders/bulk_management' - page.should have_selector "th", :text => "NAME" - page.should have_selector "th", :text => "ORDER DATE" - page.should have_selector "th", :text => "PRODUCER" - page.should have_selector "th", :text => "PRODUCT: UNIT" - page.should have_selector "th", :text => "QUANTITY" - page.should have_selector "th", :text => "MAX" + expect(page).to have_selector "th", :text => "NAME" + expect(page).to have_selector "th", :text => "ORDER DATE" + expect(page).to have_selector "th", :text => "PRODUCER" + expect(page).to have_selector "th", :text => "PRODUCT: UNIT" + expect(page).to have_selector "th", :text => "QUANTITY" + expect(page).to have_selector "th", :text => "MAX" first("div#columns_dropdown", :text => "COLUMNS").click first("div#columns_dropdown div.menu div.menu_item", text: "Producer").click - page.should_not have_selector "th", :text => "PRODUCER" - page.should have_selector "th", :text => "NAME" - page.should have_selector "th", :text => "ORDER DATE" - page.should have_selector "th", :text => "PRODUCT: UNIT" - page.should have_selector "th", :text => "QUANTITY" - page.should have_selector "th", :text => "MAX" + expect(page).to_not have_selector "th", :text => "PRODUCER" + expect(page).to have_selector "th", :text => "NAME" + expect(page).to have_selector "th", :text => "ORDER DATE" + expect(page).to have_selector "th", :text => "PRODUCT: UNIT" + expect(page).to have_selector "th", :text => "QUANTITY" + expect(page).to have_selector "th", :text => "MAX" end end @@ -223,22 +219,22 @@ feature %q{ supplier_names = ["All"] Enterprise.is_primary_producer.each{ |e| supplier_names << e.name } find("div.select2-container#s2id_supplier_filter").click - supplier_names.each { |sn| page.should have_selector "div.select2-drop-active ul.select2-results li", text: sn } + supplier_names.each { |sn| expect(page).to have_selector "div.select2-drop-active ul.select2-results li", text: sn } find("div.select2-container#s2id_supplier_filter").click - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to have_selector "tr#li_#{li2.id}", visible: true select2_select s1.name, from: "supplier_filter" - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should_not have_selector "tr#li_#{li2.id}" + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li2.id}" end it "displays all line items when 'All' is selected from supplier filter" do select2_select s1.name, from: "supplier_filter" - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should_not have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li2.id}", visible: true select2_select "All", from: "supplier_filter" - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to have_selector "tr#li_#{li2.id}", visible: true end end @@ -258,22 +254,22 @@ feature %q{ distributor_names = ["All"] Enterprise.is_distributor.each{ |e| distributor_names << e.name } find("div.select2-container#s2id_distributor_filter").click - distributor_names.each { |dn| page.should have_selector "div.select2-drop-active ul.select2-results li", text: dn } + distributor_names.each { |dn| expect(page).to have_selector "div.select2-drop-active ul.select2-results li", text: dn } find("div.select2-container#s2id_distributor_filter").click - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to have_selector "tr#li_#{li2.id}", visible: true select2_select d1.name, from: "distributor_filter" - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should_not have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li2.id}", visible: true end it "displays all line items when 'All' is selected from distributor filter" do select2_select d1.name, from: "distributor_filter" - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should_not have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li2.id}", visible: true select2_select "All", from: "distributor_filter" - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to have_selector "tr#li_#{li2.id}", visible: true end end @@ -293,24 +289,24 @@ feature %q{ it "displays a select box for order cycles, which filters line items by the selected order cycle" do order_cycle_names = OrderCycle.pluck(:name).push "All" find("div.select2-container#s2id_order_cycle_filter").click - order_cycle_names.each { |ocn| page.should have_selector "div.select2-drop-active ul.select2-results li", text: ocn } + order_cycle_names.each { |ocn| expect(page).to have_selector "div.select2-drop-active ul.select2-results li", text: ocn } find("div.select2-container#s2id_order_cycle_filter").click - page.should have_selector "tr#li_#{li1.id}" - page.should have_selector "tr#li_#{li2.id}" + expect(page).to have_selector "tr#li_#{li1.id}" + expect(page).to have_selector "tr#li_#{li2.id}" select2_select oc1.name, from: "order_cycle_filter" - page.should have_selector "#loading img.spinner" - page.should_not have_selector "#loading img.spinner" - page.should have_selector "tr#li_#{li1.id}" - page.should_not have_selector "tr#li_#{li2.id}" + expect(page).to have_selector "#loading img.spinner" + expect(page).to_not have_selector "#loading img.spinner" + expect(page).to have_selector "tr#li_#{li1.id}" + expect(page).to_not have_selector "tr#li_#{li2.id}" end it "displays all line items when 'All' is selected from order_cycle filter" do select2_select oc1.name, from: "order_cycle_filter" - page.should have_selector "tr#li_#{li1.id}" - page.should_not have_selector "tr#li_#{li2.id}" + expect(page).to have_selector "tr#li_#{li1.id}" + expect(page).to_not have_selector "tr#li_#{li2.id}" select2_select "All", from: "order_cycle_filter" - page.should have_selector "tr#li_#{li1.id}" - page.should have_selector "tr#li_#{li2.id}" + expect(page).to have_selector "tr#li_#{li1.id}" + expect(page).to have_selector "tr#li_#{li2.id}" end end @@ -334,34 +330,34 @@ feature %q{ it "allows filters to be used in combination" do select2_select oc1.name, from: "order_cycle_filter" - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should_not have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li2.id}", visible: true select2_select d1.name, from: "distributor_filter" select2_select s1.name, from: "supplier_filter" - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should_not have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li2.id}", visible: true select2_select d2.name, from: "distributor_filter" select2_select s2.name, from: "supplier_filter" - page.should_not have_selector "tr#li_#{li1.id}", visible: true - page.should_not have_selector "tr#li_#{li2.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li1.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li2.id}", visible: true select2_select oc2.name, from: "order_cycle_filter" - page.should_not have_selector "tr#li_#{li1.id}", visible: true - page.should have_selector "tr#li_#{li2.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li1.id}", visible: true + expect(page).to have_selector "tr#li_#{li2.id}", visible: true end it "displays a 'Clear All' button which sets all select filters to 'All'" do select2_select oc1.name, from: "order_cycle_filter" select2_select d1.name, from: "distributor_filter" select2_select s1.name, from: "supplier_filter" - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should_not have_selector "tr#li_#{li2.id}", visible: true - page.should have_button "Clear All" + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_button "Clear All" click_button "Clear All" - page.should have_selector "div#s2id_order_cycle_filter a.select2-choice", text: "All" - page.should have_selector "div#s2id_supplier_filter a.select2-choice", text: "All" - page.should have_selector "div#s2id_distributor_filter a.select2-choice", text: "All" - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "div#s2id_order_cycle_filter a.select2-choice", text: "All" + expect(page).to have_selector "div#s2id_supplier_filter a.select2-choice", text: "All" + expect(page).to have_selector "div#s2id_distributor_filter a.select2-choice", text: "All" + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to have_selector "tr#li_#{li2.id}", visible: true end end end @@ -379,17 +375,17 @@ feature %q{ end it "displays a quick search input" do - page.should have_field "quick_search" + expect(page).to have_field "quick_search" end it "filters line items based on their attributes and the contents of the quick search input" do - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should have_selector "tr#li_#{li2.id}", visible: true - page.should have_selector "tr#li_#{li3.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "tr#li_#{li3.id}", visible: true fill_in "quick_search", :with => o1.email - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should_not have_selector "tr#li_#{li2.id}", visible: true - page.should_not have_selector "tr#li_#{li3.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li2.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li3.id}", visible: true end end @@ -408,37 +404,37 @@ feature %q{ it "displays date fields for filtering orders, with default values set" do one_week_ago = Date.today.prev_day(7).strftime("%F") tonight = Date.tomorrow.strftime("%F") - page.should have_field "start_date_filter", with: one_week_ago - page.should have_field "end_date_filter", with: tonight + expect(page).to have_field "start_date_filter", with: one_week_ago + expect(page).to have_field "end_date_filter", with: tonight end it "only loads line items whose orders meet the date restriction criteria" do - page.should_not have_selector "tr#li_#{li1.id}", visible: true - page.should have_selector "tr#li_#{li2.id}", visible: true - page.should_not have_selector "tr#li_#{li3.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li1.id}", visible: true + expect(page).to have_selector "tr#li_#{li2.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li3.id}", visible: true end it "displays only line items whose orders meet the date restriction criteria, when changed" do fill_in "start_date_filter", :with => (Date.today - 9).strftime("%F") - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should have_selector "tr#li_#{li2.id}", visible: true - page.should_not have_selector "tr#li_#{li3.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to have_selector "tr#li_#{li2.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li3.id}", visible: true fill_in "end_date_filter", :with => (Date.today + 3).strftime("%F") - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should have_selector "tr#li_#{li2.id}", visible: true - page.should have_selector "tr#li_#{li3.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "tr#li_#{li3.id}", visible: true end context "when pending changes exist" do it "alerts the user when dates are altered" do li2_quantity_column = find("tr#li_#{li2.id} td.quantity") li2_quantity_column.fill_in "quantity", :with => li2.quantity + 1 - page.should_not have_button "IGNORE" - page.should_not have_button "SAVE" + expect(page).to_not have_button "IGNORE" + expect(page).to_not have_button "SAVE" fill_in "start_date_filter", :with => (Date.today - 9).strftime("%F %T") - page.should have_button "IGNORE" - page.should have_button "SAVE" + expect(page).to have_button "IGNORE" + expect(page).to have_button "SAVE" end it "saves pendings changes when 'SAVE' button is clicked" do @@ -446,12 +442,12 @@ feature %q{ page.fill_in "quantity", :with => (li2.quantity + 1).to_s end fill_in "start_date_filter", :with => (Date.today - 9).strftime("%F %T") - page.should have_selector "input[name='quantity'].update-pending" + expect(page).to have_selector "input[name='quantity'].update-pending" click_button "SAVE" - page.should have_no_selector "input.update-pending" - page.should have_selector "input[name='quantity'].update-success" + expect(page).to have_no_selector "input.update-pending" + expect(page).to have_selector "input[name='quantity'].update-success" within("tr#li_#{li2.id} td.quantity") do - page.should have_field "quantity", :with => ( li2.quantity + 1 ).to_s + expect(page).to have_field "quantity", :with => ( li2.quantity + 1 ).to_s end end @@ -461,9 +457,9 @@ feature %q{ end fill_in "start_date_filter", :with => (Date.today - 9).strftime("%F %T") click_button "IGNORE" - page.should_not have_selector "input[name='quantity'].update-pending" + expect(page).to_not have_selector "input[name='quantity'].update-pending" within("tr#li_#{li2.id} td.quantity") do - page.should have_field "quantity", :with => ( li2.quantity ).to_s + expect(page).to have_field "quantity", :with => ( li2.quantity ).to_s end end end @@ -480,36 +476,36 @@ feature %q{ end it "displays a checkbox for each line item in the list" do - page.should have_selector "tr#li_#{li1.id} input[type='checkbox'][name='bulk']" - page.should have_selector "tr#li_#{li2.id} input[type='checkbox'][name='bulk']" + expect(page).to have_selector "tr#li_#{li1.id} input[type='checkbox'][name='bulk']" + expect(page).to have_selector "tr#li_#{li2.id} input[type='checkbox'][name='bulk']" end it "displays a checkbox to which toggles the 'checked' state of all checkboxes" do check "toggle_bulk" - page.all("input[type='checkbox'][name='bulk']").each{ |checkbox| checkbox.checked?.should == true } + page.all("input[type='checkbox'][name='bulk']").each{ |checkbox| expect(checkbox.checked?).to be true } uncheck "toggle_bulk" - page.all("input[type='checkbox'][name='bulk']").each{ |checkbox| checkbox.checked?.should == false } + page.all("input[type='checkbox'][name='bulk']").each{ |checkbox| expect(checkbox.checked?).to be false } end it "displays a bulk action select box with a list of actions" do list_of_actions = ['Delete Selected'] find("div#bulk_actions_dropdown").click within("div#bulk_actions_dropdown") do - list_of_actions.each { |action_name| page.should have_selector "div.menu_item", text: action_name } + list_of_actions.each { |action_name| expect(page).to have_selector "div.menu_item", text: action_name } end end context "performing actions" do it "deletes selected items" do - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to have_selector "tr#li_#{li2.id}", visible: true within("tr#li_#{li2.id} td.bulk") do check "bulk" end find("div#bulk_actions_dropdown").click find("div#bulk_actions_dropdown div.menu_item", :text => "Delete Selected" ).click - page.should have_selector "tr#li_#{li1.id}", visible: true - page.should_not have_selector "tr#li_#{li2.id}", visible: true + expect(page).to have_selector "tr#li_#{li1.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li2.id}", visible: true end end @@ -518,9 +514,9 @@ feature %q{ fill_in "quick_search", with: o1.number check "toggle_bulk" fill_in "quick_search", with: '' - find("tr#li_#{li1.id} input[type='checkbox'][name='bulk']").checked?.should == true - find("tr#li_#{li2.id} input[type='checkbox'][name='bulk']").checked?.should == false - find("input[type='checkbox'][name='toggle_bulk']").checked?.should == false + expect(find("tr#li_#{li1.id} input[type='checkbox'][name='bulk']").checked?).to be true + expect(find("tr#li_#{li2.id} input[type='checkbox'][name='bulk']").checked?).to be false + expect(find("input[type='checkbox'][name='toggle_bulk']").checked?).to be false end it "only applies the delete action to filteredLineItems" do @@ -529,8 +525,8 @@ feature %q{ find("div#bulk_actions_dropdown").click find("div#bulk_actions_dropdown div.menu_item", :text => "Delete Selected" ).click fill_in "quick_search", with: '' - page.should_not have_selector "tr#li_#{li1.id}", visible: true - page.should have_selector "tr#li_#{li2.id}", visible: true + expect(page).to_not have_selector "tr#li_#{li1.id}", visible: true + expect(page).to have_selector "tr#li_#{li2.id}", visible: true end end end @@ -547,11 +543,11 @@ feature %q{ end it "shows an edit button for line_items, which takes the user to the standard edit page for the order" do - page.should have_selector "a.edit-order", :count => 2 + expect(page).to have_selector "a.edit-order", :count => 2 first("a.edit-order").click - URI.parse(current_url).path.should == "/admin/orders/#{o1.number}/edit" + expect(URI.parse(current_url).path).to eq "/admin/orders/#{o1.number}/edit" end end @@ -566,15 +562,15 @@ feature %q{ end it "shows a delete button for each line item" do - page.should have_selector "a.delete-line-item", :count => 2 + expect(page).to have_selector "a.delete-line-item", :count => 2 end it "removes a line item when the relevant delete button is clicked" do first("a.delete-line-item").click - page.should_not have_selector "a.delete-line-item", :count => 2 - page.should have_selector "a.delete-line-item", :count => 1 + expect(page).to_not have_selector "a.delete-line-item", :count => 2 + expect(page).to have_selector "a.delete-line-item", :count => 1 visit '/admin/orders/bulk_management' - page.should have_selector "a.delete-line-item", :count => 1 + expect(page).to have_selector "a.delete-line-item", :count => 1 end end end @@ -598,32 +594,32 @@ feature %q{ end it "displays group buy calc box" do - page.should have_selector "div#group_buy_calculation", :visible => true + expect(page).to have_selector "div#group_buy_calculation", :visible => true within "div#group_buy_calculation" do - page.should have_text "Group Buy Unit Size" - page.should have_text "5 kg" - page.should have_text "Total Quantity Ordered" - page.should have_text "4 kg" - page.should have_text "Max Quantity Ordered" - page.should have_text "9 kg" - page.should have_text "Current Fulfilled Units" - page.should have_text "0.8" - page.should have_text "Max Fulfilled Units" - page.should have_text "1.8" - page.should have_selector "div.shared_resource", :visible => true + expect(page).to have_text "Group Buy Unit Size" + expect(page).to have_text "5 kg" + expect(page).to have_text "Total Quantity Ordered" + expect(page).to have_text "4 kg" + expect(page).to have_text "Max Quantity Ordered" + expect(page).to have_text "9 kg" + expect(page).to have_text "Current Fulfilled Units" + expect(page).to have_text "0.8" + expect(page).to have_text "Max Fulfilled Units" + expect(page).to have_text "1.8" + expect(page).to have_selector "div.shared_resource", :visible => true within "div.shared_resource" do - page.should have_selector "span", :text => "Shared Resource?" - page.should have_selector "input#shared_resource" + expect(page).to have_selector "span", :text => "Shared Resource?" + expect(page).to have_selector "input#shared_resource" end end end it "all line items of the same variant" do - page.should_not have_selector "tr#li_#{li1.id}", :visible => true - page.should_not have_selector "tr#li_#{li2.id}", :visible => true - page.should have_selector "tr#li_#{li3.id}", :visible => true - page.should have_selector "tr#li_#{li4.id}", :visible => true + expect(page).to_not have_selector "tr#li_#{li1.id}", :visible => true + expect(page).to_not have_selector "tr#li_#{li2.id}", :visible => true + expect(page).to have_selector "tr#li_#{li3.id}", :visible => true + expect(page).to have_selector "tr#li_#{li4.id}", :visible => true end context "clicking 'Clear' in group buy box" do @@ -632,11 +628,11 @@ feature %q{ end it "shows all products and clears group buy box" do - page.should_not have_selector "div#group_buy_calculation", :visible => true - page.should have_selector "tr#li_#{li1.id}", :visible => true - page.should have_selector "tr#li_#{li2.id}", :visible => true - page.should have_selector "tr#li_#{li3.id}", :visible => true - page.should have_selector "tr#li_#{li4.id}", :visible => true + expect(page).to_not have_selector "div#group_buy_calculation", :visible => true + expect(page).to have_selector "tr#li_#{li1.id}", :visible => true + expect(page).to have_selector "tr#li_#{li2.id}", :visible => true + expect(page).to have_selector "tr#li_#{li3.id}", :visible => true + expect(page).to have_selector "tr#li_#{li4.id}", :visible => true end end end @@ -661,16 +657,16 @@ feature %q{ it "displays a Bulk Management Tab under the Orders item" do visit '/admin/orders' - page.should have_link "Bulk Order Management" + expect(page).to have_link "Bulk Order Management" click_link "Bulk Order Management" - page.should have_selector "h1.page-title", text: "Bulk Order Management" + expect(page).to have_selector "h1.page-title", text: "Bulk Order Management" end it "shows only line item from orders that I distribute, and not those that I supply" do visit '/admin/orders/bulk_management' - page.should have_selector "tr#li_#{line_item_distributed.id}", :visible => true - page.should_not have_selector "tr#li_#{line_item_not_distributed.id}", :visible => true + expect(page).to have_selector "tr#li_#{line_item_distributed.id}", :visible => true + expect(page).to_not have_selector "tr#li_#{line_item_not_distributed.id}", :visible => true end end end