spec: Use multi-line regex mode for matching

This avoids test failures on small terminals (e.g. on Travis) when multiple
lines are generated.
This commit is contained in:
Claudio Bley 2018-07-10 22:09:17 +02:00
parent 012aeb8493
commit f979ce281c

View file

@ -20,7 +20,7 @@ RSpec.describe ColorLS::Flags do
it { is_expected.not_to match(/((r|-).*(w|-).*(x|-).*){3}/) } # does not list file info it { is_expected.not_to match(/((r|-).*(w|-).*(x|-).*){3}/) } # does not list file info
it { is_expected.not_to match(/\.hidden-file/) } # does not display hidden files it { is_expected.not_to match(/\.hidden-file/) } # does not display hidden files
it { is_expected.not_to match(/Found \d+ contents/) } # does not show a report it { is_expected.not_to match(/Found \d+ contents/) } # does not show a report
it { is_expected.to match(/a-file.+symlinks.+z-file/) } # displays dirs & files alphabetically it { is_expected.to match(/a-file.+symlinks.+z-file/m) } # displays dirs & files alphabetically
it { is_expected.not_to match(/(.*\n){3}/) } # displays multiple files per line it { is_expected.not_to match(/(.*\n){3}/) } # displays multiple files per line
it { is_expected.not_to match(%r(\.{1,2}/)) } # does not display ./ or ../ it { is_expected.not_to match(%r(\.{1,2}/)) } # does not display ./ or ../
it { is_expected.not_to match(/├──/) } # does not display file hierarchy it { is_expected.not_to match(/├──/) } # does not display file hierarchy
@ -29,7 +29,7 @@ RSpec.describe ColorLS::Flags do
context 'with --reverse flag' do context 'with --reverse flag' do
let(:args) { ['--reverse', FIXTURES] } let(:args) { ['--reverse', FIXTURES] }
it { is_expected.to match(/z-file.+symlinks.+a-file/) } # displays dirs & files in reverse alphabetical order it { is_expected.to match(/z-file.+symlinks.+a-file/m) } # displays dirs & files in reverse alphabetical order
end end
context 'with --long flag & file path' do context 'with --long flag & file path' do
@ -53,13 +53,13 @@ RSpec.describe ColorLS::Flags do
context 'with --sort-dirs flag' do context 'with --sort-dirs flag' do
let(:args) { ['--sort-dirs', FIXTURES] } let(:args) { ['--sort-dirs', FIXTURES] }
it { is_expected.to match(/symlinks.+a-file.+z-file/) } # sorts results alphabetically, directories first it { is_expected.to match(/symlinks.+a-file.+z-file/m) } # sorts results alphabetically, directories first
end end
context 'with --sort-files flag' do context 'with --sort-files flag' do
let(:args) { ['--sort-files', FIXTURES] } let(:args) { ['--sort-files', FIXTURES] }
it { is_expected.to match(/a-file.+z-file.+symlinks/) } # sorts results alphabetically, files first it { is_expected.to match(/a-file.+z-file.+symlinks/m) } # sorts results alphabetically, files first
end end
context 'with --sort=time' do context 'with --sort=time' do
@ -88,7 +88,7 @@ RSpec.describe ColorLS::Flags do
context 'with --sort=extension flag' do context 'with --sort=extension flag' do
let(:args) { ['--sort=extension', FIXTURES] } let(:args) { ['--sort=extension', FIXTURES] }
it { is_expected.to match(/a-file.+symlinks.+z-file.+a.md.+a.txt.+z.txt/) } # sorts results by extension it { is_expected.to match(/a-file.+symlinks.+z-file.+a.md.+a.txt.+z.txt/m) } # sorts results by extension
end end
context 'with --dirs flag' do context 'with --dirs flag' do