mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Fix README spec
Mocked types cannot be private. Moved to a module to prevent polluting the global namespace.
This commit is contained in:
parent
4b68b8e3de
commit
f55c60e01f
1 changed files with 12 additions and 10 deletions
|
@ -1,26 +1,28 @@
|
||||||
require "../spec_helper"
|
require "../spec_helper"
|
||||||
|
|
||||||
private abstract class Interface
|
module Readme
|
||||||
|
abstract class Interface
|
||||||
abstract def invoke(thing) : String
|
abstract def invoke(thing) : String
|
||||||
end
|
end
|
||||||
|
|
||||||
# Type being tested.
|
# Type being tested.
|
||||||
private class Driver
|
class Driver
|
||||||
def do_something(interface : Interface, thing)
|
def do_something(interface : Interface, thing)
|
||||||
interface.invoke(thing)
|
interface.invoke(thing)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
Spectator.describe Driver do
|
Spectator.describe Readme::Driver do
|
||||||
# Define a mock for Interface.
|
# Define a mock for Interface.
|
||||||
mock Interface
|
mock Readme::Interface
|
||||||
|
|
||||||
# Define a double that the interface will use.
|
# Define a double that the interface will use.
|
||||||
double(:my_double, foo: 42)
|
double(:my_double, foo: 42)
|
||||||
|
|
||||||
it "does a thing" do
|
it "does a thing" do
|
||||||
# Create an instance of the mock interface.
|
# Create an instance of the mock interface.
|
||||||
interface = mock(Interface)
|
interface = mock(Readme::Interface)
|
||||||
# Indicate that `#invoke` should return "test" when called.
|
# Indicate that `#invoke` should return "test" when called.
|
||||||
allow(interface).to receive(:invoke).and_return("test")
|
allow(interface).to receive(:invoke).and_return("test")
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue