Fix types of arguments given to common object methods

This commit is contained in:
Michael Miller 2022-03-20 15:39:19 -06:00
parent 0fb7be6722
commit 0b6e44c227
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF
3 changed files with 17 additions and 11 deletions

View file

@ -142,6 +142,7 @@ Spectator.describe Spectator::Double do
end end
it "responds with defined messages" do it "responds with defined messages" do
hasher = Crystal::Hasher.new
aggregate_failures do aggregate_failures do
expect(dbl.!=(42)).to eq("!=") expect(dbl.!=(42)).to eq("!=")
expect(dbl.!~(42)).to eq("!~") expect(dbl.!~(42)).to eq("!~")
@ -150,9 +151,9 @@ Spectator.describe Spectator::Double do
expect(dbl.=~(42)).to eq("=~") expect(dbl.=~(42)).to eq("=~")
expect(dbl.class).to eq("class") expect(dbl.class).to eq("class")
expect(dbl.dup).to eq("dup") expect(dbl.dup).to eq("dup")
expect(dbl.hash(42)).to eq("hash") expect(dbl.hash(hasher)).to eq("hash")
expect(dbl.hash).to eq("hash") expect(dbl.hash).to eq("hash")
expect(dbl.in?(42)).to eq(true) expect(dbl.in?([42])).to eq(true)
expect(dbl.in?(1, 2, 3)).to eq(true) expect(dbl.in?(1, 2, 3)).to eq(true)
expect(dbl.inspect).to eq("inspect") expect(dbl.inspect).to eq("inspect")
expect(dbl.itself).to eq("itself") expect(dbl.itself).to eq("itself")
@ -181,6 +182,7 @@ Spectator.describe Spectator::Double do
it "raises with undefined messages" do it "raises with undefined messages" do
io = IO::Memory.new io = IO::Memory.new
pp = PrettyPrint.new(io) pp = PrettyPrint.new(io)
hasher = Crystal::Hasher.new
aggregate_failures do aggregate_failures do
expect { dbl.!=(42) }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.!=(42) }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.!~(42) }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.!~(42) }.to raise_error(Spectator::UnexpectedMessage)
@ -189,9 +191,9 @@ Spectator.describe Spectator::Double do
expect { dbl.=~(42) }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.=~(42) }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.class }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.class }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.dup }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.dup }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.hash(42) }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.hash(hasher) }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.hash }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.hash }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.in?(42) }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.in?([42]) }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.in?(1, 2, 3) }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.in?(1, 2, 3) }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.inspect }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.inspect }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.itself }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.itself }.to raise_error(Spectator::UnexpectedMessage)

View file

@ -86,6 +86,7 @@ Spectator.describe Spectator::LazyDouble do
end end
it "responds with defined messages" do it "responds with defined messages" do
hasher = Crystal::Hasher.new
aggregate_failures do aggregate_failures do
expect(dbl.!=(42)).to eq("!=") expect(dbl.!=(42)).to eq("!=")
expect(dbl.!~(42)).to eq("!~") expect(dbl.!~(42)).to eq("!~")
@ -94,9 +95,9 @@ Spectator.describe Spectator::LazyDouble do
expect(dbl.=~(42)).to eq("=~") expect(dbl.=~(42)).to eq("=~")
expect(dbl.class).to eq("class") expect(dbl.class).to eq("class")
expect(dbl.dup).to eq("dup") expect(dbl.dup).to eq("dup")
expect(dbl.hash(42)).to eq("hash") expect(dbl.hash(hasher)).to eq("hash")
expect(dbl.hash).to eq("hash") expect(dbl.hash).to eq("hash")
expect(dbl.in?(42)).to eq(true) expect(dbl.in?([42])).to eq(true)
expect(dbl.in?(1, 2, 3)).to eq(true) expect(dbl.in?(1, 2, 3)).to eq(true)
expect(dbl.inspect).to eq("inspect") expect(dbl.inspect).to eq("inspect")
expect(dbl.itself).to eq("itself") expect(dbl.itself).to eq("itself")
@ -125,6 +126,7 @@ Spectator.describe Spectator::LazyDouble do
it "raises with undefined messages" do it "raises with undefined messages" do
io = IO::Memory.new io = IO::Memory.new
pp = PrettyPrint.new(io) pp = PrettyPrint.new(io)
hasher = Crystal::Hasher.new
aggregate_failures do aggregate_failures do
expect { dbl.!=(42) }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.!=(42) }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.!~(42) }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.!~(42) }.to raise_error(Spectator::UnexpectedMessage)
@ -133,9 +135,9 @@ Spectator.describe Spectator::LazyDouble do
expect { dbl.=~(42) }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.=~(42) }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.class }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.class }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.dup }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.dup }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.hash(42) }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.hash(hasher) }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.hash }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.hash }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.in?(42) }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.in?([42]) }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.in?(1, 2, 3) }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.in?(1, 2, 3) }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.inspect }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.inspect }.to raise_error(Spectator::UnexpectedMessage)
expect { dbl.itself }.to raise_error(Spectator::UnexpectedMessage) expect { dbl.itself }.to raise_error(Spectator::UnexpectedMessage)

