Sha256: 2c76e8698b896ef6db4af25f8d818f3927994e2d09fbf22dd07bfea87a93003f
Contents?: true
Size: 1.44 KB
Versions: 7
Compression:
Stored size: 1.44 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Rubocop::PathUtil do describe '#relative_path' do pending 'builds paths relative to the current project by default' it 'builds paths relative to PWD by default as a stop-gap' do relative = File.join(Dir.pwd, 'relative') expect(subject.relative_path(relative)).to eq('relative') end it 'supports custom base paths' do expect(subject.relative_path('/foo/bar', '/foo')).to eq('bar') end end describe '#match_path?' do it 'matches strings to the basename' do expect(subject.match_path?('file', '/dir/file')).to be_true expect(subject.match_path?('file', '/dir/files')).to be_false expect(subject.match_path?('dir', '/dir/file')).to be_false end it 'matches strings to the full path' do expect(subject.match_path?('/dir/file', '/dir/file')).to be_true expect(subject.match_path?('/dir/file', '/dir/dir/file')).to be_false end it 'matches glob expressions' do expect(subject.match_path?('dir/*', 'dir/file')).to be_true expect(subject.match_path?('dir/*', 'dir/sub/file')).to be_true expect(subject.match_path?('dir/**/*', 'dir/sub/file')).to be_true expect(subject.match_path?('sub/*', 'dir/sub/file')).to be_false end it 'matches regexps' do expect(subject.match_path?(/^d.*e$/, 'dir/file')).to be_true expect(subject.match_path?(/^d.*e$/, 'dir/filez')).to be_false end end end
Version data entries
7 entries across 7 versions & 2 rubygems