mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Support injecting mock functionality into modules
Add mock registry for a single module.
This commit is contained in:
parent
a3c55dfa47
commit
8f80b10fc1
3 changed files with 64 additions and 1 deletions
|
@ -205,6 +205,25 @@ Spectator.describe "Mocks Docs" do
|
|||
runnable = mock(Runnable2, command: "echo foo")
|
||||
expect(runnable.run_one).to eq("Running echo foo")
|
||||
end
|
||||
|
||||
context "Injecting Mocks" do
|
||||
module MyFileUtils
|
||||
def self.rm_rf(path)
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
inject_mock MyFileUtils do
|
||||
stub def self.rm_rf(path)
|
||||
"Simulating deletion of #{path}"
|
||||
false
|
||||
end
|
||||
end
|
||||
|
||||
specify do
|
||||
expect(MyFileUtils.rm_rf("/")).to be_false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "Injecting Mocks" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue