mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Allow be
matcher to be used on structs
This commit is contained in:
parent
3d08949c94
commit
60f1c3091b
3 changed files with 11 additions and 5 deletions
|
@ -115,11 +115,11 @@ Spectator.describe "Explicit Subject" do
|
|||
end
|
||||
|
||||
it "the subject and named helpers return the same object" do
|
||||
expect(global_count).to eq(subject) # TODO: `be` matcher with value (no same? method).
|
||||
expect(global_count).to be(subject)
|
||||
end
|
||||
|
||||
it "is set to the block return value (i.e. the global $count)" do
|
||||
expect(global_count).to eq(@@count) # TODO: `be` matcher with value (no same? method).
|
||||
expect(global_count).to be(@@count)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -8,7 +8,7 @@ Spectator.describe "Arbitrary helper methods" do
|
|||
end
|
||||
|
||||
it "has access to methods define in its group" do
|
||||
expect(help).to eq(:available) # TODO: `be` matcher with value (no same? method).
|
||||
expect(help).to be(:available)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -21,7 +21,7 @@ Spectator.describe "Arbitrary helper methods" do
|
|||
|
||||
describe "in a nested group" do
|
||||
it "has access to methods defined in its parent group" do
|
||||
expect(help).to eq(:available) # TODO: `be` matcher with value (no same? method).
|
||||
expect(help).to be(:available)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -13,7 +13,13 @@ module Spectator::Matchers
|
|||
|
||||
# Checks whether the matcher is satisifed with the expression given to it.
|
||||
private def match?(actual : TestExpression(T)) : Bool forall T
|
||||
expected.value.same?(actual.value)
|
||||
value = expected.value
|
||||
if value.responds_to?(:same)
|
||||
value.same?(actual.value)
|
||||
else
|
||||
# Value type (struct) comparison.
|
||||
actual.value.class == value.class && actual.value == value
|
||||
end
|
||||
end
|
||||
|
||||
# Message displayed when the matcher isn't satisifed.
|
||||
|
|
Loading…
Reference in a new issue