Skip to content

Commit 00174ef

Browse files
transclaude
andcommitted
Fix Ruby 3+ keyword argument handling in method test dispatch
The method wrapper used |*a, &b| which swallows kwargs in Ruby 3, breaking methods that accept keyword arguments. Now uses |*a, **kw, &b|. Also separates NameError (method doesn't exist) from other errors during method aliasing for clearer error messages, and removes Ruby 1.8/1.9 compatibility guards. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5bc36fb commit 00174ef

6 files changed

Lines changed: 25 additions & 23 deletions

File tree

HISTORY.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# RELEASE HISTORY
22

3+
## 0.9.3 / 2026-04-01
4+
5+
Bug fix release. Fixes Ruby 3+ compatibility issues in test method dispatch.
6+
7+
Changes:
8+
9+
* Fix keyword argument handling in method test wrapper (Ruby 3+ kwargs split).
10+
* Separate NameError from general errors in method aliasing for clearer messages.
11+
* Include original error message in "not tested" error reports.
12+
* Remove Ruby 1.8/1.9 compatibility guards.
13+
14+
315
## 0.9.2 / 2026-03-31
416

517
Maintenance release. Modernized project tooling and cleaned up documentation.

lemon.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = 'lemon'
3-
s.version = '0.9.2'
3+
s.version = '0.9.3'
44
s.summary = 'Pucker-strength Unit Testing'
55
s.description = 'Lemon is a unit testing framework that tightly correlates ' \
66
'class to test case and method to test unit.'

lib/lemon.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module Lemon
2-
VERSION = '0.9.2'
2+
VERSION = '0.9.3'
33
end
44

55
# Ruby Test standard location for test objects.

lib/lemon/core_ext.rb

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,2 @@
1-
if RUBY_VERSION > '1.9'
2-
require_relative 'core_ext/kernel'
3-
require_relative 'core_ext/module'
4-
else
5-
require 'lemon/core_ext/kernel'
6-
require 'lemon/core_ext/module'
7-
end
1+
require_relative 'core_ext/kernel'
2+
require_relative 'core_ext/module'

lib/lemon/test_method.rb

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,18 @@ def run(test, &block)
8383
begin
8484
target_class.class_eval do
8585
alias_method "_lemon_#{target}", target
86-
define_method(target) do |*a,&b|
86+
define_method(target) do |*a, **kw, &b|
8787
test.tested = true
88-
__send__("_lemon_#{target}",*a,&b)
88+
__send__("_lemon_#{target}", *a, **kw, &b)
8989
end
9090
end
91+
rescue NameError
92+
Kernel.eval <<-END, test.to_proc.binding
93+
raise NameError, "#{target} is not defined"
94+
END
9195
rescue => error
9296
Kernel.eval <<-END, test.to_proc.binding
93-
raise #{error.class}, "#{target} not tested"
97+
raise #{error.class}, "#{target} not tested (#{error.message})"
9498
END
9599
end
96100

@@ -111,11 +115,7 @@ def run(test, &block)
111115
#
112116
#
113117
def raise_pending(procedure)
114-
if RUBY_VERSION < '1.9'
115-
Kernel.eval %[raise NotImplementedError, "#{target} not tested"], procedure
116-
else
117-
Kernel.eval %[raise NotImplementedError, "#{target} not tested"], procedure.binding
118-
end
118+
Kernel.eval %[raise NotImplementedError, "#{target} not tested"], procedure.binding
119119
end
120120

121121
#

lib/lemon/test_world.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
1-
if RUBY_VERSION < '1.9'
2-
require 'lemon/ignore_callers'
3-
else
4-
require_relative 'ignore_callers'
5-
end
1+
require_relative 'ignore_callers'
62

73
module Lemon
84

@@ -13,4 +9,3 @@ class World < Module
139
end
1410

1511
end
16-

0 commit comments

Comments
 (0)