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 6f2adbe commit 1a7e923
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/rspec/mocks/any_instance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,23 @@ def private_method; :private_method_return_value; end
allow_any_instance_of(sub_class).to receive(:foo).and_call_original
expect(sub_class.new.foo).to eq("bar")
end

it "allows an expectation to be set on a subclass when an allowance already exists on a superclass" do
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

context "when the class has a prepended module", :if => Support::RubyFeatures.module_prepends_supported? do
Expand Down

0 comments on commit 1a7e923

Please sign in to comment.