mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add specialized should/should_not methods for procs
This commit is contained in:
parent
102105911c
commit
d04db7bf68
1 changed files with 14 additions and 0 deletions
|
@ -30,3 +30,17 @@ class Object
|
|||
::Spectator::Expectations::ValueExpectationPartial.new(self, __FILE__, __LINE__).to_not(matcher)
|
||||
end
|
||||
end
|
||||
|
||||
struct Proc(*T, R)
|
||||
# Extension method to create an expectation for a block of code (proc).
|
||||
# Depending on the matcher, the proc may be executed multiple times.
|
||||
def should(matcher : ::Spectator::Matchers::Matcher)
|
||||
::Spectator::Expectations::BlockExpectationPartial.new(self, __FILE__, __LINE__).to(matcher)
|
||||
end
|
||||
|
||||
# Works the same as `#should` except the condition is inverted.
|
||||
# When `#should` succeeds, this method will fail, and vice-versa.
|
||||
def should_not(matcher : ::Spectator::Matchers::Matcher)
|
||||
::Spectator::Expectations::BlockExpectationPartial.new(self, __FILE__, __LINE__).to_not(matcher)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue