diff options
Diffstat (limited to 'spec/models/repository_spec.rb')
-rw-r--r-- | spec/models/repository_spec.rb | 61 |
1 files changed, 54 insertions, 7 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index a739f523008..7748846f6a5 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1006,19 +1006,58 @@ RSpec.describe Repository do end end - context 'when specifying a path with wildcard' do - let(:path) { 'files/*/*.png' } + context 'when specifying a wildcard path' do + let(:path) { '*.md' } + + it 'returns files matching the path in the root folder' do + expect(result).to contain_exactly('CONTRIBUTING.md', + 'MAINTENANCE.md', + 'PROCESS.md', + 'README.md') + end + end + + context 'when specifying a wildcard path for all' do + let(:path) { '**.md' } + + it 'returns all matching files in all folders' do + expect(result).to contain_exactly('CONTRIBUTING.md', + 'MAINTENANCE.md', + 'PROCESS.md', + 'README.md', + 'files/markdown/ruby-style-guide.md', + 'with space/README.md') + end + end + + context 'when specifying a path to subfolders using two asterisks and a slash' do + let(:path) { 'files/**/*.md' } it 'returns all files matching the path' do - expect(result).to contain_exactly('files/images/logo-black.png', - 'files/images/logo-white.png') + expect(result).to contain_exactly('files/markdown/ruby-style-guide.md') + end + end + + context 'when specifying a wildcard path to subfolder with just two asterisks' do + let(:path) { 'files/**.md' } + + it 'returns all files in the matching path' do + expect(result).to contain_exactly('files/markdown/ruby-style-guide.md') + end + end + + context 'when specifying a wildcard path to subfolder with one asterisk' do + let(:path) { 'files/*/*.md' } + + it 'returns all files in the matching path' do + expect(result).to contain_exactly('files/markdown/ruby-style-guide.md') end end - context 'when specifying an extension with wildcard' do - let(:path) { '*.rb' } + context 'when specifying a wildcard path for an unknown number of subfolder levels' do + let(:path) { '**/*.rb' } - it 'returns all files matching the extension' do + it 'returns all matched files in all subfolders' do expect(result).to contain_exactly('encoding/russian.rb', 'files/ruby/popen.rb', 'files/ruby/regex.rb', @@ -1026,6 +1065,14 @@ RSpec.describe Repository do end end + context 'when specifying a wildcard path to one level of subfolders' do + let(:path) { '*/*.rb' } + + it 'returns all matched files in one subfolder' do + expect(result).to contain_exactly('encoding/russian.rb') + end + end + context 'when sending regexp' do let(:path) { '.*\.rb' } |