Kernel#proc captures the block given to the caller.
defwith_index(offset=0)returnenum_for(:with_index)unlessblock_given?# if offset == 0, use each_with_index, which is faster because of C implementation.returneach_with_index(&proc)ifoffset==0eachdo|prime|yieldprime,offsetoffset+=1endend
and enum = Prime.each is needed before loop again.
It's better to split the test.
By the way, is PseudoPrimeGenerator#with_object covered by the tests? I don't see test_enumerator_with_object stuff.
Perhaps, for example, we can count the number of primes by modulo 4?
Found a small bug, btw, it's important to pass arguments to enum_for. Maybe you started from with_object that had the same problem (even worse there, since that argument is mandatory!). Also, enumerators should provide a way to calculate size lazily when possible (GH#931).