[rspec-users] [bug] mock expectations fail when a subclass is instantiated
dchelimsky at gmail.com
Sat Aug 16 18:51:44 EDT 2008
On Sat, Aug 16, 2008 at 4:25 PM, Chuck Remes <cremes.devlist at mac.com> wrote:
> I took a look at the web site but did not see any issue/bug tracker
I forwarded this there: http://rspec.lighthouseapp.com/projects/5645/tickets/496
Will respond in that ticket.
> reporting this here.
> The mock framework fails to differentiate between messages sent to a parent
> class versus a subclass, so some of my expectations fail when I assert some
> expectation on a parent. Here's code to show it:
> cremes$ cat c.rb
> class A
> class B < A
> class C
> def foo
> a = A.new
> b = B.new
> cremes$ cat c_spec.rb
> require 'rubygems'
> require 'spec'
> require 'c'
> describe C, "mock" do
> it "should incorrectly pick up message sent to parent class as a subclass
> err" do
> c = C.new
> cremes$ spec c_spec.rb
> NoMethodError in 'C mock should incorrectly pick up message sent to parent
> class as a subclass err'
> undefined method `new' for B:Class
> ./c.rb:10:in `foo'
> Finished in 0.006664 seconds
> 1 example, 1 failure
> If I capture the exception thrown here, it is at lib/spec/mocks/proxy.rb
> line 75. I'd provide a patch if I knew how to fix it! :)
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users