diff options
| author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2015-12-21 10:11:15 +0100 |
|---|---|---|
| committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2016-01-14 12:48:13 +0100 |
| commit | d382335dcd9285c9355ed04dc12c5314bca3c024 (patch) | |
| tree | 598ed4a68aa4b2e349bde636850ab4479e69545b /spec | |
| parent | c184eeb8489a389bf9f3528f7fe012d1edf132cb (diff) | |
| download | gitlab-ce-d382335dcd9285c9355ed04dc12c5314bca3c024.tar.gz | |
Add implementation of remaining methods in `StringPath`
Diffstat (limited to 'spec')
| -rw-r--r-- | spec/lib/gitlab/string_path_spec.rb | 53 |
1 files changed, 43 insertions, 10 deletions
diff --git a/spec/lib/gitlab/string_path_spec.rb b/spec/lib/gitlab/string_path_spec.rb index d086a011763..7818e340726 100644 --- a/spec/lib/gitlab/string_path_spec.rb +++ b/spec/lib/gitlab/string_path_spec.rb @@ -16,7 +16,11 @@ describe Gitlab::StringPath do end def path(example) - described_class.new(example.metadata[:path], universe) + string_path(example.metadata[:path]) + end + + def string_path(string_path) + described_class.new(string_path, universe) end describe '/file/with/absolute_path', path: '/file/with/absolute_path' do @@ -47,14 +51,6 @@ describe Gitlab::StringPath do 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 } @@ -64,7 +60,44 @@ describe Gitlab::StringPath do describe '#parent' do subject { |example| path(example).parent } - it { is_expected.to eq Gitlab::StringPath.new('path/', universe) } + it { is_expected.to eq string_path('path/') } + end + + describe '#descendants' do + subject { |example| path(example).descendants } + + it { is_expected.to be_an_instance_of Array } + it { is_expected.to all(be_an_instance_of described_class) } + it { is_expected.to contain_exactly string_path('path/dir_1/file_1'), + string_path('path/dir_1/file_b'), + string_path('path/dir_1/subdir/'), + string_path('path/dir_1/subdir/subfile') } + end + + describe '#children' do + subject { |example| path(example).children } + + it { is_expected.to all(be_an_instance_of described_class) } + it { is_expected.to contain_exactly string_path('path/dir_1/file_1'), + string_path('path/dir_1/file_b'), + string_path('path/dir_1/subdir/') } + end + + describe '#files' do + subject { |example| path(example).files } + + it { is_expected.to all(be_file) } + it { is_expected.to all(be_an_instance_of described_class) } + it { is_expected.to contain_exactly string_path('path/dir_1/file_1'), + string_path('path/dir_1/file_b') } + end + + describe '#directories' do + subject { |example| path(example).directories } + + it { is_expected.to all(be_directory) } + it { is_expected.to all(be_an_instance_of described_class) } + it { is_expected.to contain_exactly string_path('path/dir_1/subdir/') } end end end |
