[rspec-devel] [ rspec-Bugs-8077 ] Stubbing :new on Active base class causes sub class :new to return base type

noreply at rubyforge.org noreply at rubyforge.org
Tue Jan 23 07:45:27 EST 2007


Bugs item #8077, was opened at 2007-01-23 07:14
You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=8077&group_id=797

Category: mock module
Group: None
>Status: Closed
>Resolution: Rejected
Priority: 3
Submitted By: Scott Fleckenstein (nullstyle)
>Assigned to: David Chelimsky (dchelimsky)
Summary: Stubbing :new on Active base class causes sub class :new to return base type

Initial Comment:
Quite a subject sentence, huh? Before I get to my description, attached to this report is a stand-alone ruby file that will reproduce the bug I am seeing, given you have the sqlite3 gem installed.

Also note that this is surfacing when using Rspec 0.7.5.1 along with the corresponding Rspec on Rails plugin; Ruby 1.8.5 on OS X 10.4.latest

Basically, I have a situation where I am employing single-table-inheritance with my active record classes.  I have a set of specs that stub! :new on the base class.  After the stubbing specs are run, any calls to subclass.new return an instance of the base class.

Example:

Foo < ActiveRecord::Base ; end
Bar < Foo ; end

p Bar.new.class  # => Bar
Foo.stub!(:new)
Foo.__reset_mock
p Bar.new.class  # => Foo

I tried working up a patch, but I don't have enough skill with the rspec codebase to get it done.

Thanks,
Scott Fleckenstein



----------------------------------------------------------------------

>Comment By: David Chelimsky (dchelimsky)
Date: 2007-01-23 12:45

Message:
Very nice bug report. Thank  you. However, it is a duplicate of [#7611]

http://rubyforge.org/tracker/index.php?func=detail&aid=7611&group_id=797&atid=3149

Apologies for the "Rejected" resolution. We are not offered an "Is Duplication" option.

Cheers,
David



----------------------------------------------------------------------

You can respond by visiting: 
http://rubyforge.org/tracker/?func=detail&atid=3149&aid=8077&group_id=797


More information about the rspec-devel mailing list