Class: TestFindFiles
Instance Method Summary collapse
- #test_find_files_in_multiple_paths ⇒ Object
- #test_find_files_no_recursion ⇒ Object
- #test_find_files_with_hidden_files ⇒ Object
- #test_find_files_with_mixed_existent_and_non_existent_paths ⇒ Object
- #test_find_files_with_non_existent_paths ⇒ Object
- #test_find_files_with_recursion ⇒ Object
- #test_find_files_with_relative_paths ⇒ Object
Instance Method Details
#test_find_files_in_multiple_paths ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/find_files.rb', line 97 def test_find_files_in_multiple_paths # Test with multiple paths expected_files = [ 'lib/markdown_exec/version.rb', 'spec/cli_spec.rb', 'spec/env_spec.rb', 'spec/markdown_exec_spec.rb', 'spec/tap_spec.rb' ] result = find_files('*', ['lib/**', 'spec']) expected_files.each do |file| assert_includes result, file end end |
#test_find_files_no_recursion ⇒ Object
76 77 78 79 80 |
# File 'lib/find_files.rb', line 76 def test_find_files_no_recursion # Test with no recursive directories result = find_files('cli.rb', ['lib']) assert_includes result, 'lib/cli.rb' end |
#test_find_files_with_hidden_files ⇒ Object
112 113 114 115 116 |
# File 'lib/find_files.rb', line 112 def test_find_files_with_hidden_files # Test to ensure hidden files are also found result = find_files('.gitignore', ['.']) assert_includes result, './.gitignore' end |
#test_find_files_with_mixed_existent_and_non_existent_paths ⇒ Object
124 125 126 127 128 129 130 131 |
# File 'lib/find_files.rb', line 124 def test_find_files_with_mixed_existent_and_non_existent_paths # Test with a mix of existing and non-existing paths result = find_files('*.rb', %w[lib non_existent_dir]) assert_includes result, 'lib/cli.rb' assert_includes result, 'lib/colorize.rb' # Ensure that non-existent paths do not cause failure and do not include files assert_equal result.length, Dir.glob('lib/*.rb').length end |
#test_find_files_with_non_existent_paths ⇒ Object
118 119 120 121 122 |
# File 'lib/find_files.rb', line 118 def test_find_files_with_non_existent_paths # Test with non-existent paths result = find_files('*.rb', %w[non_existent_dir another_fake_dir]) assert_empty result end |
#test_find_files_with_recursion ⇒ Object
82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/find_files.rb', line 82 def test_find_files_with_recursion # Test with recursive directories expected_files = [ 'lib/cli.rb', 'lib/colorize.rb', 'lib/dev/watchfile.sh', 'lib/markdown_exec.rb', 'lib/markdown_exec/version.rb' ] result = find_files('*', ['lib/**']) expected_files.each do |file| assert_includes result, file end end |
#test_find_files_with_relative_paths ⇒ Object
133 134 135 136 137 138 139 |
# File 'lib/find_files.rb', line 133 def test_find_files_with_relative_paths # Test with relative paths base_dir = Dir.pwd result = find_files('cli.rb', ['lib'], use_relative_paths: true) assert_includes result, 'lib/cli.rb' refute_includes result, "#{base_dir}/lib/cli.rb" end |