Sorry I don't understand what you are either asking or saying.

> If an object dynamically responds to a message via #method_missing, *but does not indicate this via #respond_to?*, then this matcher will give you false results.

Correct. If an object is doing this, it has incorrectly implemented method_missing.

On 4/07/2014 7:27 pm, Arup Rakshit wrote:
Hi,

In the relish doc  :-

https://www.relishapp.com/rspec/rspec-expectations/v/3-0/docs/built-in-matchers/respond-to-matcher

Note that this matcher relies entirely upon #respond_to?. If an object
dynamically responds to a message via #method_missing, *but does not indicate
this via #respond_to?*, then this matcher will give you false results.

What does the *..* line mean ?

The below test simply passes :-

#!/usr/bin/env ruby

class Foo
   def method_missing(name,*args,&block)
     self.class.send(:define_method, name) do
       "#{name} has been defined dynamically"
     end
   end
end

rspec :-

require_relative "../test.rb"

describe Foo do
   before { subject.foo }

   it "defines #foo dynamically" do
     expect(subject).to respond_to(:foo)
   end
end

I am not able to connect the line I marked with *..* with this example.... :(


--
You received this message because you are subscribed to the Google Groups 
"rspec" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rspec/53B778F3.6070608%40xaviershay.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to