Prevent comparing range arguments with non-compatible types in stubs

Addresses https://github.com/icy-arctic-fox/spectator/issues/48
This commit is contained in:
Michael Miller 2022-12-18 11:35:43 -07:00
parent f55c60e01f
commit e6584c9f04
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF
4 changed files with 37 additions and 24 deletions

View file

@ -38,6 +38,10 @@ Spectator.describe "GitHub Issue #48" do
block.call(thing)
block
end
def range(r : Range)
r
end
end
mock Test, make_nilable: nil
@ -122,4 +126,10 @@ Spectator.describe "GitHub Issue #48" do
allow(fake).to receive(:capture).and_return(proc)
expect(fake.capture(5) { 5 }).to be(proc)
end
it "handles range comparisons against non-comparable types" do
range = 1..10
allow(fake).to receive(:range).and_return(range)
expect(fake.range(1..3)).to eq(range)
end
end