Skip to content

Commit

Permalink
Add a failing spec which demonstrates #1077
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Phippen committed Apr 20, 2016
1 parent 4648b31 commit afe492e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions spec/rspec/mocks/any_instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,20 @@ def private_method; :private_method_return_value; end
end

it "allows an expectation to be set on a subclass when an allowance already exists on a superclass" do
allow_any_instance_of(super_class).to receive(:foo)
expect_any_instance(sub_class).to receive(:foo).with(:bar)
sub_class.new.foo(:bar)
class A
def foo
true
end
end

class B < A
def foo
super
end
end
allow_any_instance_of(A).to receive(:foo)
expect_any_instance_of(B).to receive(:foo).with(:bar)
B.new.foo(:bar)
end
end

Expand Down

0 comments on commit afe492e

Please sign in to comment.