mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Use before
instead of before_each
(same for after)
This commit is contained in:
parent
4906dfae0d
commit
a6149b2671
8 changed files with 28 additions and 28 deletions
|
@ -312,7 +312,7 @@ Spectator.describe Spectator::Mock do
|
|||
let(mock) { MockThing }
|
||||
let(foo_stub) { Spectator::ValueStub.new(:foo, :override) }
|
||||
|
||||
after_each { mock._spectator_clear_stubs }
|
||||
after { mock._spectator_clear_stubs }
|
||||
|
||||
it "overrides an existing method" do
|
||||
expect { mock._spectator_define_stub(foo_stub) }.to change { mock.foo }.from(:stub).to(:override)
|
||||
|
@ -368,7 +368,7 @@ Spectator.describe Spectator::Mock do
|
|||
end
|
||||
|
||||
describe "._spectator_clear_stubs" do
|
||||
before_each { mock._spectator_define_stub(foo_stub) }
|
||||
before { mock._spectator_define_stub(foo_stub) }
|
||||
|
||||
it "removes previously defined stubs" do
|
||||
expect { mock._spectator_clear_stubs }.to change { mock.foo }.from(:override).to(:stub)
|
||||
|
@ -376,7 +376,7 @@ Spectator.describe Spectator::Mock do
|
|||
end
|
||||
|
||||
describe "._spectator_calls" do
|
||||
before_each { mock._spectator_clear_calls }
|
||||
before { mock._spectator_clear_calls }
|
||||
|
||||
# Retrieves symbolic names of methods called on a mock.
|
||||
def called_method_names(mock)
|
||||
|
@ -410,7 +410,7 @@ Spectator.describe Spectator::Mock do
|
|||
|
||||
let(mock) { MockThing.new }
|
||||
|
||||
after_each { mock._spectator_clear_stubs }
|
||||
after { mock._spectator_clear_stubs }
|
||||
|
||||
it "raises a TypeCastError when using a value-based stub" do
|
||||
stub = Spectator::ValueStub.new(:oops, nil).as(Spectator::Stub)
|
||||
|
@ -461,7 +461,7 @@ Spectator.describe Spectator::Mock do
|
|||
let(mock) { MockedClass.new }
|
||||
|
||||
# Necessary to clear stubs to prevent leakages between tests.
|
||||
after_each { mock._spectator_clear_stubs }
|
||||
after { mock._spectator_clear_stubs }
|
||||
|
||||
it "overrides responses from methods with keyword arguments" do
|
||||
expect(mock.method1).to eq(123)
|
||||
|
@ -571,8 +571,8 @@ Spectator.describe Spectator::Mock do
|
|||
let(mock) { MockedStruct.new }
|
||||
|
||||
# Necessary to clear stubs to prevent leakages between tests.
|
||||
after_each { mock._spectator_clear_stubs }
|
||||
after_each { MockedStruct._spectator_invocations.clear }
|
||||
after { mock._spectator_clear_stubs }
|
||||
after { MockedStruct._spectator_invocations.clear }
|
||||
|
||||
it "overrides responses from methods with keyword arguments" do
|
||||
expect(mock.method1).to eq(123)
|
||||
|
@ -656,7 +656,7 @@ Spectator.describe Spectator::Mock do
|
|||
let(mock) { Thing }
|
||||
let(foo_stub) { Spectator::ValueStub.new(:foo, :override) }
|
||||
|
||||
after_each { mock._spectator_clear_stubs }
|
||||
after { mock._spectator_clear_stubs }
|
||||
|
||||
it "overrides an existing method" do
|
||||
expect { mock._spectator_define_stub(foo_stub) }.to change { mock.foo }.from(:stub).to(:override)
|
||||
|
@ -712,7 +712,7 @@ Spectator.describe Spectator::Mock do
|
|||
end
|
||||
|
||||
describe "._spectator_clear_stubs" do
|
||||
before_each { mock._spectator_define_stub(foo_stub) }
|
||||
before { mock._spectator_define_stub(foo_stub) }
|
||||
|
||||
it "removes previously defined stubs" do
|
||||
expect { mock._spectator_clear_stubs }.to change { mock.foo }.from(:override).to(:stub)
|
||||
|
@ -720,7 +720,7 @@ Spectator.describe Spectator::Mock do
|
|||
end
|
||||
|
||||
describe "._spectator_calls" do
|
||||
before_each { mock._spectator_clear_calls }
|
||||
before { mock._spectator_clear_calls }
|
||||
|
||||
# Retrieves symbolic names of methods called on a mock.
|
||||
def called_method_names(mock)
|
||||
|
@ -756,7 +756,7 @@ Spectator.describe Spectator::Mock do
|
|||
|
||||
let(mock) { NoReturnThing.new }
|
||||
|
||||
after_each { mock._spectator_clear_stubs }
|
||||
after { mock._spectator_clear_stubs }
|
||||
|
||||
it "raises a TypeCastError when using a value-based stub" do
|
||||
stub = Spectator::ValueStub.new(:oops, nil).as(Spectator::Stub)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue