mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Store expected value as array
Fixes issue where contain_exactly matcher would try to append to a tuple (which isn't allowed).
This commit is contained in:
parent
c99401f7d5
commit
476e54bb2b
3 changed files with 9 additions and 9 deletions
|
@ -548,7 +548,7 @@ module Spectator
|
||||||
# expect([1, 2, 3]).to contain_exactly(3, 2, 1)
|
# expect([1, 2, 3]).to contain_exactly(3, 2, 1)
|
||||||
# ```
|
# ```
|
||||||
macro contain_exactly(*expected)
|
macro contain_exactly(*expected)
|
||||||
%test_value = ::Spectator::TestValue.new({{expected}}, {{expected.stringify}})
|
%test_value = ::Spectator::TestValue.new(({{expected}}).to_a, {{expected.stringify}})
|
||||||
::Spectator::Matchers::ArrayMatcher.new(%test_value)
|
::Spectator::Matchers::ArrayMatcher.new(%test_value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -560,7 +560,7 @@ module Spectator
|
||||||
# expect([1, 2, 3]).to match_array([3, 2, 1])
|
# expect([1, 2, 3]).to match_array([3, 2, 1])
|
||||||
# ```
|
# ```
|
||||||
macro match_array(expected)
|
macro match_array(expected)
|
||||||
%test_value = ::Spectator::TestValue.new({{expected}}, {{expected.stringify}})
|
%test_value = ::Spectator::TestValue.new(({{expected}}).to_a, {{expected.stringify}})
|
||||||
::Spectator::Matchers::ArrayMatcher.new(%test_value)
|
::Spectator::Matchers::ArrayMatcher.new(%test_value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -582,7 +582,7 @@ module Spectator
|
||||||
# expect([1, 2, 3]).to have_size_of(%i[x y z])
|
# expect([1, 2, 3]).to have_size_of(%i[x y z])
|
||||||
# ```
|
# ```
|
||||||
macro have_size_of(expected)
|
macro have_size_of(expected)
|
||||||
%test_value = ::Spectator::TestValue.new(({{expected}}), {{expected.stringify}})
|
%test_value = ::Spectator::TestValue.new({{expected}}, {{expected.stringify}})
|
||||||
::Spectator::Matchers::SizeOfMatcher.new(%test_value)
|
::Spectator::Matchers::SizeOfMatcher.new(%test_value)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ module Spectator::Matchers
|
||||||
private getter expected
|
private getter expected
|
||||||
|
|
||||||
# Creates the matcher with an expected value.
|
# Creates the matcher with an expected value.
|
||||||
def initialize(@expected : TestValue(ExpectedType))
|
def initialize(@expected : TestValue(Array(ExpectedType)))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
|
@ -27,7 +27,7 @@ module Spectator::Matchers
|
||||||
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:to_a)
|
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:to_a)
|
||||||
|
|
||||||
actual_elements = actual_value.to_a
|
actual_elements = actual_value.to_a
|
||||||
expected_elements = expected.value.to_a
|
expected_elements = expected.value
|
||||||
missing, extra = compare_arrays(expected_elements, actual_elements)
|
missing, extra = compare_arrays(expected_elements, actual_elements)
|
||||||
|
|
||||||
if missing.empty? && extra.empty?
|
if missing.empty? && extra.empty?
|
||||||
|
@ -51,7 +51,7 @@ module Spectator::Matchers
|
||||||
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:to_a)
|
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:to_a)
|
||||||
|
|
||||||
actual_elements = actual_value.to_a
|
actual_elements = actual_value.to_a
|
||||||
expected_elements = expected.value.to_a
|
expected_elements = expected.value
|
||||||
missing, extra = compare_arrays(expected_elements, actual_elements)
|
missing, extra = compare_arrays(expected_elements, actual_elements)
|
||||||
|
|
||||||
if missing.empty? && extra.empty?
|
if missing.empty? && extra.empty?
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Spectator::Matchers
|
||||||
private getter expected
|
private getter expected
|
||||||
|
|
||||||
# Creates the matcher with an expected value.
|
# Creates the matcher with an expected value.
|
||||||
def initialize(@expected : TestValue(ExpectedType))
|
def initialize(@expected : TestValue(Array(ExpectedType)))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Short text about the matcher's purpose.
|
# Short text about the matcher's purpose.
|
||||||
|
@ -24,7 +24,7 @@ module Spectator::Matchers
|
||||||
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:to_a)
|
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:to_a)
|
||||||
|
|
||||||
actual_elements = actual_value.to_a
|
actual_elements = actual_value.to_a
|
||||||
expected_elements = expected.value.to_a
|
expected_elements = expected.value
|
||||||
missing, extra = array_diff(expected_elements, actual_elements)
|
missing, extra = array_diff(expected_elements, actual_elements)
|
||||||
|
|
||||||
if missing.empty? && extra.empty?
|
if missing.empty? && extra.empty?
|
||||||
|
@ -46,7 +46,7 @@ module Spectator::Matchers
|
||||||
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:to_a)
|
return unexpected(actual_value, actual.label) unless actual_value.responds_to?(:to_a)
|
||||||
|
|
||||||
actual_elements = actual_value.to_a
|
actual_elements = actual_value.to_a
|
||||||
expected_elements = expected.value.to_a
|
expected_elements = expected.value
|
||||||
missing, extra = array_diff(expected_elements, actual_elements)
|
missing, extra = array_diff(expected_elements, actual_elements)
|
||||||
|
|
||||||
if missing.empty? && extra.empty?
|
if missing.empty? && extra.empty?
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue