Skip to content

Commit

Permalink
Add tests for --report flag
Browse files Browse the repository at this point in the history
  • Loading branch information
bl7awy19 committed Mar 18, 2022
1 parent c4f3885 commit f43c9b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
22 changes: 15 additions & 7 deletions spec/color_ls/flags_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
end.not_to output(/((r|-).*(w|-).*(x|-).*){3}/).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('displays dirs & files alphabetically') { expect { subject }.to output(/a-file.+symlinks.+z-file/m).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+ 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 multiple files per line' do
allow($stdout).to receive(:tty?).and_return(true)
Expand Down Expand Up @@ -352,11 +352,19 @@
end
end

context 'with unrecognized files' do
let(:args) { ['--report', FIXTURES] }
context 'with --report flag' do
let(:args) { ['--report', '--report=long', FIXTURES] }

it 'shows a report with unrecognized files' do
expect { subject }.to output(/Unrecognized files\s+: 3/).to_stdout
it 'shows a report with recognized and unrecognized files' do
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

Expand Down
3 changes: 3 additions & 0 deletions test/checks
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ OK colorls --color=never
OK colorls --color=always
OK colorls --tree spec
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 --git spec/fixtures/
Expand Down

0 comments on commit f43c9b9

Please # to comment.