Disallow stubs for undefined methods in null double

Any method_missing invocation should return self.
This commit is contained in:
Michael Miller 2022-07-14 13:37:09 -06:00
parent 7dd77a2096
commit 827b69483b
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF
2 changed files with 4 additions and 27 deletions

View file

@ -216,12 +216,12 @@ Spectator.describe Spectator::NullDouble do
expect(dbl.foo("foobar")).to eq("bar")
end
it "raises self when constraint unsatisfied" do
it "raises when constraint unsatisfied" do
expect { dbl.foo("baz") }.to raise_error(Spectator::UnexpectedMessage, /foo/)
end
it "raises self when argument count doesn't match" do
expect { dbl.foo }.to raise_error(Spectator::UnexpectedMessage, /foo/)
it "returns self when argument count doesn't match" do
expect(dbl.foo).to be(dbl)
end
it "ignores the block argument if not in the constraint" do
@ -406,15 +406,6 @@ Spectator.describe Spectator::NullDouble do
it "removes previously defined stubs" do
expect { dbl._spectator_clear_stubs }.to change { dbl.foo }.from(5).to(42)
end
it "defaults to returning itself for methods with no implementation" do
stub = Spectator::ValueStub.new(:baz, :xyz)
dbl._spectator_define_stub(stub)
expect(dbl.baz).to eq(:xyz)
dbl._spectator_clear_stubs
expect(dbl.baz).to be(dbl)
end
end
describe "#_spectator_calls" do