Add no_args support for stubs

Fixes https://github.com/icy-arctic-fox/spectator/issues/28
This commit is contained in:
Michael Miller 2021-07-02 18:43:39 -06:00
parent 92f758084d
commit e3f6fb3c7c
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD
4 changed files with 48 additions and 0 deletions

View file

@ -170,4 +170,8 @@ module Spectator::DSL
{% end %}
%stubs
end
def no_args
::Spectator::Mocks::NoArguments.new
end
end

View file

@ -0,0 +1,21 @@
require "./arguments"
module Spectator::Mocks
class NoArguments < Arguments
def args
Tuple.new
end
def opts
NamedTuple.new
end
def ===(other : Arguments) : Bool
other.args.empty? && other.opts.empty?
end
def ===(other) : Bool
false
end
end
end