mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Store location information in stub
Allows tracking where a stub was originally defined.
This commit is contained in:
parent
e61b31e47b
commit
318e4f3707
3 changed files with 9 additions and 5 deletions
|
@ -167,8 +167,8 @@ module Spectator::DSL
|
|||
# allow(dbl).to receive(:foo).and_return(42)
|
||||
# expect(dbl.foo).to eq(42)
|
||||
# ```
|
||||
macro receive(method)
|
||||
::Spectator::NullStub.new({{method.id.symbolize}})
|
||||
macro receive(method, *, _file = __FILE__, _line = __LINE__)
|
||||
::Spectator::NullStub.new({{method.id.symbolize}}, location: ::Spectator::Location.new({{_file}}, {{_line}}))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -12,8 +12,11 @@ module Spectator
|
|||
# Is nil when there's no constraint - only the method name must match.
|
||||
getter constraint : AbstractArguments?
|
||||
|
||||
# Location the stub was defined.
|
||||
getter location : Location?
|
||||
|
||||
# Creates the base of the stub.
|
||||
def initialize(@method : Symbol, @constraint : AbstractArguments? = nil)
|
||||
def initialize(@method : Symbol, @constraint : AbstractArguments? = nil, @location : Location? = nil)
|
||||
end
|
||||
|
||||
# Checks if a method call should receive the response from this stub.
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
require "../location"
|
||||
require "./arguments"
|
||||
require "./typed_stub"
|
||||
|
||||
|
@ -10,8 +11,8 @@ module Spectator
|
|||
end
|
||||
|
||||
# Creates the stub.
|
||||
def initialize(method : Symbol, @value : T, constraint : AbstractArguments? = nil)
|
||||
super(method, constraint)
|
||||
def initialize(method : Symbol, @value : T, constraint : AbstractArguments? = nil, location : Location? = nil)
|
||||
super(method, constraint, location)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue