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

Deprecate RequestStub#then #1037

Open
Nakilon opened this issue Oct 6, 2023 · 2 comments
Open

Deprecate RequestStub#then #1037

Nakilon opened this issue Oct 6, 2023 · 2 comments

Comments

@Nakilon
Copy link

Nakilon commented Oct 6, 2023

I believe it's useless

def then
self
end

and it conflicts with the new Ruby method #then. I've just got caught on it here:

p( stub_request(mtd, url).then do |_|
  with_any_query ? _.with(query: hash_including({})) : _
end ).to_return ...
@Nakilon
Copy link
Author

Nakilon commented Oct 6, 2023

Workaround:

WebMock::RequestStub.remove_method :then

@bblimke
Copy link
Owner

bblimke commented Feb 6, 2024

@Nakilon thank you for reporting.

The inclusion of then was intended to enhance readability by providing syntactic sugar for stub declaration, as demonstrated in this example. However, I acknowledge that its presence in Object leads to confusion now.

To address this, I am considering the addition of and_then, accompanied by a deprecation notice for then, followed by the release of a new minor version 3.x. Subsequently, we can proceed with the removal of then in WebMock 4.0.x.

I would appreciate your thoughts on this approach.

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

2 participants