View file

@ -124,6 +124,7 @@ Spectator.describe Spectator::NullDouble do
end end
it "responds with defined messages" do it "responds with defined messages" do
hasher = Crystal::Hasher.new
aggregate_failures do aggregate_failures do
expect(dbl.!=(42)).to eq("!=") expect(dbl.!=(42)).to eq("!=")
expect(dbl.!~(42)).to eq("!~") expect(dbl.!~(42)).to eq("!~")
@ -132,9 +133,9 @@ Spectator.describe Spectator::NullDouble do
expect(dbl.=~(42)).to eq("=~") expect(dbl.=~(42)).to eq("=~")
expect(dbl.class).to eq("class") expect(dbl.class).to eq("class")
expect(dbl.dup).to eq("dup") expect(dbl.dup).to eq("dup")
expect(dbl.hash(42)).to eq("hash") expect(dbl.hash(hasher)).to eq("hash")
expect(dbl.hash).to eq("hash") expect(dbl.hash).to eq("hash")
expect(dbl.in?(42)).to eq(true) expect(dbl.in?([42])).to eq(true)
expect(dbl.in?(1, 2, 3)).to eq(true) expect(dbl.in?(1, 2, 3)).to eq(true)
expect(dbl.inspect).to eq("inspect") expect(dbl.inspect).to eq("inspect")
expect(dbl.itself).to eq("itself") expect(dbl.itself).to eq("itself")
@ -161,6 +162,7 @@ Spectator.describe Spectator::NullDouble do
subject(dbl) { EmptyDouble.new } subject(dbl) { EmptyDouble.new }
it "returns self with undefined messages" do it "returns self with undefined messages" do
hasher = Crystal::Hasher.new
aggregate_failures do aggregate_failures do
# Methods that would cause type cast errors are omitted from this list. # Methods that would cause type cast errors are omitted from this list.
expect_null_double(dbl, dbl.!=(42)) expect_null_double(dbl, dbl.!=(42))
@ -170,7 +172,7 @@ Spectator.describe Spectator::NullDouble do
expect_null_double(dbl, dbl.=~(42)) expect_null_double(dbl, dbl.=~(42))
expect_null_double(dbl, dbl.class) expect_null_double(dbl, dbl.class)
expect_null_double(dbl, dbl.dup) expect_null_double(dbl, dbl.dup)
expect_null_double(dbl, dbl.hash(42)) expect_null_double(dbl, dbl.hash(hasher))
expect_null_double(dbl, dbl.hash) expect_null_double(dbl, dbl.hash)
expect_null_double(dbl, dbl.itself) expect_null_double(dbl, dbl.itself)
expect_null_double(dbl, dbl.not_nil!) expect_null_double(dbl, dbl.not_nil!)