From 267daa57133191eb8da8625d02f45a0c8304416b Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 17 Dec 2024 16:22:02 -0800 Subject: [PATCH] Fix strict_unused_block warnings when running specs on Ruby 3.4 Run the specs with -W:strict_unused_block on Ruby 3.4 to more easily catch future issues. --- CHANGELOG | 4 ++++ Rakefile | 2 +- lib/sequel/extensions/migration.rb | 2 +- lib/sequel/extensions/null_dataset.rb | 4 ++-- spec/extensions/migration_spec.rb | 2 +- spec/model/hooks_spec.rb | 8 ++++---- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 1eec205417..89b0804b15 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +=== master + +* Fix strict_unused_block warnings when running specs on Ruby 3.4 (jeremyevans) + === 5.87.0 (2024-12-01) * Add pg_schema_caching extension, for reloading OIDs for custom types when loading cached schema (jeremyevans) diff --git a/Rakefile b/Rakefile index 82df67664e..99b215a7b4 100644 --- a/Rakefile +++ b/Rakefile @@ -70,7 +70,7 @@ run_spec = proc do |file| lib_dir = File.join(File.dirname(File.expand_path(__FILE__)), 'lib') rubylib = ENV['RUBYLIB'] ENV['RUBYLIB'] ? (ENV['RUBYLIB'] += ":#{lib_dir}") : (ENV['RUBYLIB'] = lib_dir) - sh "#{FileUtils::RUBY} #{"-w" if RUBY_VERSION >= '3'} #{file}" + sh "#{FileUtils::RUBY} #{"-w" if RUBY_VERSION >= '3'} #{'-W:strict_unused_block' if RUBY_VERSION >= '3.4'} #{file}" ENV['RUBYLIB'] = rubylib end diff --git a/lib/sequel/extensions/migration.rb b/lib/sequel/extensions/migration.rb index 23bc189a77..9a481dfbcb 100644 --- a/lib/sequel/extensions/migration.rb +++ b/lib/sequel/extensions/migration.rb @@ -223,7 +223,7 @@ def create_join_table(*args) @actions << [:drop_join_table, *args] end - def create_table(name, opts=OPTS) + def create_table(name, opts=OPTS, &_) @actions << [:drop_table, name, opts] end diff --git a/lib/sequel/extensions/null_dataset.rb b/lib/sequel/extensions/null_dataset.rb index 3c22c287cd..1ec6a5bd88 100644 --- a/lib/sequel/extensions/null_dataset.rb +++ b/lib/sequel/extensions/null_dataset.rb @@ -63,12 +63,12 @@ def delete end # Return self without sending a database query, never yielding. - def each + def each(&_) self end # Return nil without sending a database query, never yielding. - def fetch_rows(sql) + def fetch_rows(sql, &_) nil end diff --git a/spec/extensions/migration_spec.rb b/spec/extensions/migration_spec.rb index b9d88d82e0..5661597dc4 100644 --- a/spec/extensions/migration_spec.rb +++ b/spec/extensions/migration_spec.rb @@ -447,7 +447,7 @@ def table_exists?(name) it "should add a column name if it doesn't already exist in the schema_info table" do @db.create_table(:schema_info){Integer :v} - def @db.alter_table(*); end + def @db.alter_table(*, &_); end Sequel::Migrator.apply(@db, @dirname) end diff --git a/spec/model/hooks_spec.rb b/spec/model/hooks_spec.rb index 9ccd73292a..863b02cb93 100644 --- a/spec/model/hooks_spec.rb +++ b/spec/model/hooks_spec.rb @@ -353,19 +353,19 @@ def around_validation @c.raise_on_save_failure = false o = @c.load(:id => 1) - def o.around_save() end + def o.around_save(&_) end o.save.must_be_nil o = @c.load(:id => 1) - def o.around_update() end + def o.around_update(&_) end o.save.must_be_nil o = @c.new - def o.around_create() end + def o.around_create(&_) end o.save.must_be_nil o = @c.new - def o.around_validation() end + def o.around_validation(&_) end o.save.must_be_nil end end