forked from athityakumar/colorls
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure to use
file_encoding
for arguments
Fixes athityakumar#377
- Loading branch information
Showing
2 changed files
with
71 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# coding: utf-8 | ||
require 'spec_helper' | ||
|
||
RSpec.describe ColorLS::Core do | ||
subject { described_class.new(*args) } | ||
|
||
context 'initialize' do | ||
let(:args) { 'Imágenes' } | ||
|
||
it 'works with Unicode characters' do | ||
camera = 'Cámara'.force_encoding(ColorLS::file_encoding) | ||
imagenes = 'Imágenes'.force_encoding(ColorLS::file_encoding) | ||
|
||
dirInfo = instance_double( | ||
'FileInfo', | ||
:group => "sys", | ||
:mtime => Time.now, | ||
:directory? => true, | ||
:owner => "user", | ||
:name => imagenes, | ||
:show => imagenes, | ||
:nlink => 1, | ||
:size => 128, | ||
:blockdev? => false, | ||
:chardev? => false, | ||
:socket? => false, | ||
:symlink? => false, | ||
:stats => OpenStruct.new( | ||
mode: 0o444, # read for user, owner, other | ||
setuid?: false, | ||
setgid?: false, | ||
sticky?: false | ||
), | ||
:executable? => true | ||
) | ||
|
||
fileInfo = instance_double( | ||
'FileInfo', | ||
:group => "sys", | ||
:mtime => Time.now, | ||
:directory? => false, | ||
:owner => "user", | ||
:name => camera, | ||
:show => camera, | ||
:nlink => 1, | ||
:size => 128, | ||
:blockdev? => false, | ||
:chardev? => false, | ||
:socket? => false, | ||
:symlink? => false, | ||
:stats => OpenStruct.new( | ||
mode: 0o444, # read for user, owner, other | ||
setuid?: false, | ||
setgid?: false, | ||
sticky?: false | ||
), | ||
:executable? => false | ||
) | ||
|
||
expect(::Dir).to receive(:entries).and_return([camera]) | ||
|
||
allow(ColorLS::FileInfo).to receive(:new).and_return(dirInfo) | ||
allow(ColorLS::FileInfo).to receive(:new).with(File.join(imagenes, camera), link_info: false) { fileInfo } | ||
|
||
expect { subject }.not_to raise_error | ||
end | ||
end | ||
end |