From 7ddfb9771529f284569cdeeb798bc5e4f1c0439e Mon Sep 17 00:00:00 2001 From: Jeremy Evans Date: Tue, 17 Dec 2024 16:27:44 -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/roda/plugins/head.rb | 2 +- spec/plugin/not_found_spec.rb | 2 +- spec/plugin/status_handler_spec.rb | 2 +- 5 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 23d910f48..cf18bb0c8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,3 +1,7 @@ +=== master + +* Fix strict_unused_block warnings when running specs on Ruby 3.4 (jeremyevans) + = 3.87.0 (2024-12-17) * Add host_routing plugin for routing based on request host header (jeremyevans) diff --git a/Rakefile b/Rakefile index 256b469a6..bea9f2dd8 100644 --- a/Rakefile +++ b/Rakefile @@ -61,7 +61,7 @@ end spec = proc do |env| env.each{|k,v| ENV[k] = v} - sh "#{FileUtils::RUBY} #{"-w" if RUBY_VERSION >= '3'} spec/all.rb" + sh "#{FileUtils::RUBY} #{"-w" if RUBY_VERSION >= '3'} #{'-W:strict_unused_block' if RUBY_VERSION >= '3.4'} spec/all.rb" env.each{|k,v| ENV.delete(k)} if File.directory?('.sass-cache') require 'fileutils' diff --git a/lib/roda/plugins/head.rb b/lib/roda/plugins/head.rb index 7c8632052..03dfa1852 100644 --- a/lib/roda/plugins/head.rb +++ b/lib/roda/plugins/head.rb @@ -45,7 +45,7 @@ def initialize(body) end # yield nothing - def each + def each(&_) end # this should be called by the Rack server diff --git a/spec/plugin/not_found_spec.rb b/spec/plugin/not_found_spec.rb index 5432dac5b..2631ca12d 100644 --- a/spec/plugin/not_found_spec.rb +++ b/spec/plugin/not_found_spec.rb @@ -102,7 +102,7 @@ end o = Object.new - def o.each; end + def o.each(&_); end route do |r| r.halt [404, {}, o] end diff --git a/spec/plugin/status_handler_spec.rb b/spec/plugin/status_handler_spec.rb index 8cbf0b81e..9f1fc8557 100644 --- a/spec/plugin/status_handler_spec.rb +++ b/spec/plugin/status_handler_spec.rb @@ -135,7 +135,7 @@ end o = Object.new - def o.each; end + def o.each(&_); end route do |r| r.halt [404, {}, o] end