mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Workaround absolute path requirement for mock injection
This commit is contained in:
parent
ac3b322900
commit
14d8c046f0
2 changed files with 7 additions and 6 deletions
|
@ -404,7 +404,7 @@ Spectator.describe Spectator::Mock do
|
|||
|
||||
describe "#inject" do
|
||||
context "with a class" do
|
||||
class MockedClass
|
||||
class ::MockedClass
|
||||
getter _spectator_invocations = [] of Symbol
|
||||
|
||||
getter method1 do
|
||||
|
@ -427,7 +427,7 @@ Spectator.describe Spectator::Mock do
|
|||
end
|
||||
end
|
||||
|
||||
Spectator::Mock.inject(:class, MockedClass, :mock_name, method1: 123) do
|
||||
Spectator::Mock.inject(:class, ::MockedClass, :mock_name, method1: 123) do
|
||||
stub def method2
|
||||
:stubbed
|
||||
end
|
||||
|
@ -511,7 +511,7 @@ Spectator.describe Spectator::Mock do
|
|||
end
|
||||
|
||||
context "with a struct" do
|
||||
struct MockedStruct
|
||||
struct ::MockedStruct
|
||||
# Using a class variable instead of an instance variable to prevent mutability problems with stub lookup.
|
||||
class_getter _spectator_invocations = [] of Symbol
|
||||
|
||||
|
@ -537,7 +537,7 @@ Spectator.describe Spectator::Mock do
|
|||
end
|
||||
end
|
||||
|
||||
Spectator::Mock.inject(:struct, MockedStruct, :mock_name, method1: 123) do
|
||||
Spectator::Mock.inject(:struct, ::MockedStruct, :mock_name, method1: 123) do
|
||||
stub def method2
|
||||
:stubbed
|
||||
end
|
||||
|
@ -608,7 +608,7 @@ Spectator.describe Spectator::Mock do
|
|||
end
|
||||
|
||||
context "class method stubs" do
|
||||
class Thing
|
||||
class ::Thing
|
||||
def self.foo
|
||||
:original
|
||||
end
|
||||
|
@ -622,7 +622,7 @@ Spectator.describe Spectator::Mock do
|
|||
end
|
||||
end
|
||||
|
||||
Spectator::Mock.inject(:class, Thing) do
|
||||
Spectator::Mock.inject(:class, ::Thing) do
|
||||
stub def self.foo
|
||||
:stub
|
||||
end
|
||||
|
|
|
@ -96,6 +96,7 @@ module Spectator
|
|||
# The original method functionality will still be accessible, but pass through mock code first.
|
||||
# *base* is the keyword for the type being defined - class or struct.
|
||||
# *type_name* is the name of the type to inject mock functionality into.
|
||||
# This _must_ be full, resolvable path to the type.
|
||||
# An optional *name* of the mock can be provided.
|
||||
# Any key-value pairs provided with *value_methods* are used as initial stubs for the mocked type.
|
||||
#
|
||||
|
|
Loading…
Reference in a new issue