Skip to content

Commit

Permalink
Merge 5419641 into 26e0cb9
Browse files Browse the repository at this point in the history
  • Loading branch information
aried3r committed Dec 11, 2019
2 parents 26e0cb9 + 5419641 commit e15220a
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 9 deletions.
15 changes: 8 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# before_install:
# - gem update --system '2.4.5'
language: ruby
cache: bundler
rvm:
- 2.0.0
- 2.1.10
- 2.2.5
- 2.3.3
- 2.4.0
- 2.0
- 2.1
- 2.2
- 2.3
- 2.4
- 2.5
- 2.6
6 changes: 6 additions & 0 deletions lib/memfs/dir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@ def self.chdir(path, &block)
0
end

if Gem::Requirement.new('>= 2.6').satisfied_by?(Gem::Version.new(RUBY_VERSION))
def self.children(dirname, _opts = {})
entries(dirname, _opts) - %w[. ..]
end
end

def self.chroot(path)
fail Errno::EPERM, path unless Process.uid.zero?

Expand Down
10 changes: 8 additions & 2 deletions spec/fileutils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,14 @@
expect(described_class.pwd).to eq('/test')
end

it 'returns nil' do
expect(described_class.cd('/test')).to be_nil
if Gem::Requirement.new('>= 2.6').satisfied_by?(Gem::Version.new(RUBY_VERSION))
it 'returns 0' do
expect(described_class.cd('/test')).to eq 0
end
else
it 'returns nil' do
expect(described_class.cd('/test')).to be_nil
end
end

it "raises an error when the given path doesn't exist" do
Expand Down
17 changes: 17 additions & 0 deletions spec/memfs/dir_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ module MemFs
end
end

if Gem::Requirement.new('>= 2.6').satisfied_by?(Gem::Version.new(RUBY_VERSION))
describe '.children' do
it 'returns an array containing all of the filenames except for "." and ".."'\
'in this directory.' do
%w[/test/dir1 /test/dir2].each { |dir| described_class.mkdir dir }
_fs.touch '/test/file1', '/test/file2'
expect(described_class.children('/test')).to eq(%w[dir1 dir2 file1 file2])
end
end
else
describe '.children' do
it 'raises and error' do
expect { described_class.children('/test') }.to raise_error(NoMethodError)
end
end
end

describe '.chroot' do
before { allow(Process).to receive_messages(uid: 0) }

Expand Down

0 comments on commit e15220a

Please sign in to comment.