Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stubs for mocked types should use the spec scope #17

Open
icy-arctic-fox opened this issue Nov 7, 2020 · 0 comments
Open

Stubs for mocked types should use the spec scope #17

icy-arctic-fox opened this issue Nov 7, 2020 · 0 comments
Assignees
Milestone

Comments

@icy-arctic-fox
Copy link
Owner

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

@icy-arctic-fox icy-arctic-fox self-assigned this Nov 7, 2020
@icy-arctic-fox icy-arctic-fox added this to the v0.11 milestone Mar 17, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant