mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Support for canned responses in double creation
This commit is contained in:
parent
73e3f8fd66
commit
9c161a07ff
1 changed files with 6 additions and 2 deletions
|
@ -1,9 +1,13 @@
|
||||||
require "../mocks"
|
require "../mocks"
|
||||||
|
|
||||||
module Spectator::DSL
|
module Spectator::DSL
|
||||||
macro double(name, &block)
|
macro double(name, **stubs, &block)
|
||||||
{% if block.is_a?(Nop) %}
|
{% if block.is_a?(Nop) %}
|
||||||
Double{{name.id}}.new
|
Double{{name.id}}.new.tap do |%double|
|
||||||
|
{% for name, value in stubs %}
|
||||||
|
allow(%double).to receive({{name.id}}).and_return({{value}})
|
||||||
|
{% end %}
|
||||||
|
end
|
||||||
{% else %}
|
{% else %}
|
||||||
class Double{{name.id}} < ::Spectator::Mocks::Double
|
class Double{{name.id}} < ::Spectator::Mocks::Double
|
||||||
def initialize
|
def initialize
|
||||||
|
|
Loading…
Reference in a new issue