A platform for community discussion. Free, open, simple.
DEV: Make specs pass with ruby 3.4 (#35411)
Osama Sayegh8a22edb8b0c2
diff --git a/spec/lib/discourse_logstash_logger_spec.rb b/spec/lib/discourse_logstash_logger_spec.rbindex ed433569077..f40350760d9 100644--- a/spec/lib/discourse_logstash_logger_spec.rb+++ b/spec/lib/discourse_logstash_logger_spec.rb@@ -74,7 +74,8 @@ RSpec.describe DiscourseLogstashLogger doexpect(parsed["exception.class"]).to eq("Some::StandardError")expect(parsed["exception.message"]).to eq("some job error message")expect(parsed["job.class"]).to eq("SomeJob")- expect(parsed["job.opts"]).to eq("{\"user_id\"=>1}")+ # first option is for ruby 3.3 and the other for 3.4+ expect(parsed["job.opts"]).to eq('{"user_id"=>1}').or eq('{"user_id" => 1}')expect(parsed["job.problem_db"]).to eq("some_db")endenddiff --git a/spec/lib/service/steps_inspector_spec.rb b/spec/lib/service/steps_inspector_spec.rbindex 873dfac3a20..f1bba444222 100644--- a/spec/lib/service/steps_inspector_spec.rb+++ b/spec/lib/service/steps_inspector_spec.rb@@ -341,7 +341,10 @@ RSpec.describe Service::StepsInspector doendit "returns the provided paramaters" do- expect(error).to match(/{"parameter"=>nil, "other_param"=>nil}/)+ # first option is for ruby 3.3 and the other for 3.4+ expect(error).to match(/{"parameter"=>nil, "other_param"=>nil}/).or match(+ /{"parameter" => nil, "other_param" => nil}/,+ )endend@@ -404,6 +407,9 @@ RSpec.describe Service::StepsInspector dolet(:parameter) { nil }it "outputs the service class name, the steps results and the specific error" do+ # first option is for ruby 3.3 and the other for 3.4+ # the only difference between them is in the last line where the hash+ # arrows are surrounded with spacesexpect(inspector.inspect.gsub(%r{ \(\d+\.\d+ ms\)}, "").gsub(/\e\[\d+(;\d+)?m/, "")).to eq(<<~OUTPUT,Inspecting DummyService result object:@@ -421,7 +427,22 @@ RSpec.describe Service::StepsInspector doProvided parameters: {"parameter"=>nil, "other_param"=>nil}OUTPUT- )+ ).or eq(<<~OUTPUT)+ Inspecting DummyService result object:++ [ 1/13] [options] default ✅+ [ 2/13] [model] model ✅+ [ 3/13] [policy] policy ✅+ [ 4/13] [params] default ❌++ (9 more steps not shown as the execution flow was stopped before reaching them)++ Why it failed:++ #<ActiveModel::Errors [#<ActiveModel::Error attribute=parameter, type=blank, options={}>]>++ Provided parameters: {"parameter" => nil, "other_param" => nil}+ OUTPUTendendenddiff --git a/spec/requests/admin/users_controller_spec.rb b/spec/requests/admin/users_controller_spec.rbindex a713b21b36e..804bc9409a1 100644--- a/spec/requests/admin/users_controller_spec.rb+++ b/spec/requests/admin/users_controller_spec.rb@@ -2643,7 +2643,10 @@ RSpec.describe Admin::UsersController dotarget_user_id: user.id,action: UserHistory.actions[:delete_associated_accounts],)- expect(UserHistory.last.previous_value).to include(':uid=>"123456789"')+ # first option is for ruby 3.3 and the other for 3.4+ expect(UserHistory.last.previous_value).to include(':uid=>"123456789"').or include(+ 'uid: "123456789"',+ )endenddiff --git a/spec/serializers/wizard_serializer_spec.rb b/spec/serializers/wizard_serializer_spec.rbindex 988a8f1acc0..294b8afe822 100644--- a/spec/serializers/wizard_serializer_spec.rb+++ b/spec/serializers/wizard_serializer_spec.rb@@ -37,8 +37,8 @@ RSpec.describe WizardSerializer dojson = MultiJson.load(MultiJson.dump(serializer.as_json))expect(json["wizard"]["current_color_scheme"].to_s).to include(- '{"name"=>"header_background", "hex"=>"00FF00"}',- )+ '{"name"=>"header_background", "hex"=>"00FF00"}', # ruby 3.3+ ).or include('{"name" => "header_background", "hex" => "00FF00"}') # ruby 3.4endend