summaryrefslogtreecommitdiff
path: root/spec/lib
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2015-12-21 09:17:43 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-01-14 12:48:13 +0100
commitc184eeb8489a389bf9f3528f7fe012d1edf132cb (patch)
tree2208808c892aaa2e45aec02ea76474919e72c024 /spec/lib
parent518b206287318006f9b57382a747b1474b6795a4 (diff)
downloadgitlab-ce-c184eeb8489a389bf9f3528f7fe012d1edf132cb.tar.gz
Improve `StringPath` specs (DRY)
Diffstat (limited to 'spec/lib')
-rw-r--r--spec/lib/gitlab/string_path_spec.rb29
1 files changed, 19 insertions, 10 deletions
diff --git a/spec/lib/gitlab/string_path_spec.rb b/spec/lib/gitlab/string_path_spec.rb
index 86e48f6ee0b..d086a011763 100644
--- a/spec/lib/gitlab/string_path_spec.rb
+++ b/spec/lib/gitlab/string_path_spec.rb
@@ -6,6 +6,8 @@ describe Gitlab::StringPath do
'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',
@@ -13,8 +15,12 @@ describe Gitlab::StringPath do
'/file/with/absolute_path']
end
- describe '/file/with/absolute_path' do
- subject { described_class.new('/file/with/absolute_path', universe) }
+ 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 }
@@ -22,26 +28,27 @@ describe Gitlab::StringPath do
it { is_expected.to_not have_parent }
describe '#basename' do
- subject { described_class.new('/file/with/absolute_path', universe).basename }
+ subject { |example| path(example).basename }
it { is_expected.to eq 'absolute_path' }
end
end
- describe 'path/' do
- subject { described_class.new('path/', universe) }
+ 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/' do
- subject { described_class.new('path/dir_1/', universe) }
+ describe 'path/dir_1/', path: 'path/dir_1/' do
+ subject { |example| path(example) }
+
it { is_expected.to have_parent }
describe '#files' do
- subject { described_class.new('path/dir_1/', universe).files }
+ 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),
@@ -49,12 +56,14 @@ describe Gitlab::StringPath do
end
describe '#basename' do
- subject { described_class.new('path/dir_1/', universe).basename }
+ subject { |example| path(example).basename }
+
it { is_expected.to eq 'dir_1/' }
end
describe '#parent' do
- subject { described_class.new('path/dir_1/', universe).parent }
+ subject { |example| path(example).parent }
+
it { is_expected.to eq Gitlab::StringPath.new('path/', universe) }
end
end