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
instance_spy breaks when using accessors in JRuby #919
Comments
This is due to a bug in JRuby -- see the issue linked above. It worked fine on rspec-mocks 3.1 because on 3.0 and 3.1 we weren't verifying arguments for calls to null-object doubles. #829 fixed that but has the side effect of not working in this case on JRuby due to the JRuby bug.
Actually, it fails for I'm not sure what to do about this yet...if the runtime lies to us and tells us a method takes no parameters, how are we supposed to know it's lied to us? |
Hmm, looks like the |
Ah, my mistake. Yes, you are correct, it doesn't work with instance_double either. My apologies. I'll keep an eye on the JRuby bug. |
It appears that JRuby does not have this bug when you manually define the writer method (e.g. |
Looks like jruby/jruby#2816 has already been fixed! They've added it to the JRuby 1.7.20 milestone which suggests a fix will come in the next JRuby 1.7 release. Given that it's being addressed in JRuby so promptly, I don't think we should expend effort to work around it. Closing. |
Good to know! For the time being I'll leave my 1 unchecked double (it's not critical to the test anyway) but will let the team know about the manual definition workaround. Cheers. |
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.
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.
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.
I'm running a jruby-1.7.22 Rails app with the following rspec versions:
When I add this line:
I start getting errors such as this on numerous tests:
My workaround is to add this to spec/spec_helper.rb, above
This fixed all the tests except the ones that use allow/expect_any_instance_of (at least on my dev machine--it did not fix it on my CI server, probably because we're running rspec slightly differently there and may have already loaded rspec-mocks before this method is redefined). |
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.
When using JRuby 1.7.19 it is impossible to assign attributes when using instance_spy. The attributes work fine when using an instance_double as a null object. The test case is:
With this result:
The following versions are used:
It worked fine with rspec 3.1.7 and rspec-mocks 3.1.3
The text was updated successfully, but these errors were encountered: