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
|
@ -309,7 +309,7 @@ Spectator.describe Spectator::Double do
|
|||
subject(dbl) { ClassDouble }
|
||||
let(foo_stub) { Spectator::ValueStub.new(:foo, :override) }
|
||||
|
||||
after_each { dbl._spectator_clear_stubs }
|
||||
after { dbl._spectator_clear_stubs }
|
||||
|
||||
it "overrides an existing method" do
|
||||
expect { dbl._spectator_define_stub(foo_stub) }.to change { dbl.foo }.from(:stub).to(:override)
|
||||
|
@ -357,7 +357,7 @@ Spectator.describe Spectator::Double do
|
|||
end
|
||||
|
||||
describe "._spectator_clear_stubs" do
|
||||
before_each { dbl._spectator_define_stub(foo_stub) }
|
||||
before { dbl._spectator_define_stub(foo_stub) }
|
||||
|
||||
it "removes previously defined stubs" do
|
||||
expect { dbl._spectator_clear_stubs }.to change { dbl.foo }.from(:override).to(:stub)
|
||||
|
@ -365,7 +365,7 @@ Spectator.describe Spectator::Double do
|
|||
end
|
||||
|
||||
describe "._spectator_calls" do
|
||||
before_each { dbl._spectator_clear_calls }
|
||||
before { dbl._spectator_clear_calls }
|
||||
|
||||
# Retrieves symbolic names of methods called on a double.
|
||||
def called_method_names(dbl)
|
||||
|
@ -440,7 +440,7 @@ Spectator.describe Spectator::Double do
|
|||
subject(dbl) { FooBarDouble.new }
|
||||
let(stub) { Spectator::ValueStub.new(:foo, 5) }
|
||||
|
||||
before_each { dbl._spectator_define_stub(stub) }
|
||||
before { dbl._spectator_define_stub(stub) }
|
||||
|
||||
it "removes previously defined stubs" do
|
||||
expect { dbl._spectator_clear_stubs }.to change { dbl.foo }.from(5).to(42)
|
||||
|
@ -451,7 +451,7 @@ Spectator.describe Spectator::Double do
|
|||
subject(dbl) { FooBarDouble.new }
|
||||
let(stub) { Spectator::ValueStub.new(:foo, 5) }
|
||||
|
||||
before_each { dbl._spectator_define_stub(stub) }
|
||||
before { dbl._spectator_define_stub(stub) }
|
||||
|
||||
# Retrieves symbolic names of methods called on a double.
|
||||
def called_method_names(dbl)
|
||||
|
|
|
@ -246,7 +246,7 @@ Spectator.describe Spectator::LazyDouble do
|
|||
subject(dbl) { Spectator::LazyDouble.new(foo: 42, bar: "baz") }
|
||||
let(stub) { Spectator::ValueStub.new(:foo, 5) }
|
||||
|
||||
before_each { dbl._spectator_define_stub(stub) }
|
||||
before { dbl._spectator_define_stub(stub) }
|
||||
|
||||
it "removes previously defined stubs" do
|
||||
expect { dbl._spectator_clear_stubs }.to change { dbl.foo }.from(5).to(42)
|
||||
|
@ -257,7 +257,7 @@ Spectator.describe Spectator::LazyDouble do
|
|||
subject(dbl) { Spectator::LazyDouble.new(foo: 42, bar: "baz") }
|
||||
let(stub) { Spectator::ValueStub.new(:foo, 5) }
|
||||
|
||||
before_each { dbl._spectator_define_stub(stub) }
|
||||
before { dbl._spectator_define_stub(stub) }
|
||||
|
||||
# Retrieves symbolic names of methods called on a double.
|
||||
def called_method_names(dbl)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -270,7 +270,7 @@ Spectator.describe Spectator::NullDouble do
|
|||
subject(dbl) { ClassDouble }
|
||||
let(foo_stub) { Spectator::ValueStub.new(:foo, :override) }
|
||||
|
||||
after_each { dbl._spectator_clear_stubs }
|
||||
after { dbl._spectator_clear_stubs }
|
||||
|
||||
it "overrides an existing method" do
|
||||
expect { dbl._spectator_define_stub(foo_stub) }.to change { dbl.foo }.from(:stub).to(:override)
|
||||
|
@ -318,7 +318,7 @@ Spectator.describe Spectator::NullDouble do
|
|||
end
|
||||
|
||||
describe "._spectator_clear_stubs" do
|
||||
before_each { dbl._spectator_define_stub(foo_stub) }
|
||||
before { dbl._spectator_define_stub(foo_stub) }
|
||||
|
||||
it "removes previously defined stubs" do
|
||||
expect { dbl._spectator_clear_stubs }.to change { dbl.foo }.from(:override).to(:stub)
|
||||
|
@ -326,7 +326,7 @@ Spectator.describe Spectator::NullDouble do
|
|||
end
|
||||
|
||||
describe "._spectator_calls" do
|
||||
before_each { dbl._spectator_clear_calls }
|
||||
before { dbl._spectator_clear_calls }
|
||||
|
||||
# Retrieves symbolic names of methods called on a double.
|
||||
def called_method_names(dbl)
|
||||
|
@ -401,7 +401,7 @@ Spectator.describe Spectator::NullDouble do
|
|||
subject(dbl) { FooBarDouble.new }
|
||||
let(stub) { Spectator::ValueStub.new(:foo, 5) }
|
||||
|
||||
before_each { dbl._spectator_define_stub(stub) }
|
||||
before { dbl._spectator_define_stub(stub) }
|
||||
|
||||
it "removes previously defined stubs" do
|
||||
expect { dbl._spectator_clear_stubs }.to change { dbl.foo }.from(5).to(42)
|
||||
|
@ -412,7 +412,7 @@ Spectator.describe Spectator::NullDouble do
|
|||
subject(dbl) { FooBarDouble.new }
|
||||
let(stub) { Spectator::ValueStub.new(:foo, 5) }
|
||||
|
||||
before_each { dbl._spectator_define_stub(stub) }
|
||||
before { dbl._spectator_define_stub(stub) }
|
||||
|
||||
# Retrieves symbolic names of methods called on a double.
|
||||
def called_method_names(dbl)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue