Add tests for --report flag

This commit is contained in:
bl7awy 2022-03-18 22:28:26 +03:00
parent c4f3885410
commit f43c9b9e7e
2 changed files with 18 additions and 7 deletions

View file

@ -21,7 +21,7 @@ RSpec.describe ColorLS::Flags do
} }
it('does not display hidden files') { expect { subject }.not_to output(/\.hidden-file/).to_stdout } it('does not display hidden files') { expect { subject }.not_to output(/\.hidden-file/).to_stdout }
it('does not show a report') { expect { subject }.not_to output(/Found \d+ contents/).to_stdout } it('does not show a report') { expect { subject }.not_to output(/(Found \d+ items in total\.)|(Folders: \d+, Files: \d+\.)/).to_stdout }
it('displays dirs & files alphabetically') { expect { subject }.to output(/a-file.+symlinks.+z-file/m).to_stdout } it('displays dirs & files alphabetically') { expect { subject }.to output(/a-file.+symlinks.+z-file/m).to_stdout }
it 'displays multiple files per line' do it 'displays multiple files per line' do
@ -352,11 +352,19 @@ RSpec.describe ColorLS::Flags do
end end
end end
context 'with unrecognized files' do context 'with --report flag' do
let(:args) { ['--report', FIXTURES] } let(:args) { ['--report', '--report=long', FIXTURES] }
it 'shows a report with unrecognized files' do it 'shows a report with recognized and unrecognized files' do
expect { subject }.to output(/Unrecognized files\s+: 3/).to_stdout expect { subject }.to output(/Recognized files\s+: 3\n.+Unrecognized files\s+: 3/).to_stdout
end
end
context 'with --report=short flag' do
let(:args) { ['--report=short', FIXTURES] }
it 'shows a brief report' do
expect { subject }.to output(/Folders: \d+, Files: \d+\./).to_stdout
end end
end end

View file

@ -34,6 +34,9 @@ OK colorls --color=never
OK colorls --color=always OK colorls --color=always
OK colorls --tree spec OK colorls --tree spec
OK colorls --tree=1 OK colorls --tree=1
OK colorls --report
OK colorls --report=long
OK colorls --report=short
LC_ALL=C OK colorls spec/fixtures/ LC_ALL=C OK colorls spec/fixtures/
LC_ALL=C OK colorls --git spec/fixtures/ LC_ALL=C OK colorls --git spec/fixtures/