From bc1e8bfde6ab4d8965053e9bb04281d49fa3a3fc Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Fri, 17 Aug 2018 15:01:57 +1000 Subject: [PATCH] Convert specs to RSpec 3.7.0 syntax with Transpec This conversion is done by Transpec 3.3.0 with the following command: transpec spec/features/admin/enterprise_fees_spec.rb * 27 conversions from: obj.should to: expect(obj).to * 8 conversions from: == expected to: eq(expected) * 4 conversions from: obj.should_not to: expect(obj).not_to For more details: https://github.com/yujinakayama/transpec#supported-conversions --- spec/features/admin/enterprise_fees_spec.rb | 62 ++++++++++----------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/spec/features/admin/enterprise_fees_spec.rb b/spec/features/admin/enterprise_fees_spec.rb index 69b3d88bd5..9bc919ad57 100644 --- a/spec/features/admin/enterprise_fees_spec.rb +++ b/spec/features/admin/enterprise_fees_spec.rb @@ -17,12 +17,12 @@ feature %q{ click_link 'Configuration' click_link 'Enterprise Fees' - page.should have_select "enterprise_fee_set_collection_attributes_0_enterprise_id" - page.should have_select "enterprise_fee_set_collection_attributes_0_fee_type", selected: 'Packing' - page.should have_selector "input[value='$0.50 / kg']" - page.should have_select "enterprise_fee_set_collection_attributes_0_tax_category_id", selected: 'GST' - page.should have_select "enterprise_fee_set_collection_attributes_0_calculator_type", selected: 'Flat Rate (per item)' - page.should have_selector "input[value='#{amount}']" + expect(page).to have_select "enterprise_fee_set_collection_attributes_0_enterprise_id" + expect(page).to have_select "enterprise_fee_set_collection_attributes_0_fee_type", selected: 'Packing' + expect(page).to have_selector "input[value='$0.50 / kg']" + expect(page).to have_select "enterprise_fee_set_collection_attributes_0_tax_category_id", selected: 'GST' + expect(page).to have_select "enterprise_fee_set_collection_attributes_0_calculator_type", selected: 'Flat Rate (per item)' + expect(page).to have_selector "input[value='#{amount}']" end scenario "creating an enterprise fee" do @@ -42,15 +42,15 @@ feature %q{ click_button 'Update' # Then I should see my fee and fields for the calculator - page.should have_content "Your enterprise fees have been updated." - page.should have_selector "input[value='Hello!']" + expect(page).to have_content "Your enterprise fees have been updated." + expect(page).to have_selector "input[value='Hello!']" # When I fill in the calculator fields and click update fill_in 'enterprise_fee_set_collection_attributes_0_calculator_attributes_preferred_flat_percent', with: '12.34' click_button 'Update' # Then I should see the correct values in my calculator fields - page.should have_selector "#enterprise_fee_set_collection_attributes_0_calculator_attributes_preferred_flat_percent[value='12.34']" + expect(page).to have_selector "#enterprise_fee_set_collection_attributes_0_calculator_attributes_preferred_flat_percent[value='12.34']" end scenario "editing an enterprise fee" do @@ -71,21 +71,21 @@ feature %q{ click_button 'Update' # Then I should see the updated fields for my fee - page.should have_select "enterprise_fee_set_collection_attributes_0_enterprise_id", selected: 'Foo' - page.should have_select "enterprise_fee_set_collection_attributes_0_fee_type", selected: 'Admin' - page.should have_selector "input[value='Greetings!']" - page.should have_select 'enterprise_fee_set_collection_attributes_0_tax_category_id', selected: 'Inherit From Product' - page.should have_selector "option[selected]", text: 'Flat Percent (per item)' + expect(page).to have_select "enterprise_fee_set_collection_attributes_0_enterprise_id", selected: 'Foo' + expect(page).to have_select "enterprise_fee_set_collection_attributes_0_fee_type", selected: 'Admin' + expect(page).to have_selector "input[value='Greetings!']" + expect(page).to have_select 'enterprise_fee_set_collection_attributes_0_tax_category_id', selected: 'Inherit From Product' + expect(page).to have_selector "option[selected]", text: 'Flat Percent (per item)' fee.reload - fee.enterprise.should == enterprise - fee.name.should == 'Greetings!' - fee.fee_type.should == 'admin' - fee.calculator_type.should == "Calculator::FlatPercentPerItem" + expect(fee.enterprise).to eq(enterprise) + expect(fee.name).to eq('Greetings!') + expect(fee.fee_type).to eq('admin') + expect(fee.calculator_type).to eq("Calculator::FlatPercentPerItem") # Sets tax_category and inherits_tax_category - fee.tax_category.should == nil - fee.inherits_tax_category.should == true + expect(fee.tax_category).to eq(nil) + expect(fee.inherits_tax_category).to eq(true) end scenario "deleting an enterprise fee" do @@ -119,12 +119,12 @@ feature %q{ find("a.delete-resource").click # Then I should see an error - page.should have_content "That enterprise fee cannot be deleted as it is referenced by a product distribution: #{p.id} - #{p.name}." + expect(page).to have_content "That enterprise fee cannot be deleted as it is referenced by a product distribution: #{p.id} - #{p.name}." # And my enterprise fee should not have been deleted visit admin_enterprise_fees_path - page.should have_selector "input[value='#{fee.name}']" - EnterpriseFee.find(fee.id).should_not be_nil + expect(page).to have_selector "input[value='#{fee.name}']" + expect(EnterpriseFee.find(fee.id)).not_to be_nil end context "as an enterprise manager" do @@ -154,13 +154,13 @@ feature %q{ select 'Flat Percent', :from => 'enterprise_fee_set_collection_attributes_0_calculator_type' click_button 'Update' - flash_message.should == 'Your enterprise fees have been updated.' + expect(flash_message).to eq('Your enterprise fees have been updated.') # After saving, we should be redirected to the fees for our chosen enterprise - page.should_not have_select 'enterprise_fee_set_collection_attributes_1_enterprise_id', selected: 'Second Distributor' + expect(page).not_to have_select 'enterprise_fee_set_collection_attributes_1_enterprise_id', selected: 'Second Distributor' enterprise_fee = EnterpriseFee.find_by_name 'foo' - enterprise_fee.enterprise.should == distributor1 + expect(enterprise_fee.enterprise).to eq(distributor1) end pending "shows me only enterprise fees for the enterprise I select" do @@ -170,15 +170,15 @@ feature %q{ visit edit_admin_enterprise_path(distributor1) within(".side_menu") { click_link 'Enterprise Fees' } click_link "Settings Enterprise Fees" - page.should have_field 'enterprise_fee_set_collection_attributes_0_name', with: 'One' - page.should_not have_field 'enterprise_fee_set_collection_attributes_1_name', with: 'Two' + expect(page).to have_field 'enterprise_fee_set_collection_attributes_0_name', with: 'One' + expect(page).not_to have_field 'enterprise_fee_set_collection_attributes_1_name', with: 'Two' click_link 'Enterprises' within("#e_#{distributor2.id}") { click_link 'Settings' } within(".side_menu") { click_link 'Enterprise Fees' } click_link "Settings Enterprise Fees" - page.should_not have_field 'enterprise_fee_set_collection_attributes_0_name', with: 'One' - page.should have_field 'enterprise_fee_set_collection_attributes_0_name', with: 'Two' + expect(page).not_to have_field 'enterprise_fee_set_collection_attributes_0_name', with: 'One' + expect(page).to have_field 'enterprise_fee_set_collection_attributes_0_name', with: 'Two' end it "only allows me to select enterprises I have access to" do @@ -189,7 +189,7 @@ feature %q{ visit edit_admin_enterprise_path(distributor1) within(".side_menu") { click_link 'Enterprise Fees' } click_link "Manage Enterprise Fees" - page.should have_select('enterprise_fee_set_collection_attributes_1_enterprise_id', + expect(page).to have_select('enterprise_fee_set_collection_attributes_1_enterprise_id', selected: 'Second Distributor', options: ['', 'First Distributor', 'Second Distributor']) end