mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Various fixes
This commit is contained in:
parent
bbaa8816b8
commit
1199379833
3 changed files with 40 additions and 32 deletions
|
@ -184,36 +184,36 @@ Spectator.describe Spectator::Double do
|
|||
pp = PrettyPrint.new(io)
|
||||
hasher = Crystal::Hasher.new
|
||||
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)
|
||||
expect { dbl.=~(42) }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.class }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.dup }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.hash(hasher) }.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?(1, 2, 3) }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.inspect }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.itself }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.not_nil! }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.pretty_inspect }.to raise_error(Spectator::UnexpectedMessage)
|
||||
# expect { dbl.pretty_inspect(io) }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.pretty_print(pp) }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.tap { nil } }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.to_json }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.to_json(io) }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.to_pretty_json }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.to_pretty_json(io) }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.to_s }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.to_s(io) }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.to_yaml }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.to_yaml(io) }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.try { nil } }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.object_id }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.same?(dbl) }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect { dbl.same?(nil) }.to raise_error(Spectator::UnexpectedMessage)
|
||||
expect(dbl.!=(42)).to be_true
|
||||
expect(dbl.!~(42)).to be_true
|
||||
expect(dbl.==(42)).to be_false
|
||||
expect(dbl.===(42)).to be_false
|
||||
expect(dbl.=~(42)).to be_false
|
||||
expect(dbl.class).to be_nil
|
||||
expect(dbl.dup).to eq(dbl)
|
||||
expect(dbl.hash(hasher)).to eq(42)
|
||||
expect(dbl.hash).to eq(42)
|
||||
expect(dbl.in?([42])).to be_false
|
||||
expect(dbl.in?(1, 2, 3)).to be_false
|
||||
expect(dbl.inspect).to eq("foo")
|
||||
expect(dbl.itself).to be(dbl)
|
||||
expect(dbl.not_nil!).to be(dbl)
|
||||
expect(dbl.pretty_inspect).to eq("foo")
|
||||
# expect(dbl.pretty_inspect(io)).to be_nil
|
||||
expect(dbl.pretty_print(pp)).to be_nil
|
||||
expect(dbl.tap { nil }).to be(dbl)
|
||||
expect(dbl.to_json).to eq("foo")
|
||||
expect(dbl.to_json(io)).to be_nil
|
||||
expect(dbl.to_pretty_json).to eq("foo")
|
||||
expect(dbl.to_pretty_json(io)).to be_nil
|
||||
expect(dbl.to_s).to eq("foo")
|
||||
expect(dbl.to_s(io)).to be_nil
|
||||
expect(dbl.to_yaml).to eq("foo")
|
||||
expect(dbl.to_yaml(io)).to be_nil
|
||||
expect(dbl.try { nil }).to be_nil
|
||||
expect(dbl.object_id).to eq(42)
|
||||
expect(dbl.same?(dbl)).to be_true
|
||||
expect(dbl.same?(nil)).to be_false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ Spectator.describe Spectator::NullDouble do
|
|||
end
|
||||
|
||||
it "raises on non-matching arguments" do
|
||||
expect { dbl.foo("bar") }.to raise_error(TypeCastError, /String/)
|
||||
expect { dbl.foo("bar") }.to raise_error(Spectator::UnexpectedMessage, /foo/)
|
||||
end
|
||||
|
||||
it "raises on non-matching stub" do
|
||||
|
|
|
@ -4,7 +4,6 @@ require "./stub"
|
|||
require "./stubbable"
|
||||
require "./stubbed_name"
|
||||
require "./unexpected_message"
|
||||
require "./value_stub"
|
||||
|
||||
module Spectator
|
||||
# Stands in for an object for testing that a SUT calls expected methods.
|
||||
|
@ -77,6 +76,15 @@ module Spectator
|
|||
def initialize(@stubs : Array(Stub) = [] of Stub)
|
||||
end
|
||||
|
||||
# Compares against another object.
|
||||
#
|
||||
# Always returns false.
|
||||
# This method exists as a workaround to provide an alternative to `Object#same?`,
|
||||
# which only accepts a `Reference` or `Nil`.
|
||||
def same?(other) : Bool
|
||||
false
|
||||
end
|
||||
|
||||
# Defines a stub to change the behavior of a method in this double.
|
||||
#
|
||||
# NOTE: Defining a stub for a method not defined in the double's type has no effect.
|
||||
|
|
Loading…
Reference in a new issue