On Dec 6, 2007 4:08 PM, Scott Taylor <[EMAIL PROTECTED]> wrote: > > On Dec 6, 2007, at 4:41 PM, David Chelimsky wrote: > > > On Dec 6, 2007 3:37 PM, Scott Taylor > > <[EMAIL PROTECTED]> wrote: > >> > >> > >> What is the appropriate way to stub out (and put an expectation on > >> Object#__send__), without getting warnings from the Rspec mock > >> library? > > > > Come on Scott - you know better than that :) > > > > Error please? > > Not an error, just a warning. And I should have written my > description better. Basically, I wanted to make sure that my library > didn't call send, but instead __send__. I tried something like this: > > before :each do > @caller = Object.new > @caller.stub!(:send).and_raise > @caller.stub!(:__send__) > > end > > it "should be able to send the message with __send__" do > @caller.should_not_receive(:send) > @caller.should_receive(:__send__) > > @attributes.to_new_class_instance({}, @caller) > end > > > The @caller object is a sort of mock object. I would have used a > real mock object, except that stubbing send on a mock object didn't > seem to do anything. > > The warning was this: > > ./usr/local/lib/ruby/gems/1.8/gems/rspec-1.0.8/lib/spec/mocks/ > proxy.rb:99: warning: redefining `__send__' may cause serious problem
I LOVE that it says "may cause serious problem" - not "problems" Anyhow - I'm not sure what we can do about that. RSpec's stubs work by redefining existing methods. Ruby doesn't want you to do that with __send__. For the moment, there's no way around it, but I'm not even sure what we could change in RSpec to make it work. Any ideas? > > Just wondering about what you would recommend for this. Let me know > if you need more context. > > > Scott > > > > > _______________________________________________ > rspec-users mailing list > rspec-users@rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users > _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users