Skip to content

Proxy doesn't support keyworad argument of Ruby 3.0 #77

@ashie

Description

@ashie

Example test code

require 'test/unit/rr'

class Klass
  def write(txt, silent: true)
    puts(txt) unless silent
  end
end

class TestKlass < Test::Unit::TestCase
  test "write" do
    c = Klass.new
    mock.proxy(c).write("write", silent: false).once
    c.write("write", silent: false)
  end
end

Result on Ruby 2.6.6

$ rbenv local 2.6.6
$ ruby -w -I"lib:test" test_proxy.rb
Loaded suite test_proxy
Started
write
.
Finished in 0.000560186 seconds.
---------------------------------------------------------------------------------------------------------------------------------------------
1 tests, 0 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
---------------------------------------------------------------------------------------------------------------------------------------------
1785.12 tests/s, 0.00 assertions/s

Result on Ruby 3.0.0

$ rbenv local 3.0.0
$ ruby -w -I"lib:test" test_proxy.rb
Loaded suite test_proxy
Started
E
=============================================================================================================================================
test_proxy.rb:13:in `block in <class:TestKlass>'
/home/aho/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rr-1.2.1/lib/rr/injections/double_injection.rb:148:in `write'
/home/aho/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rr-1.2.1/lib/rr/injections/double_injection.rb:40:in `dispatch_method'
/home/aho/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rr-1.2.1/lib/rr/injections/double_injection.rb:183:in `dispatch_method'
/home/aho/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rr-1.2.1/lib/rr/method_dispatches/method_dispatch.rb:16:in `call'
/home/aho/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rr-1.2.1/lib/rr/method_dispatches/method_dispatch.rb:41:in `call_implementation'
/home/aho/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/rr-1.2.1/lib/rr/method_dispatches/method_dispatch.rb:30:in `call_original_method'
test_proxy.rb:4:in `write'
Error: test: write(TestKlass): ArgumentError: wrong number of arguments (given 2, expected 1)
=============================================================================================================================================

Finished in 0.001129911 seconds.
---------------------------------------------------------------------------------------------------------------------------------------------
1 tests, 0 assertions, 0 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
0% passed
---------------------------------------------------------------------------------------------------------------------------------------------
885.03 tests/s, 0.00 assertions/s

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions