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
Labels
Milestone

Comments

@myronmarston
Copy link

➜  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
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
Copy link
Author

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 as completed in adf874c Apr 9, 2015
enebo added a commit that referenced this issue Apr 9, 2015
@enebo
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
Copy link
Author

Thanks for the prompt fix, @enebo!

@doozr
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
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
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
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.
JonRowe pushed a commit to rspec/rspec-support that referenced this issue Jun 10, 2019
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
Labels
Projects
None yet
Development

No branches or pull requests

4 participants