mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add other comparison matchers to DSL
This commit is contained in:
parent
2758ba7643
commit
0c284b6713
1 changed files with 60 additions and 0 deletions
|
@ -15,6 +15,18 @@ module Spectator::DSL
|
||||||
::Spectator::Matchers::EqualityMatcher.new({{expected.stringify}}, {{expected}})
|
::Spectator::Matchers::EqualityMatcher.new({{expected.stringify}}, {{expected}})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Indicates that some value should not equal another.
|
||||||
|
# The `!=` operator is used for this check.
|
||||||
|
# The value passed to this method is the unexpected value.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# ```
|
||||||
|
# expect(1 + 2).to ne(5)
|
||||||
|
# ```
|
||||||
|
macro ne(expected)
|
||||||
|
::Spectator::Matchers::InequalityMatcher.new({{expected.stringify}}, {{expected}})
|
||||||
|
end
|
||||||
|
|
||||||
# Indicates that some value when compared to another satisfies an operator.
|
# Indicates that some value when compared to another satisfies an operator.
|
||||||
# An operator should follow, such as: `<`, `<=`, `>`, or `>=`.
|
# An operator should follow, such as: `<`, `<=`, `>`, or `>=`.
|
||||||
#
|
#
|
||||||
|
@ -58,6 +70,54 @@ module Spectator::DSL
|
||||||
::Spectator::Matchers::TypeMatcher({{expected}}).new
|
::Spectator::Matchers::TypeMatcher({{expected}}).new
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Indicates that some value should be less than another.
|
||||||
|
# The `<` operator is used for this check.
|
||||||
|
# The value passed to this method is the value expected to be larger.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# ```
|
||||||
|
# expect(3 - 1).to be_lt(3)
|
||||||
|
# ```
|
||||||
|
macro be_lt(expected)
|
||||||
|
::Spectator::Matchers::LessThanMatcher.new({{expected.stringify}}, {{expected}})
|
||||||
|
end
|
||||||
|
|
||||||
|
# Indicates that some value should be less than or equal to another.
|
||||||
|
# The `<=` operator is used for this check.
|
||||||
|
# The value passed to this method is the value expected to be larger or equal.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# ```
|
||||||
|
# expect(3 - 1).to be_le(3)
|
||||||
|
# ```
|
||||||
|
macro be_le(expected)
|
||||||
|
::Spectator::Matchers::LessThanEqualMatcher.new({{expected.stringify}}, {{expected}})
|
||||||
|
end
|
||||||
|
|
||||||
|
# Indicates that some value should be greater than another.
|
||||||
|
# The `>` operator is used for this check.
|
||||||
|
# The value passed to this method is the value expected to be smaller.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# ```
|
||||||
|
# expect(3 + 1).to be_gt(3)
|
||||||
|
# ```
|
||||||
|
macro be_gt(expected)
|
||||||
|
::Spectator::Matchers::GreaterThanMatcher.new({{expected.stringify}}, {{expected}})
|
||||||
|
end
|
||||||
|
|
||||||
|
# Indicates that some value should be greater than or equal to another.
|
||||||
|
# The `>=` operator is used for this check.
|
||||||
|
# The value passed to this method is the value expected to be smaller or equal.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# ```
|
||||||
|
# expect(3 + 1).to be_ge(3)
|
||||||
|
# ```
|
||||||
|
macro be_ge(expected)
|
||||||
|
::Spectator::Matchers::GreaterThanEqualMatcher.new({{expected.stringify}}, {{expected}})
|
||||||
|
end
|
||||||
|
|
||||||
# Indicates that some value should match another.
|
# Indicates that some value should match another.
|
||||||
# The `=~` operator is used for this check.
|
# The `=~` operator is used for this check.
|
||||||
# Typically a regular expression is used,
|
# Typically a regular expression is used,
|
||||||
|
|
Loading…
Reference in a new issue