Skip to content

Add spec for Enumerator::Lazy#chunk - #506

Merged
eregon merged 1 commit into
ruby:masterfrom
joshgelbard:enumerator-lazy-chunk
Dec 28, 2017
Merged

eregon merged 1 commit into
ruby:masterfrom
joshgelbard:enumerator-lazy-chunk

Conversation

@joshgelbard

Copy link
Copy Markdown
Contributor

Mostly copied and slightly altered the existing specs that seemed most similar. Will do #chunk_while and company along the same lines unless this is wrong.

@joshgelbard

Copy link
Copy Markdown
Contributor Author

It looks like the existing specs for Enumerator::Lazy all test for almost exactly the same things. Since I will otherwise shortly be adding four more files of that, I'm thinking of pulling out the shared tests into a shared examples group and using them with should_behave_like.

@eregon

eregon commented Oct 15, 2017 •

Copy link
Copy Markdown
Member

When possible, shared specs are indeed better so there is less duplication and examples added for one method also means added to others methods.
Could you try to make and use a shared spec for those?

The chunk_spec.rb files can then define a few @ivar like @yieldsmixed in the before :each block with the specific receiver class/method, and those can be used in the shared spec.
Or alternatively, they could just define a "factory" Proc for creating a Enumerable/Enumerator::Lazy with the given elements, and the shared spec can use that.

@eregon

eregon commented Oct 28, 2017

Copy link
Copy Markdown
Member

@joshgelbard Did you have the occasion to look at sharing those specs?
If not, I'd rather merge this spec and then we can improve based on what's in master.

@eregon

eregon commented Dec 28, 2017

Copy link
Copy Markdown
Member

Let's merge this, thank you for the new spec!

@eregon
eregon merged commit be17ce5 into ruby:master Dec 28, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants