mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
WIP replace mocks with Mocks shard
This commit is contained in:
parent
0e3f626932
commit
d74a772f43
40 changed files with 110 additions and 2348 deletions
|
@ -1,14 +1,14 @@
|
|||
require "../spec_helper"
|
||||
|
||||
Spectator.describe Spectator::Matchers::ReceiveMatcher do
|
||||
let(stub) { Spectator::NullStub.new(:test_method) }
|
||||
let(stub) { Mocks::NilStub.new(:test_method) }
|
||||
subject(matcher) { described_class.new(stub) }
|
||||
|
||||
let(args) { Spectator::Arguments.capture(1, "test", Symbol, foo: /bar/) }
|
||||
let(args_stub) { Spectator::NullStub.new(:test_method, args) }
|
||||
let(args) { Mocks::ArgumentsPattern.build(1, "test", Symbol, foo: /bar/) }
|
||||
let(args_stub) { Mocks::NilStub.new(:test_method, args) }
|
||||
let(args_matcher) { described_class.new(args_stub) }
|
||||
|
||||
let(no_args_stub) { Spectator::NullStub.new(:test_method, Spectator::Arguments.none) }
|
||||
let(no_args_stub) { Mocks::NilStub.new(:test_method, Mocks::ArgumentsPattern.none) }
|
||||
let(no_args_matcher) { described_class.new(no_args_stub) }
|
||||
|
||||
double(:dbl, test_method: nil, irrelevant: nil)
|
||||
|
@ -296,7 +296,7 @@ Spectator.describe Spectator::Matchers::ReceiveMatcher do
|
|||
end
|
||||
|
||||
it "has the expected call listed" do
|
||||
is_expected.to contain({:expected, "Not #{stub.message}"})
|
||||
is_expected.to contain({:expected, "Not #{stub}"})
|
||||
end
|
||||
|
||||
it "has the list of called methods" do
|
||||
|
|
|
@ -48,13 +48,13 @@ Spectator.describe "Allow stub DSL" do
|
|||
context "with a class double" do
|
||||
double(:dbl) do
|
||||
# Ensure the original is never called.
|
||||
abstract_stub def self.foo : Nil
|
||||
stub abstract def self.foo : Nil
|
||||
end
|
||||
|
||||
abstract_stub def self.foo(arg) : Nil
|
||||
stub abstract def self.foo(arg) : Nil
|
||||
end
|
||||
|
||||
abstract_stub def self.value : Int32
|
||||
stub abstract def self.value : Int32
|
||||
42
|
||||
end
|
||||
end
|
||||
|
|
|
@ -337,7 +337,7 @@ Spectator.describe "Double DSL", :smoke do
|
|||
|
||||
describe "class doubles" do
|
||||
double(:class_double) do
|
||||
abstract_stub def self.abstract_method
|
||||
stub abstract def self.abstract_method
|
||||
:abstract
|
||||
end
|
||||
|
||||
|
|
|
@ -57,13 +57,13 @@ Spectator.describe "Deferred stub expectation DSL" do
|
|||
context "with a class double" do
|
||||
double(:dbl) do
|
||||
# Ensure the original is never called.
|
||||
abstract_stub def self.foo : Nil
|
||||
stub abstract def self.foo : Nil
|
||||
end
|
||||
|
||||
abstract_stub def self.foo(arg) : Nil
|
||||
stub abstract def self.foo(arg) : Nil
|
||||
end
|
||||
|
||||
abstract_stub def self.value : Int32
|
||||
stub abstract def self.value : Int32
|
||||
42
|
||||
end
|
||||
end
|
||||
|
|
|
@ -253,7 +253,7 @@ Spectator.describe "Mock DSL", :smoke do
|
|||
end
|
||||
|
||||
# NOTE: Defining the stub here with a return type restriction, but no default implementation.
|
||||
abstract_stub abstract def method4 : Symbol
|
||||
stub abstract def method4 : Symbol
|
||||
|
||||
# NOTE: Abstract methods that yield must have yield functionality defined in the method.
|
||||
# This requires that yielding methods have a default implementation.
|
||||
|
@ -268,10 +268,10 @@ Spectator.describe "Mock DSL", :smoke do
|
|||
end
|
||||
|
||||
# NOTE: Defining the stub here with a return type restriction, but no default implementation.
|
||||
abstract_stub abstract def method7(arg, *args, kwarg, **kwargs) : CapturedArguments
|
||||
stub abstract def method7(arg, *args, kwarg, **kwargs) : CapturedArguments
|
||||
|
||||
# NOTE: Another quirk where a default implementation must be provided because `&` is dropped.
|
||||
abstract_stub abstract def method8(arg, *args, kwarg, **kwargs, &) : CapturedArguments
|
||||
stub abstract def method8(arg, *args, kwarg, **kwargs, &) : CapturedArguments
|
||||
end
|
||||
|
||||
subject(fake) { mock(AbstractClass) }
|
||||
|
@ -373,10 +373,10 @@ Spectator.describe "Mock DSL", :smoke do
|
|||
mock(AbstractClass) do
|
||||
# NOTE: Abstract methods without a type restriction on the return value
|
||||
# must be implemented with a type restriction.
|
||||
abstract_stub abstract def method1 : String
|
||||
stub abstract def method1 : String
|
||||
|
||||
# NOTE: Defining the stub here with a return type restriction, but no default implementation.
|
||||
abstract_stub abstract def method4 : Symbol
|
||||
stub abstract def method4 : Symbol
|
||||
|
||||
# NOTE: Abstract methods that yield must have yield functionality defined in the method.
|
||||
# This requires that yielding methods have a default implementation.
|
||||
|
@ -449,7 +449,7 @@ Spectator.describe "Mock DSL", :smoke do
|
|||
end
|
||||
|
||||
# NOTE: Defining the stub here with a return type restriction, but no default implementation.
|
||||
abstract_stub abstract def method4 : Symbol
|
||||
stub abstract def method4 : Symbol
|
||||
|
||||
# NOTE: Abstract methods that yield must have yield functionality defined in the method.
|
||||
# This requires that yielding methods have a default implementation.
|
||||
|
@ -464,10 +464,10 @@ Spectator.describe "Mock DSL", :smoke do
|
|||
end
|
||||
|
||||
# NOTE: Defining the stub here with a return type restriction, but no default implementation.
|
||||
abstract_stub abstract def method7(arg, *args, kwarg, **kwargs) : CapturedArguments
|
||||
stub abstract def method7(arg, *args, kwarg, **kwargs) : CapturedArguments
|
||||
|
||||
# NOTE: Another quirk where a default implementation must be provided because `&` is dropped.
|
||||
abstract_stub abstract def method8(arg, *args, kwarg, **kwargs, &) : CapturedArguments
|
||||
stub abstract def method8(arg, *args, kwarg, **kwargs, &) : CapturedArguments
|
||||
end
|
||||
|
||||
subject(fake) { mock(AbstractStruct) }
|
||||
|
@ -569,10 +569,10 @@ Spectator.describe "Mock DSL", :smoke do
|
|||
mock(AbstractStruct) do
|
||||
# NOTE: Abstract methods without a type restriction on the return value
|
||||
# must be implemented with a type restriction.
|
||||
abstract_stub abstract def method1 : String
|
||||
stub abstract def method1 : String
|
||||
|
||||
# NOTE: Defining the stub here with a return type restriction, but no default implementation.
|
||||
abstract_stub abstract def method4 : Symbol
|
||||
stub abstract def method4 : Symbol
|
||||
|
||||
# NOTE: Abstract methods that yield must have yield functionality defined in the method.
|
||||
# This requires that yielding methods have a default implementation.
|
||||
|
@ -994,7 +994,7 @@ Spectator.describe "Mock DSL", :smoke do
|
|||
end
|
||||
|
||||
mock(Dummy) do
|
||||
abstract_stub def self.abstract_method
|
||||
stub abstract def self.abstract_method
|
||||
:abstract
|
||||
end
|
||||
|
||||
|
@ -1055,7 +1055,7 @@ Spectator.describe "Mock DSL", :smoke do
|
|||
end
|
||||
|
||||
mock(Dummy) do
|
||||
abstract_stub def self.abstract_method
|
||||
stub abstract def self.abstract_method
|
||||
:abstract
|
||||
end
|
||||
|
||||
|
|
|
@ -74,7 +74,7 @@ Spectator.describe Spectator::Double do
|
|||
|
||||
context "with abstract stubs and return type annotations" do
|
||||
Spectator::Double.define(TestDouble) do
|
||||
abstract_stub abstract def foo(value) : String
|
||||
stub abstract def foo(value) : String
|
||||
end
|
||||
|
||||
let(arguments) { Spectator::Arguments.capture(/foo/) }
|
||||
|
@ -98,8 +98,8 @@ Spectator.describe Spectator::Double do
|
|||
|
||||
context "with nillable return type annotations" do
|
||||
Spectator::Double.define(TestDouble) do
|
||||
abstract_stub abstract def foo : String?
|
||||
abstract_stub abstract def bar : Nil
|
||||
stub abstract def foo : String?
|
||||
stub abstract def bar : Nil
|
||||
end
|
||||
|
||||
let(foo_stub) { Spectator::ValueStub.new(:foo, nil).as(Spectator::Stub) }
|
||||
|
@ -116,7 +116,7 @@ Spectator.describe Spectator::Double do
|
|||
|
||||
context "with a method that uses NoReturn" do
|
||||
Spectator::Double.define(NoReturnDouble) do
|
||||
abstract_stub abstract def oops : NoReturn
|
||||
stub abstract def oops : NoReturn
|
||||
end
|
||||
|
||||
subject(dbl) { NoReturnDouble.new }
|
||||
|
@ -233,8 +233,8 @@ Spectator.describe Spectator::Double do
|
|||
|
||||
context "without common object methods" do
|
||||
Spectator::Double.define(TestDouble) do
|
||||
abstract_stub abstract def foo(value) : String
|
||||
abstract_stub abstract def foo(value, & : -> _) : String
|
||||
stub abstract def foo(value) : String
|
||||
stub abstract def foo(value, & : -> _) : String
|
||||
end
|
||||
|
||||
let(stub) { Spectator::ValueStub.new(:foo, "bar", arguments).as(Spectator::Stub) }
|
||||
|
|
|
@ -50,7 +50,7 @@ Spectator.describe Spectator::NullDouble do
|
|||
|
||||
context "with abstract stubs and return type annotations" do
|
||||
Spectator::NullDouble.define(TestDouble2) do
|
||||
abstract_stub abstract def foo(value) : String
|
||||
stub abstract def foo(value) : String
|
||||
end
|
||||
|
||||
let(arguments) { Spectator::Arguments.capture(/foo/) }
|
||||
|
@ -74,8 +74,8 @@ Spectator.describe Spectator::NullDouble do
|
|||
|
||||
context "with nillable return type annotations" do
|
||||
Spectator::NullDouble.define(TestDouble) do
|
||||
abstract_stub abstract def foo : String?
|
||||
abstract_stub abstract def bar : Nil
|
||||
stub abstract def foo : String?
|
||||
stub abstract def bar : Nil
|
||||
end
|
||||
|
||||
let(foo_stub) { Spectator::ValueStub.new(:foo, nil).as(Spectator::Stub) }
|
||||
|
@ -92,7 +92,7 @@ Spectator.describe Spectator::NullDouble do
|
|||
|
||||
context "with a method that uses NoReturn" do
|
||||
Spectator::NullDouble.define(NoReturnDouble) do
|
||||
abstract_stub abstract def oops : NoReturn
|
||||
stub abstract def oops : NoReturn
|
||||
end
|
||||
|
||||
subject(dbl) { NoReturnDouble.new }
|
||||
|
@ -202,8 +202,8 @@ Spectator.describe Spectator::NullDouble do
|
|||
|
||||
context "without common object methods" do
|
||||
Spectator::NullDouble.define(TestDouble) do
|
||||
abstract_stub abstract def foo(value) : String
|
||||
abstract_stub abstract def foo(value, & : -> _) : String
|
||||
stub abstract def foo(value) : String
|
||||
stub abstract def foo(value, & : -> _) : String
|
||||
end
|
||||
|
||||
let(stub) { Spectator::ValueStub.new(:foo, "bar", arguments).as(Spectator::Stub) }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue