From f55c60e01fcf1559cc4420353e3f6b4a6992714b Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sat, 17 Dec 2022 21:01:22 -0700 Subject: [PATCH] Fix README spec Mocked types cannot be private. Moved to a module to prevent polluting the global namespace. --- spec/docs/readme_spec.cr | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/spec/docs/readme_spec.cr b/spec/docs/readme_spec.cr index 6024906..2ed7fd5 100644 --- a/spec/docs/readme_spec.cr +++ b/spec/docs/readme_spec.cr @@ -1,26 +1,28 @@ require "../spec_helper" -private abstract class Interface - abstract def invoke(thing) : String -end +module Readme + abstract class Interface + abstract def invoke(thing) : String + end -# Type being tested. -private class Driver - def do_something(interface : Interface, thing) - interface.invoke(thing) + # Type being tested. + class Driver + def do_something(interface : Interface, thing) + interface.invoke(thing) + end end end -Spectator.describe Driver do +Spectator.describe Readme::Driver do # Define a mock for Interface. - mock Interface + mock Readme::Interface # Define a double that the interface will use. double(:my_double, foo: 42) it "does a thing" do # Create an instance of the mock interface. - interface = mock(Interface) + interface = mock(Readme::Interface) # Indicate that `#invoke` should return "test" when called. allow(interface).to receive(:invoke).and_return("test")