Test stub modifiers

This commit is contained in:
Michael Miller 2022-04-02 12:12:31 -06:00
parent be1c698836
commit a6fc2a4917
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF

View file

@ -17,6 +17,31 @@ Spectator.describe Spectator::ValueStub do
expect(stub.call(method_call)).to eq(42)
end
context Spectator::StubModifiers do
describe "#and_return(value)" do
let(arguments) { Spectator::Arguments.capture(/foo/) }
let(location) { Spectator::Location.new(__FILE__, __LINE__) }
let(original) { Spectator::ValueStub.new(:foo, 42, arguments, location) }
subject(stub) { original.and_return(123) }
it "produces a stub that returns a value" do
expect(stub.call(method_call)).to eq(123)
end
it "retains the method name" do
expect(stub.method).to eq(:foo)
end
it "retains the arguments constraint" do
expect(stub.constraint).to eq(arguments)
end
it "retains the location" do
expect(stub.location).to eq(location)
end
end
end
describe "#===" do
subject { stub === call }