Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Ruby versions on Travis CI #30

Merged
merged 7 commits into from
Jan 7, 2020
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
simonc marked this conversation as resolved.
Show resolved Hide resolved
- 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))
simonc marked this conversation as resolved.
Show resolved Hide resolved
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
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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry about line length for specs descriptions. I exluded the spec files from rubocop to avoid having this weird cuts 😄

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry about line length for specs descriptions. I excluded the spec files from rubocop to avoid having this weird cuts 😄

%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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you meant an error 😊

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, thanks!

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