Right now, #stub  stubs a method even if it doesn’t exist. Is there a#responds_to ? that method? It would also be good if it raised an
Example:
 
#bar  method even if it doesn’t exist 
 
foo.stub(:bar).and_return(‘baz’)
What I’d like is something like this:
 
#stub  does 
foo.stub!(:bar).and_return(‘baz’)
Thoughts?
 
John F.http://www.linkedin.com/in/johnxf User John Feminella - Stack Overflow 
             
            
              
            
                
           
          
            
              
                johnf  
              
                  
                    July 27, 2011, 10:32pm
                   
                  2 
               
             
            
              On Jul 27, 2011, at 2:32 PM, John F. wrote:
foo.stub(:bar).and_return(‘baz’)
What I’d like is something like this:
raise ArgumentError unless foo.respond_to? :bar 
otherwise, behaves as the regular #stub  does 
foo.stub!(:bar).and_return(‘baz’)
Thoughts?
 
This has come up many times before. Please check outhttp://groups.google.com/group/rspec/browse_thread/thread/c344c898c278cd2b Undefined method stub report · Issue #15 · rspec/rspec-mocks · GitHub  to see where the
             
            
              
            
                
           
          
            
              
                johnf  
              
                  
                    July 28, 2011,  1:22am
                   
                  3 
               
             
            
              Apologies for not noticing this – I did search, but I wasn’t sure
 
John F.http://www.linkedin.com/in/johnxf User John Feminella - Stack Overflow 
             
            
              
            
                
           
          
            
              
                johnf  
              
                  
                    July 28, 2011,  2:32am
                   
                  4 
               
             
            
              On Jul 27, 2011, at 5:36 PM, John F. [email protected] 
Apologies for not noticing this – I did search, but I wasn’t sure
 
No apology necessary. Just saving myself a bunch of re-typing 
Cheers,