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

and_iterates/and_yields should handle enumerator chains #12

Open
npepinpe opened this issue Jun 15, 2017 · 1 comment
Open

and_iterates/and_yields should handle enumerator chains #12

npepinpe opened this issue Jun 15, 2017 · 1 comment

Comments

@npepinpe
Copy link

With version 2.3.5, using the following:

flexmock(collection).should_receive(:each_batch).and_iterates(%w[a b c], %[d e f])
collection.each_batch.each_with_index do |batch, index|
   ...
end

Produces the following exception:

FlexMock::MockError: No Block given to mock with 'and_yield' expectation

Intuitively, I would have expected the above code to simply work. I'm not entirely sure how feasible it would be, and there are work-arounds, but it would be a nice to have.

@doudou
Copy link
Owner

doudou commented Jun 16, 2017

Let's forget about the implementation (which is probably somehow feasible), and discuss the feature first.

I see the point, especially given that I'm also prone to providing all my #each methods with the "return an enumerator if no block is given" pattern.

However, this is not a feature of the language... The 'yield-to-enumerator' conversion relies on code within the method, and I would assume that existing users of and_yields/and_iterates actually rely on this check. I would prefer a syntax that allows for both usage patterns. I'll need to think about it ... Suggestions ?

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