Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnboundMethod#parameters for an assignment method wrongly returns blank array #2816

Closed
myronmarston opened this Issue Apr 9, 2015 · 5 comments

Comments

Projects
None yet
4 participants
@myronmarston
Copy link

myronmarston commented Apr 9, 2015

➜  rspec-mocks git:(master) ✗ chruby 2.1
➜  rspec-mocks git:(master) ✗ ruby -v -e 'puts Class.new { attr_accessor :foo }.instance_method(:foo=).parameters.inspect'
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-darwin12.0]
[[:req]]
➜  rspec-mocks git:(master) ✗ chruby jruby
➜  rspec-mocks git:(master) ✗ ruby -v -e 'puts Class.new { attr_accessor :foo }.instance_method(:foo=).parameters.inspect'
jruby 1.7.8 (1.9.3p392) 2013-11-14 0ce429e on Java HotSpot(TM) 64-Bit Server VM 1.6.0_65-b14-462-11M4609 [darwin-x86_64]
[]

rspec-mocks relies upon parameters for verifying doubles to ensure the method signature of the real object supports the provided arguments, and it's not working properly for assignment methods on JRuby due to this bug (see rspec/rspec-mocks#919).

@nirvdrum

This comment has been minimized.

Copy link
Contributor

nirvdrum commented Apr 9, 2015

I don't have much to add to this, but wanted to note that it's still a problem in 1.7.19.

@myronmarston

This comment has been minimized.

Copy link
Author

myronmarston commented Apr 9, 2015

It also looks like it's not a problem with manually defined def foo=:

➜  rspec-core git:(master) ✗ ruby -v -e 'puts Class.new { def foo=(v); @foo = v; end }.instance_method(:foo=).parameters.inspect'
jruby 1.7.8 (1.9.3p392) 2013-11-14 0ce429e on Java HotSpot(TM) 64-Bit Server VM 1.6.0_65-b14-462-11M4609 [darwin-x86_64]
[[:req, :v]]

So apparently it's only a problem with attr_accessor and attr_writer-generated methods.

@enebo enebo added this to the JRuby 1.7.20 milestone Apr 9, 2015

@enebo enebo added the core label Apr 9, 2015

@enebo enebo closed this in adf874c Apr 9, 2015

enebo added a commit that referenced this issue Apr 9, 2015

@enebo

This comment has been minimized.

Copy link
Member

enebo commented Apr 9, 2015

I fixed thereported problem but I noticed this uncovered a class of potential methods where we are not properly reporting back parameter data. I opened up #2817 to track that. Tests should follow with that issue as well.

@myronmarston

This comment has been minimized.

Copy link
Author

myronmarston commented Apr 9, 2015

Thanks for the prompt fix, @enebo!

@doozr

This comment has been minimized.

Copy link

doozr commented Apr 9, 2015

Excellent news, thanks @enebo

myronmarston added a commit to rspec/rspec-support that referenced this issue Jul 20, 2015

Work around JRuby `Method#parameters` bug.
See jruby/jruby#2816 and rspec/rspec-mocks#919 for
a discussion of the bug. This is affecting us now that
I’m trying to enable partial double verification for
rspec-core (rspec/rspec-core#2032) so I thought it worth
addressing.

myronmarston added a commit to rspec/rspec-support that referenced this issue Jul 20, 2015

Work around JRuby `Method#parameters` bug.
See jruby/jruby#2816 and rspec/rspec-mocks#919 for
a discussion of the bug. This is affecting us now that
I’m trying to enable partial double verification for
rspec-core (rspec/rspec-core#2032) so I thought it worth
addressing.

myronmarston added a commit to rspec/rspec-support that referenced this issue Jul 21, 2015

Work around JRuby `Method#parameters` bug.
See jruby/jruby#2816 and rspec/rspec-mocks#919 for
a discussion of the bug. This is affecting us now that
I’m trying to enable partial double verification for
rspec-core (rspec/rspec-core#2032) so I thought it worth
addressing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.