spectator
spectator copied to clipboard
Stubs for mocked types should use the spec scope
Currently, the scope of method stubs with a default scope is executed within the mocked type. This should be changed to execute in the scope of the spec.
struct MyStruct
def stubbed_method
answer
end
def answer
1
end
end
Spectator.describe MyStruct do
let(answer) { 42 }
mock MyStruct do
stub stubbed_method { answer }
end
it "returns the answer" do
expect(subject.stubbed_method).to eq(42) # Fails, reports 1
end
end
Issue originally raised in #14