Rename thing to mock

This commit is contained in:
Michael Miller 2022-05-15 13:44:45 -06:00
parent 37c6db250d
commit fdac99d122
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF

View file

@ -54,18 +54,18 @@ Spectator.describe Spectator::Mock do
end end
end end
let(thing) { MockThing.new } let(mock) { MockThing.new }
it "defines a subclass of the mocked type" do it "defines a subclass of the mocked type" do
expect(MockThing).to be_lt(Thing) expect(MockThing).to be_lt(Thing)
end end
it "overrides responses from methods with keyword arguments" do it "overrides responses from methods with keyword arguments" do
expect(thing.method1).to eq(123) expect(mock.method1).to eq(123)
end end
it "overrides responses from methods defined in the block" do it "overrides responses from methods defined in the block" do
expect(thing.method2).to eq(:stubbed) expect(mock.method2).to eq(:stubbed)
end end
it "allows methods to be stubbed" do it "allows methods to be stubbed" do
@ -74,9 +74,9 @@ Spectator.describe Spectator::Mock do
stub3 = Spectator::ValueStub.new(:method3, "stubbed") stub3 = Spectator::ValueStub.new(:method3, "stubbed")
aggregate_failures do aggregate_failures do
expect { thing._spectator_define_stub(stub1) }.to change { thing.method1 }.to(777) expect { mock._spectator_define_stub(stub1) }.to change { mock.method1 }.to(777)
expect { thing._spectator_define_stub(stub2) }.to change { thing.method2 }.to(:override) expect { mock._spectator_define_stub(stub2) }.to change { mock.method2 }.to(:override)
expect { thing._spectator_define_stub(stub3) }.to change { thing.method3 }.from("original").to("stubbed") expect { mock._spectator_define_stub(stub3) }.to change { mock.method3 }.from("original").to("stubbed")
end end
end end
end end