Possible bug in proxy.rb in Rspec 1.3.1

In the proxy.rb file, Rspec 1.3.1 added a stanza to the it/else stack

    elsif @target.is_a?(Class)
      @target.superclass.send(sym, *args, &block)

This just seems wrong to me and I’m pretty sure it’s causing
catastrophic errors in my build.

Consider the following example:

require ‘spec_helper’

class Foo

def self.singleton
  @singleton ||= new

# Redirect all missing class methods to the singleton instance for

backwards compatible API
def self.method_missing(name,*args,&block)

def bar


describe Foo do

it “should mock correctly” do
Foo.bar.should == 123

it “should call successfully after a mock” do
Foo.bar.should == “abc”


The first example creates a message_expectation for the Foo class
object, which defines the :bar method on Foo, since as written
Foo.respond_to?(:bar) returns false. This method send the name of the
method to the __mock_proxy which delegates it to message received.

As we move to the second example, the method defined by
define_expected_method remains, which sends the message to the
mock_proxy’s message_received methods. Since there are no expectations
defined, we drop to the suspect code. Since the @target of the proxy
is Foo, and Foo is a Class, the message tries to get sent to Foo’s
superclass, namely Object, which doesn’t define #bar and blows up.

Filed as bug #17 at http://github.com/dchelimsky/rspec/issues/17