From: twalpole@...
Date: 2017-01-05T20:59:26+00:00
Subject: [ruby-core:78982] [Ruby trunk Bug#13107] def_delegators causes random errors in MRI 2.4.0

Issue #13107 has been updated by Thomas Walpole.


Forgot to add the location reported for the error

# /home/travis/.rvm/rubies/ruby-2.4.0/lib/ruby/2.4.0/forwardable.rb:228:in `last_response'

----------------------------------------
Bug #13107: def_delegators causes random errors in MRI 2.4.0
https://bugs.ruby-lang.org/issues/13107#change-62397

* Author: Thomas Walpole
* Status: Open
* Priority: Normal
* Assignee: 
* Target version: 
* ruby -v: 
* Backport: 2.2: UNKNOWN, 2.3: UNKNOWN, 2.4: UNKNOWN
----------------------------------------
In the Capybara project we use the rack_test gem which uses def_delegators to forward last_reponse to @rack_mock_session - https://github.com/brynary/rack-test/blob/master/lib/rack/test.rb#L29

When running the Capybara test test suite calling last_reponse on a rack_test Session object will sporadically result in a TypeError from forwardable.rb

TypeError:
       wrong argument type Integer (expected Proc)

Patching around the delegator with

class Rack::Test::Session
  def last_response
    @rack_mock_session.last_response
  end
 end

stops the error from occurring, so it appears that something def_delegators is doing is causing problems.  Unfortunately I have not yet been able to establish exactly what causes the issues to produce a simple test case.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>