mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Test stub location
This commit is contained in:
parent
873b1abcae
commit
be1c698836
2 changed files with 18 additions and 3 deletions
|
@ -2,12 +2,17 @@ require "../../spec_helper"
|
||||||
|
|
||||||
Spectator.describe Spectator::NullStub do
|
Spectator.describe Spectator::NullStub do
|
||||||
let(method_call) { Spectator::MethodCall.capture(:foo) }
|
let(method_call) { Spectator::MethodCall.capture(:foo) }
|
||||||
subject(stub) { described_class.new(:foo) }
|
let(location) { Spectator::Location.new(__FILE__, __LINE__) }
|
||||||
|
subject(stub) { described_class.new(:foo, location: location) }
|
||||||
|
|
||||||
it "stores the method name" do
|
it "stores the method name" do
|
||||||
expect(stub.method).to eq(:foo)
|
expect(stub.method).to eq(:foo)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "stores the location" do
|
||||||
|
expect(stub.location).to eq(location)
|
||||||
|
end
|
||||||
|
|
||||||
it "returns nil" do
|
it "returns nil" do
|
||||||
expect(stub.call(method_call)).to be_nil
|
expect(stub.call(method_call)).to be_nil
|
||||||
end
|
end
|
||||||
|
@ -15,7 +20,8 @@ Spectator.describe Spectator::NullStub do
|
||||||
context Spectator::StubModifiers do
|
context Spectator::StubModifiers do
|
||||||
describe "#and_return(value)" do
|
describe "#and_return(value)" do
|
||||||
let(arguments) { Spectator::Arguments.capture(/foo/) }
|
let(arguments) { Spectator::Arguments.capture(/foo/) }
|
||||||
let(original) { Spectator::NullStub.new(:foo, arguments) }
|
let(location) { Spectator::Location.new(__FILE__, __LINE__) }
|
||||||
|
let(original) { Spectator::NullStub.new(:foo, arguments, location) }
|
||||||
subject(stub) { original.and_return(42) }
|
subject(stub) { original.and_return(42) }
|
||||||
|
|
||||||
it "produces a stub that returns a value" do
|
it "produces a stub that returns a value" do
|
||||||
|
@ -29,6 +35,10 @@ Spectator.describe Spectator::NullStub do
|
||||||
it "retains the arguments constraint" do
|
it "retains the arguments constraint" do
|
||||||
expect(stub.constraint).to eq(arguments)
|
expect(stub.constraint).to eq(arguments)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "retains the location" do
|
||||||
|
expect(stub.location).to eq(location)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -2,12 +2,17 @@ require "../../spec_helper"
|
||||||
|
|
||||||
Spectator.describe Spectator::ValueStub do
|
Spectator.describe Spectator::ValueStub do
|
||||||
let(method_call) { Spectator::MethodCall.capture(:foo) }
|
let(method_call) { Spectator::MethodCall.capture(:foo) }
|
||||||
subject(stub) { Spectator::ValueStub.new(:foo, 42) }
|
let(location) { Spectator::Location.new(__FILE__, __LINE__) }
|
||||||
|
subject(stub) { described_class.new(:foo, 42, location: location) }
|
||||||
|
|
||||||
it "stores the method name" do
|
it "stores the method name" do
|
||||||
expect(stub.method).to eq(:foo)
|
expect(stub.method).to eq(:foo)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "stores the location" do
|
||||||
|
expect(stub.location).to eq(location)
|
||||||
|
end
|
||||||
|
|
||||||
it "stores the return value" do
|
it "stores the return value" do
|
||||||
expect(stub.call(method_call)).to eq(42)
|
expect(stub.call(method_call)).to eq(42)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue