1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
require 'spec_helper'
describe Gitlab::StringPath do
let(:universe) do
['path/',
'path/dir_1/',
'path/dir_1/file_1',
'path/dir_1/file_b',
'path/dir_1/subdir/',
'path/dir_1/subdir/subfile',
'path/second_dir',
'path/second_dir/dir_3/file_2',
'path/second_dir/dir_3/file_3',
'another_file',
'/file/with/absolute_path']
end
def path(example)
described_class.new(example.metadata[:path], universe)
end
describe '/file/with/absolute_path', path: '/file/with/absolute_path' do
subject { |example| path(example) }
it { is_expected.to be_absolute }
it { is_expected.to_not be_relative }
it { is_expected.to be_file }
it { is_expected.to_not have_parent }
describe '#basename' do
subject { |example| path(example).basename }
it { is_expected.to eq 'absolute_path' }
end
end
describe 'path/', path: 'path/' do
subject { |example| path(example) }
it { is_expected.to be_directory }
it { is_expected.to be_relative }
it { is_expected.to_not have_parent }
end
describe 'path/dir_1/', path: 'path/dir_1/' do
subject { |example| path(example) }
it { is_expected.to have_parent }
describe '#files' do
subject { |example| path(example).files }
pending { is_expected.to all(be_an_instance_of described_class) }
pending { is_expected.to be eq [Gitlab::StringPath.new('path/dir_1/file_1', universe),
Gitlab::StringPath.new('path/dir_1/file_b', universe)] }
end
describe '#basename' do
subject { |example| path(example).basename }
it { is_expected.to eq 'dir_1/' }
end
describe '#parent' do
subject { |example| path(example).parent }
it { is_expected.to eq Gitlab::StringPath.new('path/', universe) }
end
end
end