diff --git a/core/pathname.rbs b/core/pathname.rbs index 9baf1cbcd..0a5992f6c 100644 --- a/core/pathname.rbs +++ b/core/pathname.rbs @@ -670,28 +670,6 @@ class Pathname # def file?: () -> bool - # - # Iterates over the directory tree in a depth first manner, yielding a Pathname - # for each file under "this" directory. - # - # Note that you need to require 'pathname' to use this method. - # - # Returns an Enumerator if no block is given. - # - # Since it is implemented by the standard library module Find, Find.prune can be - # used to control the traversal. - # - # If `self` is `.`, yielded pathnames begin with a filename in the current - # directory, not `./`. - # - # See Find.find - # - def find: (?ignore_error: boolish) { (Pathname) -> untyped } -> nil - | (?ignore_error: boolish) -> Enumerator[Pathname, nil] - # - # Recursively deletes a directory, including all directories beneath it. - # - # Note that you need to require 'pathname' to use this method. - # - # See FileUtils.rm_rf - # - def rmtree: () -> self - # + # Iterates over the directory tree in a depth first manner, yielding a Pathname + # for each file under "this" directory. + # + # Note that you need to require 'pathname' to use this method. + # + # Returns an Enumerator if no block is given. + # + # Since it is implemented by the standard library module Find, Find.prune can be + # used to control the traversal. + # + # If `self` is `.`, yielded pathnames begin with a filename in the current + # directory, not `./`. + # + # See Find.find + # + def find: (?ignore_error: boolish) { (Pathname) -> untyped } -> nil + | (?ignore_error: boolish) -> Enumerator[Pathname, nil] + + # + # Recursively deletes a directory, including all directories beneath it. + # + # Note that you need to require 'pathname' to use this method. + # + # See FileUtils.rm_rf + # + def rmtree: () -> self +end diff --git a/test/stdlib/Pathname_ext_test.rb b/test/stdlib/Pathname_ext_test.rb new file mode 100644 index 000000000..d87392d64 --- /dev/null +++ b/test/stdlib/Pathname_ext_test.rb @@ -0,0 +1,29 @@ +require_relative "test_helper" +require 'pathname' + +class PathnameExtInstanceTest < Test::Unit::TestCase + include TestHelper + + library 'pathname' + testing '::Pathname' + + def test_find + assert_send_type '() { (Pathname) -> untyped } -> nil', + Pathname(__dir__), :find do end + assert_send_type '(ignore_error: bool) -> Enumerator[Pathname, nil]', + Pathname(__dir__), :find, ignore_error: true + assert_send_type '(ignore_error: Symbol) -> Enumerator[Pathname, nil]', + Pathname(__dir__), :find, ignore_error: :true + assert_send_type '() -> Enumerator[Pathname, nil]', + Pathname(__dir__), :find + end + + def test_rmtree + Dir.mktmpdir do |dir| + target = Pathname(dir).join('target') + target.mkdir + assert_send_type '() -> Pathname', + target, :rmtree + end + end +end diff --git a/test/stdlib/Pathname_test.rb b/test/stdlib/Pathname_test.rb index 7212d824c..656a53efd 100644 --- a/test/stdlib/Pathname_test.rb +++ b/test/stdlib/Pathname_test.rb @@ -1,5 +1,5 @@ require_relative "test_helper" -require 'pathname' +require "pathname" unless defined?(Pathname) class PathnameSingletonTest < Test::Unit::TestCase include TestHelper @@ -314,17 +314,6 @@ def test_file? Pathname('/unknown'), :file? end - def test_find - assert_send_type '() { (Pathname) -> untyped } -> nil', - Pathname(__dir__), :find do end - assert_send_type '(ignore_error: bool) -> Enumerator[Pathname, nil]', - Pathname(__dir__), :find, ignore_error: true - assert_send_type '(ignore_error: Symbol) -> Enumerator[Pathname, nil]', - Pathname(__dir__), :find, ignore_error: :true - assert_send_type '() -> Enumerator[Pathname, nil]', - Pathname(__dir__), :find - end - def test_fnmatch assert_send_type '(String) -> bool', Pathname('foo'), :fnmatch, 'fo*' @@ -638,15 +627,6 @@ def test_rmdir end end - def test_rmtree - Dir.mktmpdir do |dir| - target = Pathname(dir).join('target') - target.mkdir - assert_send_type '() -> Pathname', - target, :rmtree - end - end - def test_root? assert_send_type '() -> bool', Pathname('.'), :root?