mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add mock registry prep
This commit is contained in:
parent
74eb4fc11a
commit
e9f7e65ac9
3 changed files with 15 additions and 4 deletions
|
@ -3,5 +3,11 @@ require "./mocks/*"
|
|||
module Spectator
|
||||
# Functionality for mocking existing types.
|
||||
module Mocks
|
||||
def self.run(context : TestContext)
|
||||
Registry.prepare(context)
|
||||
yield
|
||||
ensure
|
||||
Registry.reset
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,6 +11,10 @@ module Spectator::Mocks
|
|||
|
||||
@@entries = {} of Key => Entry
|
||||
|
||||
def prepare(context : TestContext) : Nil
|
||||
# TODO
|
||||
end
|
||||
|
||||
def reset : Nil
|
||||
@@entries.clear
|
||||
end
|
||||
|
|
|
@ -7,10 +7,11 @@ module Spectator
|
|||
# Runs the example, hooks, and captures the result
|
||||
# and translates to a usable result.
|
||||
def run_impl : Result
|
||||
result = capture_result
|
||||
expectations = Harness.current.expectations
|
||||
Mocks::Registry.reset
|
||||
translate_result(result, expectations)
|
||||
Mocks.run(group.context) do
|
||||
result = capture_result
|
||||
expectations = Harness.current.expectations
|
||||
translate_result(result, expectations)
|
||||
end
|
||||
end
|
||||
|
||||
# Runs all hooks and the example code.
|
||||
|
|
Loading…
Reference in a new issue