Fix long listing of files as arguments

The elements in `@contents` should only ever be names of directory entries.
Otherwise erroneous paths will be constructed with `@input/@content_entry`.

* add check to ensure that long listing prints information about `.hidden-file`

Fixes #104.
This commit is contained in:
Claudio Bley 2017-08-17 21:57:00 +02:00
parent 6fa9ca2112
commit 438aed19bd
2 changed files with 9 additions and 1 deletions

View file

@ -47,7 +47,8 @@ module ColorLS
@contents = if is_directory
Dir.entries(path)
else
[path]
@input = File.dirname(path)
[File.basename(path)]
end
filter_hidden_contents if is_directory

7
spec/core_spec.rb Normal file
View file

@ -0,0 +1,7 @@
require 'spec_helper'
RSpec.describe ColorLS do
it 'lists info of a hidden file with --long option' do
expect { ColorLS::Flags.new('--long', 'spec/fixtures/.hidden-file').process }.to_not output(/No Info/).to_stdout
end
end