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

stub_service does NOT mock in combination with delegate_to #22

Closed
marian13 opened this issue Nov 20, 2022 · 1 comment
Closed

stub_service does NOT mock in combination with delegate_to #22

marian13 opened this issue Nov 20, 2022 · 1 comment
Assignees
Labels
bug Custom.

Comments

@marian13
Copy link
Owner

marian13 commented Nov 20, 2022

What is the issue?

  • stub_service does NOT mock in combination with delegate_to.

When it happens? How to reproduce it?

  • Try to uncomment the spec in cowsay_spec.rb.

    context "when `out` is NOT passed" do
      include ConvenientService::RSpec::Helpers::StubService
       
      it "defaults to `stdout`" do
        stub_service(described_class::Services::Print).to return_success
       
        expect { described_class.print(text) }
          .to delegate_to(described_class::Services::Print, :result)
          .with_arguments(text: text, out: $stdout)
      end
    end
  • Then run specs.

    task rspec -- spec/lib/convenient_service/examples/standard/cowsay_spec.rb 

Where it happens?

  • It does NOT depend on the environment. Fails for all Rubies.
  • RSpec 3.

How big is the damage from it?

  • Minimal. For now, such a combo is rare.

Why it happens?

  • allow ... and_wrap_original inside delegate_to overrides allow ... and_wrap_original inside stub_service.
  • According to the RSpec own specs and internal implementation ignoring the previous and_wrap_original is expected behavior.

What can be done to resolve it?

What is the complexity of a possible fix?

  • Looks hard. Maybe a hack is needed. More precise ETA after a deeper investigation.
@marian13 marian13 assigned marian13 and unassigned marian13 Nov 20, 2022
@marian13 marian13 added the bug Custom. label Nov 20, 2022
@marian13
Copy link
Owner Author

marian13 commented Mar 29, 2023

stub_service does NOT use RSpec mocks under the hood anymore.

Now, it is based on RSpec.current_example.

See CanHaveStubbedResults.

@marian13 marian13 self-assigned this Mar 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Custom.
Projects
None yet
Development

No branches or pull requests

1 participant