mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Reenable pending tests
This commit is contained in:
parent
ecab2dd37e
commit
011ca37b50
1 changed files with 43 additions and 29 deletions
|
@ -1,6 +1,26 @@
|
||||||
require "../../../spec_helper"
|
require "../../../spec_helper"
|
||||||
|
|
||||||
Spectator.describe "Mock DSL", :smoke do
|
Spectator.describe "Mock DSL", :smoke do
|
||||||
|
alias CapturedArguments = Tuple(Int32, Tuple(Int32, Int32), Int32, NamedTuple(x: Int32, y: Int32, z: Int32))
|
||||||
|
|
||||||
|
let(args_proc) do
|
||||||
|
->(args : Spectator::AbstractArguments) do
|
||||||
|
{
|
||||||
|
args[0].as(Int32),
|
||||||
|
{
|
||||||
|
args[1].as(Int32),
|
||||||
|
args[2].as(Int32),
|
||||||
|
},
|
||||||
|
args[3].as(Int32),
|
||||||
|
{
|
||||||
|
x: args[:x].as(Int32),
|
||||||
|
y: args[:y].as(Int32),
|
||||||
|
z: args[:z].as(Int32),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context "with a concrete class" do
|
context "with a concrete class" do
|
||||||
class ConcreteClass
|
class ConcreteClass
|
||||||
getter _spectator_invocations = [] of Symbol
|
getter _spectator_invocations = [] of Symbol
|
||||||
|
@ -131,9 +151,9 @@ Spectator.describe "Mock DSL", :smoke do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
xit "handles arguments correctly with stubs", pending: "Need ProcStub" do
|
it "handles arguments correctly with stubs" do
|
||||||
stub1 = Spectator::ProcStub.new(:method7) { |args| args }
|
stub1 = Spectator::ProcStub.new(:method7, args_proc)
|
||||||
stub2 = Spectator::ProcStub.new(:method8) { |args| args }
|
stub2 = Spectator::ProcStub.new(:method8, args_proc)
|
||||||
fake._spectator_define_stub(stub1)
|
fake._spectator_define_stub(stub1)
|
||||||
fake._spectator_define_stub(stub2)
|
fake._spectator_define_stub(stub2)
|
||||||
args1 = fake.method7(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7)
|
args1 = fake.method7(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7)
|
||||||
|
@ -246,6 +266,12 @@ Spectator.describe "Mock DSL", :smoke do
|
||||||
stub def method6 : Symbol
|
stub def method6 : Symbol
|
||||||
yield
|
yield
|
||||||
end
|
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
|
||||||
|
|
||||||
|
# NOTE: Another quirk where a default implementation must be provided because `&` is dropped.
|
||||||
|
abstract_stub abstract def method8(arg, *args, kwarg, **kwargs, &) : CapturedArguments
|
||||||
end
|
end
|
||||||
|
|
||||||
subject(fake) { mock(AbstractClass) }
|
subject(fake) { mock(AbstractClass) }
|
||||||
|
@ -307,22 +333,13 @@ Spectator.describe "Mock DSL", :smoke do
|
||||||
expect { fake._spectator_define_stub(stub) }.to change { fake.method6 { :wrong } }.from(:kwargs).to(:override)
|
expect { fake._spectator_define_stub(stub) }.to change { fake.method6 { :wrong } }.from(:kwargs).to(:override)
|
||||||
end
|
end
|
||||||
|
|
||||||
xit "handles arguments correctly", pending: "Need ProcStub" do
|
it "handles arguments correctly with stubs" do
|
||||||
args1 = fake.method7(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7)
|
stub1 = Spectator::ProcStub.new(:method7, args_proc)
|
||||||
args2 = fake.method8(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7) { :block }
|
stub2 = Spectator::ProcStub.new(:method8, args_proc)
|
||||||
aggregate_failures do
|
|
||||||
expect(args1).to eq({1, {2, 3}, 4, {x: 5, y: 6, z: 7}})
|
|
||||||
expect(args2).to eq({1, {2, 3}, 4, {x: 5, y: 6, z: 7}})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
xit "handles arguments correctly with stubs", pending: "Need ProcStub" do
|
|
||||||
stub1 = Spectator::ProcStub.new(:method7) { |args| args }
|
|
||||||
stub2 = Spectator::ProcStub.new(:method8) { |args| args }
|
|
||||||
fake._spectator_define_stub(stub1)
|
fake._spectator_define_stub(stub1)
|
||||||
fake._spectator_define_stub(stub2)
|
fake._spectator_define_stub(stub2)
|
||||||
args1 = fake.method7(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7)
|
args1 = fake.method7(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7)
|
||||||
args2 = fake.method8(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7) { :block }
|
args2 = fake.method8(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7) # { :block }
|
||||||
aggregate_failures do
|
aggregate_failures do
|
||||||
expect(args1).to eq({1, {2, 3}, 4, {x: 5, y: 6, z: 7}})
|
expect(args1).to eq({1, {2, 3}, 4, {x: 5, y: 6, z: 7}})
|
||||||
expect(args2).to eq({1, {2, 3}, 4, {x: 5, y: 6, z: 7}})
|
expect(args2).to eq({1, {2, 3}, 4, {x: 5, y: 6, z: 7}})
|
||||||
|
@ -445,6 +462,12 @@ Spectator.describe "Mock DSL", :smoke do
|
||||||
stub def method6 : Symbol
|
stub def method6 : Symbol
|
||||||
yield
|
yield
|
||||||
end
|
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
|
||||||
|
|
||||||
|
# NOTE: Another quirk where a default implementation must be provided because `&` is dropped.
|
||||||
|
abstract_stub abstract def method8(arg, *args, kwarg, **kwargs, &) : CapturedArguments
|
||||||
end
|
end
|
||||||
|
|
||||||
subject(fake) { mock(AbstractStruct) }
|
subject(fake) { mock(AbstractStruct) }
|
||||||
|
@ -506,22 +529,13 @@ Spectator.describe "Mock DSL", :smoke do
|
||||||
expect { fake._spectator_define_stub(stub) }.to change { fake.method6 { :wrong } }.from(:kwargs).to(:override)
|
expect { fake._spectator_define_stub(stub) }.to change { fake.method6 { :wrong } }.from(:kwargs).to(:override)
|
||||||
end
|
end
|
||||||
|
|
||||||
xit "handles arguments correctly", pending: "Need ProcStub" do
|
it "handles arguments correctly with stubs" do
|
||||||
args1 = fake.method7(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7)
|
stub1 = Spectator::ProcStub.new(:method7, args_proc)
|
||||||
args2 = fake.method8(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7) { :block }
|
stub2 = Spectator::ProcStub.new(:method8, args_proc)
|
||||||
aggregate_failures do
|
|
||||||
expect(args1).to eq({1, {2, 3}, 4, {x: 5, y: 6, z: 7}})
|
|
||||||
expect(args2).to eq({1, {2, 3}, 4, {x: 5, y: 6, z: 7}})
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
xit "handles arguments correctly with stubs", pending: "Need ProcStub" do
|
|
||||||
stub1 = Spectator::ProcStub.new(:method7) { |args| args }
|
|
||||||
stub2 = Spectator::ProcStub.new(:method8) { |args| args }
|
|
||||||
fake._spectator_define_stub(stub1)
|
fake._spectator_define_stub(stub1)
|
||||||
fake._spectator_define_stub(stub2)
|
fake._spectator_define_stub(stub2)
|
||||||
args1 = fake.method7(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7)
|
args1 = fake.method7(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7)
|
||||||
args2 = fake.method8(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7) { :block }
|
args2 = fake.method8(1, 2, 3, kwarg: 4, x: 5, y: 6, z: 7) # { :block }
|
||||||
aggregate_failures do
|
aggregate_failures do
|
||||||
expect(args1).to eq({1, {2, 3}, 4, {x: 5, y: 6, z: 7}})
|
expect(args1).to eq({1, {2, 3}, 4, {x: 5, y: 6, z: 7}})
|
||||||
expect(args2).to eq({1, {2, 3}, 4, {x: 5, y: 6, z: 7}})
|
expect(args2).to eq({1, {2, 3}, 4, {x: 5, y: 6, z: 7}})
|
||||||
|
|
Loading…
Reference in a new issue