-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
Subscribe recorders to proxies #654
Conversation
I merged my PR but the diff here is still showing that code. Can you rebase this, @samphippen? |
Done! |
# TODO: this shouldn't be necessary to satisfy the expectation, but is. | ||
klass.new.foo(2) | ||
# # TODO: this shouldn't be necessary to satisfy the expectation, but is. | ||
# klass.new.foo(2) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just remove this like below ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imagine a universe where I am good at writing ruby. In that universe these
lines don't exist.
I'll fix it when I get back to london.
Sent from my phone please excuse my brevity.
On 7 Apr 2014, at 13:37, Jon Rowe notifications@github.com wrote:
In spec/rspec/mocks/any_instance_spec.rb:
@@ -426,8 +426,8 @@ def inspect
expect_any_instance_of(klass).to receive(:foo).with(2).and_return(2)
expect(instance.foo(2)).to eq(2)
# TODO: this shouldn't be necessary to satisfy the expectation, but is.
klass.new.foo(2)
# # TODO: this shouldn't be necessary to satisfy the expectation, but is.
# klass.new.foo(2)
Why not just remove this like below ;)
Reply to this email directly or view it on
GitHubhttps://github.com//pull/654/files#r11339854
.
This looks good to me but is currently failing due to some undocumented code: RSpec::Mocks::AnyInstance::Recorder#notify |
Gonna mark it Api private Sent from my phone please excuse my brevity. On 7 Apr 2014, at 13:46, Jon Rowe notifications@github.com wrote: This looks good to me but is currently failing due to some undocumented RSpec::Mocks::AnyInstance::Recorder#notify Reply to this email directly or view it on |
@JonRowe so you don't think the approach of doing a playback, followed by a call is quite odd here? I'm slightly worried this could have undesired side effects. Maybe @myronmarston can comment, as I said, I'm really not sure about this approach. |
I think the playback is problematic, too. Will respond with more thoughts later. Sent from my iPhone
|
@@ -22,6 +22,16 @@ def initialize(klass) | |||
@expectation_set = false | |||
end | |||
|
|||
# @private | |||
def notify(object, message, args, blk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be good to call this notify_received_message
(or something similar) rather than just notify
. notify
, on its own, is too generic, IMO -- notify of what?
Do you have a spec that demonstrates this case? That would be helpful to use as we figure out a solution. Anyhow, I definitely thinking of expectation args and all that. It sounds like none of the existing methods available off of the any instance recorder will work properly to notify of the exact message expectation (with args) w/o affecting how the object responds to the message (which playback does). So I think you need to refactor the internals of the any instance recorder to expose a method like you need. |
I'm going to take a look at this locally, and maybe push some commits to wrap this up. |
Please do! Sorry I haven't had time to close this out. Let me know if you |
OK, I made some progress and force pushed. More to come. I'm going to bed for now. |
OK, @samphippen, I think this is ready for review and merge. /cc @JonRowe @xaviershay |
@@ -121,6 +121,21 @@ def already_observing?(method_name) | |||
@observed_methods.include?(method_name) || super_class_observing?(method_name) | |||
end | |||
|
|||
# @private | |||
def notify_received_message(object, message, args, blk) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blk
is unused here. Should it be routed somewhere else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's nothing to do with blk
here (nor with object
). They are passed to this method just to provide the full details about the notified message because from the point of view of the proxy calling this, it doesn't know or care which aspects of the received message the subscriber uses.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK cool.
I left a few comments. Mostly LGTM. Also travis failed, which I'm not sure about. I'd like to give this another pass once the comments are worked through, but this is great! |
…eated previously.
This aligns with the normal `any_instance` behavior.
Longer term, maybe but in the short term now. My immediate concern driving that suggestion was the explicit passing of an unnamed |
OK. This LGTM. I think merge when green. |
So there're two issues with the build:
|
@@ -1,7 +1,13 @@ | |||
# This file was generated on 2014-03-30T13:16:22-07:00 from the rspec-dev repo. | |||
# DO NOT modify it by hand as your changes will get lost the next time it is generated. | |||
|
|||
before_install: "script/clone_all_rspec_repos" | |||
before_install: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comment above says not to change this file and I don't see an obvious commit bumping it. Is cool?
@xaviershay -- the build is failing on 1.8.7 when rspec-expectations tries to require |
seems legit |
Apart from the travis build issues, this LGTM. |
Subscribe recorders to proxies
Merged, since I got the build to pass finally. I've also got PRs out to rspec-dev, core, expectations, mocks and support to update the |
A sketch of a fix for #652
I'm not sure using
playback
and then sending the message is even sensible, what do people think?Also: there was a failing spec for me locally, but it was present before this commit. It's
rspec ./spec/rspec/mocks/partial_double_spec.rb:140 # Using a partial mock on a proxy object works properly
This is based on top of Myron's branch in: #651