diff --git a/spec/spectator/mocks/null_stub_spec.cr b/spec/spectator/mocks/null_stub_spec.cr index 5f64f96..021c0c5 100644 --- a/spec/spectator/mocks/null_stub_spec.cr +++ b/spec/spectator/mocks/null_stub_spec.cr @@ -2,12 +2,17 @@ require "../../spec_helper" Spectator.describe Spectator::NullStub do 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 expect(stub.method).to eq(:foo) end + it "stores the location" do + expect(stub.location).to eq(location) + end + it "returns nil" do expect(stub.call(method_call)).to be_nil end @@ -15,7 +20,8 @@ Spectator.describe Spectator::NullStub do context Spectator::StubModifiers do describe "#and_return(value)" do 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) } it "produces a stub that returns a value" do @@ -29,6 +35,10 @@ Spectator.describe Spectator::NullStub do 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 diff --git a/spec/spectator/mocks/value_stub_spec.cr b/spec/spectator/mocks/value_stub_spec.cr index f9eeb53..3b8489c 100644 --- a/spec/spectator/mocks/value_stub_spec.cr +++ b/spec/spectator/mocks/value_stub_spec.cr @@ -2,12 +2,17 @@ require "../../spec_helper" Spectator.describe Spectator::ValueStub do 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 expect(stub.method).to eq(:foo) end + it "stores the location" do + expect(stub.location).to eq(location) + end + it "stores the return value" do expect(stub.call(method_call)).to eq(42) end