summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/pathname/pathname.c1
-rw-r--r--test/pathname/test_pathname.rb12
2 files changed, 13 insertions, 0 deletions
diff --git a/ext/pathname/pathname.c b/ext/pathname/pathname.c
index 1d4ed2814b..00ca85205b 100644
--- a/ext/pathname/pathname.c
+++ b/ext/pathname/pathname.c
@@ -1274,6 +1274,7 @@ static VALUE
path_each_entry(VALUE self)
{
VALUE args[1];
+ RETURN_ENUMERATOR(self, 0, 0);
args[0] = get_strpath(self);
return rb_block_call(rb_cDir, id_foreach, 1, args, each_entry_i, rb_obj_class(self));
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index 9e14668c99..c971597602 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -1355,6 +1355,18 @@ class TestPathname < Test::Unit::TestCase
}
end
+ def test_each_entry_enumerator
+ with_tmpchdir('rubytest-pathname') {|dir|
+ open("a", "w") {}
+ open("b", "w") {}
+ a = []
+ e = Pathname(".").each_entry
+ assert_kind_of(Enumerator, e)
+ e.each {|v| a << v }
+ assert_equal([Pathname("."), Pathname(".."), Pathname("a"), Pathname("b")], a.sort)
+ }
+ end
+
def test_mkdir
with_tmpchdir('rubytest-pathname') {|dir|
Pathname("d").mkdir