|
4 | 4 | require 'fileutils' |
5 | 5 |
|
6 | 6 | RSpec.describe CodeManifest::Manifest do |
7 | | - let(:root) { Pathname.new('tmp/manifest_spec').expand_path } |
| 7 | + let(:root) { CodeManifest.root } |
8 | 8 |
|
9 | 9 | describe '#files' do |
10 | | - let(:patterns) { ['/foo', 'bar/*', '!bar/exclude'] } |
11 | | - let(:manifest) { described_class.new(root.expand_path, patterns) } |
| 10 | + let(:patterns) { ['/foo/foo.md', 'bar/*', '!bar/exclude'] } |
| 11 | + let(:manifest) { described_class.new(patterns) } |
12 | 12 |
|
13 | 13 | around do |example| |
14 | | - root.mkpath |
15 | | - FileUtils.touch(root.join('foo')) |
16 | 14 | root.join('bar').mkpath |
17 | 15 | FileUtils.touch(root.join('bar/include')) |
18 | 16 | FileUtils.touch(root.join('bar/exclude')) |
19 | 17 | example.run |
20 | | - root.rmtree |
21 | 18 | end |
22 | 19 |
|
23 | 20 | it 'returns only included files' do |
24 | | - expect(manifest.files).to match_array(['bar/include', 'foo']) |
| 21 | + expect(manifest.files).to match_array(['bar/include', 'foo/foo.md']) |
25 | 22 | end |
26 | 23 |
|
27 | 24 | context 'with different type of globs' do |
28 | 25 | let(:patterns) { ['dir_bar/**/*'] } |
29 | | - let(:manifest) { described_class.new(root.expand_path, patterns) } |
| 26 | + let(:manifest) { described_class.new(patterns) } |
30 | 27 |
|
31 | 28 | around do |example| |
32 | | - Dir.mktmpdir do |tmp_dir| |
33 | | - Dir.chdir(tmp_dir) do |
34 | | - FileUtils.mkdir(root.join('dir_bar')) |
35 | | - FileUtils.touch(root.join('dir_bar/foo')) |
36 | | - example.run |
37 | | - end |
38 | | - end |
| 29 | + FileUtils.mkdir(root.join('dir_bar')) |
| 30 | + FileUtils.touch(root.join('dir_bar/foo')) |
| 31 | + example.run |
39 | 32 | end |
40 | 33 |
|
41 | 34 | it 'excludes directories' do |
|
63 | 56 |
|
64 | 57 | expected = [ |
65 | 58 | 'dir_bar/.bar', |
66 | | - 'dir_bar/foo', |
| 59 | + 'dir_bar/foo' |
67 | 60 | ] |
68 | 61 |
|
69 | 62 | expect(manifest.files).to match_array(expected) |
|
80 | 73 |
|
81 | 74 | expected = [ |
82 | 75 | 'foo.x', |
83 | | - 'foo.y', |
| 76 | + 'foo.y' |
84 | 77 | ] |
85 | 78 |
|
86 | 79 | expect(manifest.files).to match_array(expected) |
|
91 | 84 |
|
92 | 85 | describe '#digest' do |
93 | 86 | let(:patterns) { ['/foo', 'bar/*', '!bar/exclude'] } |
94 | | - let(:manifest) { described_class.new(root.expand_path, patterns) } |
| 87 | + let(:manifest) { described_class.new(patterns) } |
95 | 88 |
|
96 | 89 | around do |example| |
97 | 90 | root.mkpath |
|
104 | 97 | end |
105 | 98 |
|
106 | 99 | it 'returns only included files' do |
107 | | - expect(manifest.digest).to eq('020eb29b524d7ba672d9d48bc72db455') |
| 100 | + expect(manifest.digest).to eq('74be16979710d4c4e7c6647856088456') |
108 | 101 | end |
109 | 102 | end |
110 | 103 |
|
111 | 104 | describe '#matches' do |
112 | 105 | let(:patterns) { ['/foo', 'bar/*', '!bar/exclude'] } |
113 | | - let(:manifest) { described_class.new(root.expand_path, patterns) } |
| 106 | + let(:manifest) { described_class.new(patterns) } |
114 | 107 | let(:paths) do |
115 | 108 | [ |
116 | 109 | 'bar/exclude', |
|
135 | 128 |
|
136 | 129 | it 'returns matched paths' do |
137 | 130 | expect(manifest.matches(paths)).to match_array([ |
138 | | - 'bar/iniclude', |
139 | | - 'foo', |
140 | | - ]) |
| 131 | + 'bar/iniclude', |
| 132 | + 'foo' |
| 133 | + ]) |
141 | 134 | end |
142 | 135 | end |
143 | 136 | end |
0 commit comments