mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Wrap expression and label in TestValue
This commit is contained in:
parent
4665d5f68d
commit
eef7e9ce3c
1 changed files with 24 additions and 24 deletions
|
@ -12,7 +12,7 @@ module Spectator::DSL
|
||||||
# expect(1 + 2).to eq(3)
|
# expect(1 + 2).to eq(3)
|
||||||
# ```
|
# ```
|
||||||
macro eq(expected)
|
macro eq(expected)
|
||||||
::Spectator::Matchers::EqualityMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::EqualityMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}})))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value should not equal another.
|
# Indicates that some value should not equal another.
|
||||||
|
@ -24,7 +24,7 @@ module Spectator::DSL
|
||||||
# expect(1 + 2).to ne(5)
|
# expect(1 + 2).to ne(5)
|
||||||
# ```
|
# ```
|
||||||
macro ne(expected)
|
macro ne(expected)
|
||||||
::Spectator::Matchers::InequalityMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::InequalityMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value when compared to another satisfies an operator.
|
# Indicates that some value when compared to another satisfies an operator.
|
||||||
|
@ -44,7 +44,7 @@ module Spectator::DSL
|
||||||
# expect("foo").to be_truthy
|
# expect("foo").to be_truthy
|
||||||
# ```
|
# ```
|
||||||
macro be
|
macro be
|
||||||
::Spectator::Matchers::TruthyMatcher.new(true)
|
::Spectator::Matchers::TruthyMatcher.new
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some object should be the same as another.
|
# Indicates that some object should be the same as another.
|
||||||
|
@ -58,7 +58,7 @@ module Spectator::DSL
|
||||||
# expect(obj.dup).to_not be(obj)
|
# expect(obj.dup).to_not be(obj)
|
||||||
# ```
|
# ```
|
||||||
macro be(expected)
|
macro be(expected)
|
||||||
::Spectator::Matchers::ReferenceMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::ReferenceMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value should be of a specified type.
|
# Indicates that some value should be of a specified type.
|
||||||
|
@ -115,7 +115,7 @@ module Spectator::DSL
|
||||||
# expect(3 - 1).to be_lt(3)
|
# expect(3 - 1).to be_lt(3)
|
||||||
# ```
|
# ```
|
||||||
macro be_lt(expected)
|
macro be_lt(expected)
|
||||||
::Spectator::Matchers::LessThanMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::LessThanMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value should be less than or equal to another.
|
# Indicates that some value should be less than or equal to another.
|
||||||
|
@ -127,7 +127,7 @@ module Spectator::DSL
|
||||||
# expect(3 - 1).to be_le(3)
|
# expect(3 - 1).to be_le(3)
|
||||||
# ```
|
# ```
|
||||||
macro be_le(expected)
|
macro be_le(expected)
|
||||||
::Spectator::Matchers::LessThanEqualMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::LessThanEqualMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value should be greater than another.
|
# Indicates that some value should be greater than another.
|
||||||
|
@ -139,7 +139,7 @@ module Spectator::DSL
|
||||||
# expect(3 + 1).to be_gt(3)
|
# expect(3 + 1).to be_gt(3)
|
||||||
# ```
|
# ```
|
||||||
macro be_gt(expected)
|
macro be_gt(expected)
|
||||||
::Spectator::Matchers::GreaterThanMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::GreaterThanMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value should be greater than or equal to another.
|
# Indicates that some value should be greater than or equal to another.
|
||||||
|
@ -151,7 +151,7 @@ module Spectator::DSL
|
||||||
# expect(3 + 1).to be_ge(3)
|
# expect(3 + 1).to be_ge(3)
|
||||||
# ```
|
# ```
|
||||||
macro be_ge(expected)
|
macro be_ge(expected)
|
||||||
::Spectator::Matchers::GreaterThanEqualMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::GreaterThanEqualMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value should match another.
|
# Indicates that some value should match another.
|
||||||
|
@ -168,7 +168,7 @@ module Spectator::DSL
|
||||||
# expect({:foo, 5}).to match({Symbol, Int32})
|
# expect({:foo, 5}).to match({Symbol, Int32})
|
||||||
# ```
|
# ```
|
||||||
macro match(expected)
|
macro match(expected)
|
||||||
::Spectator::Matchers::CaseMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::CaseMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value should be true.
|
# Indicates that some value should be true.
|
||||||
|
@ -202,7 +202,7 @@ module Spectator::DSL
|
||||||
# expect(true).to be_truthy
|
# expect(true).to be_truthy
|
||||||
# ```
|
# ```
|
||||||
macro be_truthy
|
macro be_truthy
|
||||||
::Spectator::Matchers::TruthyMatcher.new(true)
|
::Spectator::Matchers::TruthyMatcher.new
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value should be falsey.
|
# Indicates that some value should be falsey.
|
||||||
|
@ -258,7 +258,7 @@ module Spectator::DSL
|
||||||
# NOTE: Do not attempt to mix the two use cases.
|
# NOTE: Do not attempt to mix the two use cases.
|
||||||
# It likely won't work and will result in a compilation error.
|
# It likely won't work and will result in a compilation error.
|
||||||
macro be_within(expected)
|
macro be_within(expected)
|
||||||
::Spectator::Matchers::CollectionMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::CollectionMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value should be between a lower and upper-bound.
|
# Indicates that some value should be between a lower and upper-bound.
|
||||||
|
@ -279,7 +279,7 @@ module Spectator::DSL
|
||||||
# ```
|
# ```
|
||||||
macro be_between(min, max)
|
macro be_between(min, max)
|
||||||
:Spectator::Matchers::RangeMatcher.new(
|
:Spectator::Matchers::RangeMatcher.new(
|
||||||
Range.new({{min}}, {{max}}),
|
::Spectator::TestValue.new(Range.new({{min}}, {{max}})),
|
||||||
[{{min.stringify}}, {{max.stringify}}].join(" to ")
|
[{{min.stringify}}, {{max.stringify}}].join(" to ")
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
@ -339,7 +339,7 @@ module Spectator::DSL
|
||||||
# expect(%w[foo bar]).to start_with(/foo/)
|
# expect(%w[foo bar]).to start_with(/foo/)
|
||||||
# ```
|
# ```
|
||||||
macro start_with(expected)
|
macro start_with(expected)
|
||||||
::Spectator::Matchers::StartWithMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::StartWithMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value or set should end with another value.
|
# Indicates that some value or set should end with another value.
|
||||||
|
@ -361,7 +361,7 @@ module Spectator::DSL
|
||||||
# expect(%w[foo bar]).to end_with(/bar/)
|
# expect(%w[foo bar]).to end_with(/bar/)
|
||||||
# ```
|
# ```
|
||||||
macro end_with(expected)
|
macro end_with(expected)
|
||||||
::Spectator::Matchers::EndWithMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::EndWithMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value or set should contain another value.
|
# Indicates that some value or set should contain another value.
|
||||||
|
@ -384,7 +384,7 @@ module Spectator::DSL
|
||||||
# expect(%i[a b c]).to contain(:a, :b)
|
# expect(%i[a b c]).to contain(:a, :b)
|
||||||
# ```
|
# ```
|
||||||
macro contain(*expected)
|
macro contain(*expected)
|
||||||
::Spectator::Matchers::ContainMatcher.new({{expected}}, {{expected.splat.stringify}})
|
::Spectator::Matchers::ContainMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.splat.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value or set should contain another value.
|
# Indicates that some value or set should contain another value.
|
||||||
|
@ -413,7 +413,7 @@ module Spectator::DSL
|
||||||
# expect(%w[FOO BAR BAZ]).to have(/foo/i, String)
|
# expect(%w[FOO BAR BAZ]).to have(/foo/i, String)
|
||||||
# ```
|
# ```
|
||||||
macro have(*expected)
|
macro have(*expected)
|
||||||
::Spectator::Matchers::HaveMatcher.new({{expected}}, {{expected.splat.stringify}})
|
::Spectator::Matchers::HaveMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.splat.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some set, such as a `Hash`, has a given key.
|
# Indicates that some set, such as a `Hash`, has a given key.
|
||||||
|
@ -425,7 +425,7 @@ module Spectator::DSL
|
||||||
# expect({"lucky" => 7}).to have_key("lucky")
|
# expect({"lucky" => 7}).to have_key("lucky")
|
||||||
# ```
|
# ```
|
||||||
macro have_key(expected)
|
macro have_key(expected)
|
||||||
::Spectator::Matchers::HaveKeyMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::HaveKeyMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# ditto
|
# ditto
|
||||||
|
@ -442,7 +442,7 @@ module Spectator::DSL
|
||||||
# expect({"lucky" => 7}).to have_value(7)
|
# expect({"lucky" => 7}).to have_value(7)
|
||||||
# ```
|
# ```
|
||||||
macro have_value(expected)
|
macro have_value(expected)
|
||||||
::Spectator::Matchers::HaveValueMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::HaveValueMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# ditto
|
# ditto
|
||||||
|
@ -457,7 +457,7 @@ module Spectator::DSL
|
||||||
# expect([1, 2, 3]).to contain_exactly(1, 2, 3)
|
# expect([1, 2, 3]).to contain_exactly(1, 2, 3)
|
||||||
# ```
|
# ```
|
||||||
macro contain_exactly(*expected)
|
macro contain_exactly(*expected)
|
||||||
::Spectator::Matchers::ArrayMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::ArrayMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some set should contain the same values in exact order as another set.
|
# Indicates that some set should contain the same values in exact order as another set.
|
||||||
|
@ -467,7 +467,7 @@ module Spectator::DSL
|
||||||
# expect([1, 2, 3]).to match_array([1, 2, 3])
|
# expect([1, 2, 3]).to match_array([1, 2, 3])
|
||||||
# ```
|
# ```
|
||||||
macro match_array(expected)
|
macro match_array(expected)
|
||||||
::Spectator::Matchers::ArrayMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::ArrayMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some set should have a specified size.
|
# Indicates that some set should have a specified size.
|
||||||
|
@ -477,7 +477,7 @@ module Spectator::DSL
|
||||||
# expect([1, 2, 3]).to have_size(3)
|
# expect([1, 2, 3]).to have_size(3)
|
||||||
# ```
|
# ```
|
||||||
macro have_size(expected)
|
macro have_size(expected)
|
||||||
::Spectator::Matchers::SizeMatcher.new({{expected}}, {{expected.stringify}})
|
::Spectator::Matchers::SizeMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some set should have the same size (number of elements) as another set.
|
# Indicates that some set should have the same size (number of elements) as another set.
|
||||||
|
@ -487,7 +487,7 @@ module Spectator::DSL
|
||||||
# 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)
|
||||||
::Spectator::Matchers::SizeOfMatcher.new(({{expected}}), {{expected.stringify}})
|
::Spectator::Matchers::SizeOfMatcher.new(::Spectator::TestValue.new(({{expected}}), {{expected.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some value should have a set of attributes matching some conditions.
|
# Indicates that some value should have a set of attributes matching some conditions.
|
||||||
|
@ -501,7 +501,7 @@ module Spectator::DSL
|
||||||
# expect(%i[a b c]).to have_attributes(size: 1..5, first: Symbol)
|
# expect(%i[a b c]).to have_attributes(size: 1..5, first: Symbol)
|
||||||
# ```
|
# ```
|
||||||
macro have_attributes(**expected)
|
macro have_attributes(**expected)
|
||||||
::Spectator::Matchers::AttributesMatcher.new({{expected}}, {{expected.double_splat.stringify}})
|
::Spectator::Matchers::AttributesMatcher.new(::Spectator::TestValue.new({{expected}}, {{expected.double_splat.stringify}}))
|
||||||
end
|
end
|
||||||
|
|
||||||
# Indicates that some block should raise an error.
|
# Indicates that some block should raise an error.
|
||||||
|
@ -620,7 +620,7 @@ module Spectator::DSL
|
||||||
{% end %}
|
{% end %}
|
||||||
label << ')'
|
label << ')'
|
||||||
{% end %}
|
{% end %}
|
||||||
::Spectator::Matchers::{{matcher.id}}.new(descriptor, label.to_s)
|
::Spectator::Matchers::{{matcher.id}}.new(::Spectator::TestValue.new(descriptor, label.to_s))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue