From 3fe65bafd1b44d2dd68d2dc9cdbda9baf56572f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 19 Sep 2021 17:25:36 +0200 Subject: [PATCH] Use keyword arguments in mappable specs We were getting a warning with Ruby 2.7 due to the change in the way keyword arguments are handled in Ruby 3.0. ``` ruby/gems/2.7.0/gems/rspec-support-3.11.0/lib/rspec/support/with_keywords_when_needed.rb:18: warning: Passing the keyword argument as the last hash parameter is deprecated ``` As hinted by the warning, this code crashes with Ruby 3.0: ``` ArgumentError: unknown keyword: :budget_id ``` I'm not sure why this is the case, though, since we were already explicitely passing a hash first before passing the keyword parameters. I guess there are some cases in this whole keyword VS hash parameters incompatibility that I haven't completely understood. --- spec/shared/system/mappable.rb | 2 +- spec/system/budgets/investments_spec.rb | 2 +- spec/system/management/budget_investments_spec.rb | 2 +- spec/system/proposals_spec.rb | 3 +-- 4 files changed, 4 insertions(+), 5 deletions(-) diff --git a/spec/shared/system/mappable.rb b/spec/shared/system/mappable.rb index 68d1edde4..0ce4f5cd5 100644 --- a/spec/shared/system/mappable.rb +++ b/spec/shared/system/mappable.rb @@ -1,4 +1,4 @@ -shared_examples "mappable" do |mappable_factory_name, mappable_association_name, mappable_new_path, mappable_edit_path, mappable_show_path, mappable_path_arguments, management: false| +shared_examples "mappable" do |mappable_factory_name, mappable_association_name, mappable_new_path, mappable_edit_path, mappable_show_path, mappable_path_arguments: {}, management: false| let!(:user) { create(:user, :level_two) } let!(:arguments) { {} } let!(:mappable) { create(mappable_factory_name.to_s.to_sym) } diff --git a/spec/system/budgets/investments_spec.rb b/spec/system/budgets/investments_spec.rb index 0935d3d73..07d35acaf 100644 --- a/spec/system/budgets/investments_spec.rb +++ b/spec/system/budgets/investments_spec.rb @@ -1130,7 +1130,7 @@ describe "Budget Investments" do "new_budget_investment_path", "", "budget_investment_path", - { budget_id: "budget_id" } + mappable_path_arguments: { budget_id: "budget_id" } context "Destroy" do scenario "Admin cannot destroy budget investments", :admin do diff --git a/spec/system/management/budget_investments_spec.rb b/spec/system/management/budget_investments_spec.rb index 857a1f146..b9dd0c326 100644 --- a/spec/system/management/budget_investments_spec.rb +++ b/spec/system/management/budget_investments_spec.rb @@ -32,7 +32,7 @@ describe "Budget Investments" do "new_management_budget_investment_path", "", "management_budget_investment_path", - { budget_id: "budget_id" }, + mappable_path_arguments: { budget_id: "budget_id" }, management: true context "Load" do diff --git a/spec/system/proposals_spec.rb b/spec/system/proposals_spec.rb index a921fc31e..19d7ffa9a 100644 --- a/spec/system/proposals_spec.rb +++ b/spec/system/proposals_spec.rb @@ -1296,8 +1296,7 @@ describe "Proposals" do "proposal", "new_proposal_path", "edit_proposal_path", - "proposal_path", - {} + "proposal_path" scenario "Erased author" do user = create(:user)