mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add documentation to ExampleConditions
This commit is contained in:
parent
db89a99562
commit
ec9416285b
1 changed files with 13 additions and 0 deletions
|
@ -1,5 +1,13 @@
|
||||||
module Spectator
|
module Spectator
|
||||||
|
# Collection of checks that run before and after tests.
|
||||||
|
# The pre-conditions can be used to verify
|
||||||
|
# that the SUT is in an expected state prior to testing.
|
||||||
|
# The post-conditions can be used to verify
|
||||||
|
# that the SUT is in an expected state after tests have finished.
|
||||||
|
# Each check is just a `Proc` (code block) that runs when invoked.
|
||||||
class ExampleConditions
|
class ExampleConditions
|
||||||
|
# Creates an empty set of conditions.
|
||||||
|
# This will effectively run nothing extra while running a test.
|
||||||
def self.empty
|
def self.empty
|
||||||
new(
|
new(
|
||||||
[] of ->,
|
[] of ->,
|
||||||
|
@ -7,16 +15,21 @@ module Spectator
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Creates a new set of conditions.
|
||||||
def initialize(
|
def initialize(
|
||||||
@pre_conditions : Array(->),
|
@pre_conditions : Array(->),
|
||||||
@post_conditions : Array(->)
|
@post_conditions : Array(->)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Runs all pre-condition checks.
|
||||||
|
# These should be run before every test.
|
||||||
def run_pre_conditions
|
def run_pre_conditions
|
||||||
@pre_conditions.each &.call
|
@pre_conditions.each &.call
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Runs all post-condition checks.
|
||||||
|
# These should be run after every test.
|
||||||
def run_post_conditions
|
def run_post_conditions
|
||||||
@post_conditions.each &.call
|
@post_conditions.each &.call
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue