fluid_cli 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fluid_cli/api.rb +9 -3
- data/lib/fluid_cli/http_request.rb +7 -1
- data/lib/fluid_cli/theme/syncer.rb +93 -13
- data/lib/fluid_cli/version.rb +1 -1
- data/lib/fluid_cli.rb +1 -0
- metadata +16 -97
- data/vendor/deps/listen/.github/release-drafter.yml +0 -17
- data/vendor/deps/listen/.github/workflows/development.yml +0 -67
- data/vendor/deps/listen/.github/workflows/push.yml +0 -12
- data/vendor/deps/listen/.gitignore +0 -28
- data/vendor/deps/listen/.rspec +0 -3
- data/vendor/deps/listen/.rubocop.yml +0 -283
- data/vendor/deps/listen/.yardopts +0 -11
- data/vendor/deps/listen/CHANGELOG.md +0 -1
- data/vendor/deps/listen/CONTRIBUTING.md +0 -45
- data/vendor/deps/listen/Gemfile +0 -33
- data/vendor/deps/listen/Guardfile +0 -26
- data/vendor/deps/listen/LICENSE.txt +0 -22
- data/vendor/deps/listen/README.md +0 -490
- data/vendor/deps/listen/Rakefile +0 -154
- data/vendor/deps/listen/bin/listen +0 -11
- data/vendor/deps/listen/lib/listen/adapter/base.rb +0 -129
- data/vendor/deps/listen/lib/listen/adapter/bsd.rb +0 -104
- data/vendor/deps/listen/lib/listen/adapter/config.rb +0 -31
- data/vendor/deps/listen/lib/listen/adapter/darwin.rb +0 -77
- data/vendor/deps/listen/lib/listen/adapter/linux.rb +0 -108
- data/vendor/deps/listen/lib/listen/adapter/polling.rb +0 -40
- data/vendor/deps/listen/lib/listen/adapter/windows.rb +0 -96
- data/vendor/deps/listen/lib/listen/adapter.rb +0 -43
- data/vendor/deps/listen/lib/listen/backend.rb +0 -40
- data/vendor/deps/listen/lib/listen/change.rb +0 -69
- data/vendor/deps/listen/lib/listen/cli.rb +0 -65
- data/vendor/deps/listen/lib/listen/directory.rb +0 -93
- data/vendor/deps/listen/lib/listen/error.rb +0 -11
- data/vendor/deps/listen/lib/listen/event/config.rb +0 -39
- data/vendor/deps/listen/lib/listen/event/loop.rb +0 -92
- data/vendor/deps/listen/lib/listen/event/processor.rb +0 -128
- data/vendor/deps/listen/lib/listen/event/queue.rb +0 -52
- data/vendor/deps/listen/lib/listen/file.rb +0 -95
- data/vendor/deps/listen/lib/listen/fsm.rb +0 -131
- data/vendor/deps/listen/lib/listen/listener/config.rb +0 -41
- data/vendor/deps/listen/lib/listen/listener.rb +0 -136
- data/vendor/deps/listen/lib/listen/logger.rb +0 -65
- data/vendor/deps/listen/lib/listen/monotonic_time.rb +0 -27
- data/vendor/deps/listen/lib/listen/options.rb +0 -24
- data/vendor/deps/listen/lib/listen/queue_optimizer.rb +0 -129
- data/vendor/deps/listen/lib/listen/record/entry.rb +0 -66
- data/vendor/deps/listen/lib/listen/record/symlink_detector.rb +0 -47
- data/vendor/deps/listen/lib/listen/record.rb +0 -122
- data/vendor/deps/listen/lib/listen/silencer/controller.rb +0 -50
- data/vendor/deps/listen/lib/listen/silencer.rb +0 -106
- data/vendor/deps/listen/lib/listen/thread.rb +0 -54
- data/vendor/deps/listen/lib/listen/version.rb +0 -5
- data/vendor/deps/listen/lib/listen.rb +0 -47
- data/vendor/deps/listen/listen.gemspec +0 -40
- data/vendor/deps/listen/spec/acceptance/listen_spec.rb +0 -320
- data/vendor/deps/listen/spec/lib/listen/adapter/base_spec.rb +0 -101
- data/vendor/deps/listen/spec/lib/listen/adapter/bsd_spec.rb +0 -13
- data/vendor/deps/listen/spec/lib/listen/adapter/config_spec.rb +0 -122
- data/vendor/deps/listen/spec/lib/listen/adapter/darwin_spec.rb +0 -82
- data/vendor/deps/listen/spec/lib/listen/adapter/linux_spec.rb +0 -199
- data/vendor/deps/listen/spec/lib/listen/adapter/polling_spec.rb +0 -83
- data/vendor/deps/listen/spec/lib/listen/adapter/windows_spec.rb +0 -13
- data/vendor/deps/listen/spec/lib/listen/adapter_spec.rb +0 -69
- data/vendor/deps/listen/spec/lib/listen/backend_spec.rb +0 -82
- data/vendor/deps/listen/spec/lib/listen/change_spec.rb +0 -102
- data/vendor/deps/listen/spec/lib/listen/cli_spec.rb +0 -116
- data/vendor/deps/listen/spec/lib/listen/directory_spec.rb +0 -284
- data/vendor/deps/listen/spec/lib/listen/event/config_spec.rb +0 -33
- data/vendor/deps/listen/spec/lib/listen/event/loop_spec.rb +0 -118
- data/vendor/deps/listen/spec/lib/listen/event/processor_spec.rb +0 -250
- data/vendor/deps/listen/spec/lib/listen/event/queue_spec.rb +0 -118
- data/vendor/deps/listen/spec/lib/listen/file_spec.rb +0 -254
- data/vendor/deps/listen/spec/lib/listen/fsm_spec.rb +0 -147
- data/vendor/deps/listen/spec/lib/listen/listener/config_spec.rb +0 -29
- data/vendor/deps/listen/spec/lib/listen/listener_spec.rb +0 -321
- data/vendor/deps/listen/spec/lib/listen/logger_spec.rb +0 -212
- data/vendor/deps/listen/spec/lib/listen/monotonic_time_spec.rb +0 -58
- data/vendor/deps/listen/spec/lib/listen/queue_optimizer_spec.rb +0 -111
- data/vendor/deps/listen/spec/lib/listen/record_spec.rb +0 -424
- data/vendor/deps/listen/spec/lib/listen/silencer/controller_spec.rb +0 -97
- data/vendor/deps/listen/spec/lib/listen/silencer_spec.rb +0 -109
- data/vendor/deps/listen/spec/lib/listen/thread_spec.rb +0 -133
- data/vendor/deps/listen/spec/lib/listen_spec.rb +0 -25
- data/vendor/deps/listen/spec/spec_helper.rb +0 -49
- data/vendor/deps/listen/spec/support/acceptance_helper.rb +0 -260
- data/vendor/deps/listen/spec/support/fixtures_helper.rb +0 -32
- data/vendor/deps/listen/spec/support/platform_helper.rb +0 -17
- data/vendor/deps/observer/.github/dependabot.yml +0 -6
- data/vendor/deps/observer/.github/workflows/test.yml +0 -33
- data/vendor/deps/observer/.gitignore +0 -8
- data/vendor/deps/observer/BSDL +0 -22
- data/vendor/deps/observer/COPYING +0 -56
- data/vendor/deps/observer/Gemfile +0 -9
- data/vendor/deps/observer/README.md +0 -139
- data/vendor/deps/observer/Rakefile +0 -10
- data/vendor/deps/observer/bin/console +0 -14
- data/vendor/deps/observer/bin/setup +0 -8
- data/vendor/deps/observer/lib/observer.rb +0 -229
- data/vendor/deps/observer/observer.gemspec +0 -32
- data/vendor/deps/observer/test/test_observer.rb +0 -66
|
@@ -1,424 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe Listen::Record do
|
|
4
|
-
let(:dir) { instance_double(Pathname, to_s: '/dir') }
|
|
5
|
-
let(:silencer_options) { { ignore!: [/\A\.ignored/] } }
|
|
6
|
-
let(:silencer) { Listen::Silencer.new(**silencer_options) }
|
|
7
|
-
let(:record) { Listen::Record.new(dir, silencer) }
|
|
8
|
-
|
|
9
|
-
def dir_entries_for(hash)
|
|
10
|
-
hash.each do |dir, entries|
|
|
11
|
-
allow(::Dir).to receive(:entries).with(dir) { entries }
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
def real_directory(hash)
|
|
16
|
-
dir_entries_for(hash)
|
|
17
|
-
hash.each_key do |dir|
|
|
18
|
-
realpath(dir)
|
|
19
|
-
end
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
def file(path)
|
|
23
|
-
allow(::Dir).to receive(:entries).with(path).and_raise(Errno::ENOTDIR)
|
|
24
|
-
path
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def lstat(path, stat = nil)
|
|
28
|
-
stat ||= instance_double(::File::Stat, mtime: 2.3, mode: 0755, size: 42)
|
|
29
|
-
allow(::File).to receive(:lstat).with(path).and_return(stat)
|
|
30
|
-
stat
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
def realpath(path)
|
|
34
|
-
allow(::File).to receive(:realpath).with(path).and_return(path)
|
|
35
|
-
path
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def symlink(hash_or_dir)
|
|
39
|
-
if hash_or_dir.is_a?(String)
|
|
40
|
-
allow(::File).to receive(:realpath).with(hash_or_dir).
|
|
41
|
-
and_return(hash_or_dir)
|
|
42
|
-
else
|
|
43
|
-
hash_or_dir.each do |dir, real_path|
|
|
44
|
-
allow(::File).to receive(:realpath).with(dir).and_return(real_path)
|
|
45
|
-
end
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def record_tree(record)
|
|
50
|
-
record.instance_variable_get(:@tree)
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
describe '#update_file' do
|
|
54
|
-
context 'with path in watched dir' do
|
|
55
|
-
it 'sets path by spliting dirname and basename' do
|
|
56
|
-
record.update_file('file.rb', mtime: 1.1)
|
|
57
|
-
expect(record_tree(record)).to eq('file.rb' => { mtime: 1.1 })
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
it 'sets path and keeps old data not overwritten' do
|
|
61
|
-
record.update_file('file.rb', foo: 1, bar: 2)
|
|
62
|
-
record.update_file('file.rb', foo: 3)
|
|
63
|
-
watched_dir = record_tree(record)
|
|
64
|
-
expect(watched_dir).to eq('file.rb' => { foo: 3, bar: 2 })
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
context 'with subdir path' do
|
|
69
|
-
it 'sets path by splitting dirname and basename' do
|
|
70
|
-
record.update_file('path/file.rb', mtime: 1.1)
|
|
71
|
-
expect(record_tree(record)['path']).to eq('file.rb' => { mtime: 1.1 })
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
it 'sets path and keeps old data not overwritten' do
|
|
75
|
-
record.update_file('path/file.rb', foo: 1, bar: 2)
|
|
76
|
-
record.update_file('path/file.rb', foo: 3)
|
|
77
|
-
file_data = record_tree(record)['path']['file.rb']
|
|
78
|
-
expect(file_data).to eq(foo: 3, bar: 2)
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
describe '#add_dir' do
|
|
84
|
-
it 'sets itself when .' do
|
|
85
|
-
record.add_dir('.')
|
|
86
|
-
expect(record_tree(record)).to eq({})
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it 'sets itself when nil' do
|
|
90
|
-
record.add_dir(nil)
|
|
91
|
-
expect(record_tree(record)).to eq({})
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
it 'sets itself when empty' do
|
|
95
|
-
record.add_dir('')
|
|
96
|
-
expect(record_tree(record)).to eq({})
|
|
97
|
-
end
|
|
98
|
-
|
|
99
|
-
it 'correctly sets new directory data' do
|
|
100
|
-
record.add_dir('path/subdir')
|
|
101
|
-
expect(record_tree(record)).to eq('path/subdir' => {})
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
it 'sets path and keeps old data not overwritten' do
|
|
105
|
-
record.add_dir('path/subdir')
|
|
106
|
-
record.update_file('path/subdir/file.rb', mtime: 1.1)
|
|
107
|
-
record.add_dir('path/subdir')
|
|
108
|
-
record.update_file('path/subdir/file2.rb', mtime: 1.2)
|
|
109
|
-
record.add_dir('path/subdir')
|
|
110
|
-
|
|
111
|
-
watched = record_tree(record)
|
|
112
|
-
expect(watched.keys).to eq ['path/subdir']
|
|
113
|
-
expect(watched['path/subdir'].keys).to eq %w[file.rb file2.rb]
|
|
114
|
-
|
|
115
|
-
subdir = watched['path/subdir']
|
|
116
|
-
expect(subdir['file.rb']).to eq(mtime: 1.1)
|
|
117
|
-
expect(subdir['file2.rb']).to eq(mtime: 1.2)
|
|
118
|
-
end
|
|
119
|
-
end
|
|
120
|
-
|
|
121
|
-
describe '#unset_path' do
|
|
122
|
-
context 'within watched dir' do
|
|
123
|
-
context 'when path is present' do
|
|
124
|
-
before { record.update_file('file.rb', mtime: 1.1) }
|
|
125
|
-
|
|
126
|
-
it 'unsets path' do
|
|
127
|
-
record.unset_path('file.rb')
|
|
128
|
-
expect(record_tree(record)).to eq({})
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
context 'when path not present' do
|
|
133
|
-
it 'unsets path' do
|
|
134
|
-
record.unset_path('file.rb')
|
|
135
|
-
expect(record_tree(record)).to eq({})
|
|
136
|
-
end
|
|
137
|
-
end
|
|
138
|
-
end
|
|
139
|
-
|
|
140
|
-
context 'within subdir' do
|
|
141
|
-
context 'when path is present' do
|
|
142
|
-
before { record.update_file('path/file.rb', mtime: 1.1) }
|
|
143
|
-
|
|
144
|
-
it 'unsets path' do
|
|
145
|
-
record.unset_path('path/file.rb')
|
|
146
|
-
expect(record_tree(record)).to eq('path' => {})
|
|
147
|
-
end
|
|
148
|
-
end
|
|
149
|
-
|
|
150
|
-
context 'when path not present' do
|
|
151
|
-
it 'unsets path' do
|
|
152
|
-
record.unset_path('path/file.rb')
|
|
153
|
-
expect(record_tree(record)).to eq({})
|
|
154
|
-
end
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
describe '#file_data' do
|
|
160
|
-
context 'with path in watched dir' do
|
|
161
|
-
context 'when path is present' do
|
|
162
|
-
before { record.update_file('file.rb', mtime: 1.1) }
|
|
163
|
-
|
|
164
|
-
it 'returns file data' do
|
|
165
|
-
expect(record.file_data('file.rb')).to eq(mtime: 1.1)
|
|
166
|
-
end
|
|
167
|
-
end
|
|
168
|
-
|
|
169
|
-
context 'path not present' do
|
|
170
|
-
it 'return empty hash' do
|
|
171
|
-
expect(record.file_data('file.rb')).to be_empty
|
|
172
|
-
end
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
context 'with path in subdir' do
|
|
177
|
-
context 'when path is present' do
|
|
178
|
-
before { record.update_file('path/file.rb', mtime: 1.1) }
|
|
179
|
-
|
|
180
|
-
it 'returns file data' do
|
|
181
|
-
expected = { mtime: 1.1 }
|
|
182
|
-
expect(record.file_data('path/file.rb')).to eq expected
|
|
183
|
-
end
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
context 'path not present' do
|
|
187
|
-
it 'return empty hash' do
|
|
188
|
-
expect(record.file_data('path/file.rb')).to be_empty
|
|
189
|
-
end
|
|
190
|
-
end
|
|
191
|
-
end
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
describe '#dir_entries' do
|
|
195
|
-
context 'in watched dir' do
|
|
196
|
-
subject { record.dir_entries('.') }
|
|
197
|
-
|
|
198
|
-
context 'with no entries' do
|
|
199
|
-
it { should be_empty }
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
context 'with file.rb in record' do
|
|
203
|
-
before { record.update_file('file.rb', mtime: 1.1) }
|
|
204
|
-
it { should eq('file.rb' => { mtime: 1.1 }) }
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
context 'with subdir/file.rb in record' do
|
|
208
|
-
before { record.update_file('subdir/file.rb', mtime: 1.1) }
|
|
209
|
-
it { should eq('subdir' => {}) }
|
|
210
|
-
end
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
context 'when there is a file with the same name as a dir' do
|
|
214
|
-
subject { record.dir_entries('cypress') }
|
|
215
|
-
|
|
216
|
-
before do
|
|
217
|
-
record.update_file('cypress.json', mtime: 1.1)
|
|
218
|
-
record.update_file('cypress/README.md', mtime: 1.2)
|
|
219
|
-
record.update_file('a/b/cypress/d', mtime: 1.3)
|
|
220
|
-
record.update_file('a/b/c/cypress', mtime: 1.3)
|
|
221
|
-
end
|
|
222
|
-
it { should eq('README.md' => { mtime: 1.2 }) }
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
context 'when there is a file with a similar name to a dir' do
|
|
226
|
-
subject { record.dir_entries('app') }
|
|
227
|
-
|
|
228
|
-
before do
|
|
229
|
-
record.update_file('appspec.yml', mtime: 1.1)
|
|
230
|
-
record.update_file('app/README.md', mtime: 1.2)
|
|
231
|
-
record.update_file('spec/app/foo', mtime: 1.3)
|
|
232
|
-
end
|
|
233
|
-
it { should eq('README.md' => { mtime: 1.2 }) }
|
|
234
|
-
end
|
|
235
|
-
|
|
236
|
-
context 'in subdir /path' do
|
|
237
|
-
subject { record.dir_entries('path') }
|
|
238
|
-
|
|
239
|
-
context 'with no entries' do
|
|
240
|
-
it { should be_empty }
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
context 'with path/file.rb already in record' do
|
|
244
|
-
before { record.update_file('path/file.rb', mtime: 1.1) }
|
|
245
|
-
it { should eq('file.rb' => { mtime: 1.1 }) }
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
context 'with empty path/subdir' do
|
|
249
|
-
before { record.add_dir('path/subdir') }
|
|
250
|
-
it { should be_empty }
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
context 'with path/subdir with file' do
|
|
254
|
-
before do
|
|
255
|
-
record.add_dir('path/subdir')
|
|
256
|
-
record.update_file('path/subdir/file.rb', mtime: 1.1)
|
|
257
|
-
end
|
|
258
|
-
it { should be_empty }
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
context 'with path renamed to file' do
|
|
262
|
-
before do
|
|
263
|
-
record.add_dir('path/subdir')
|
|
264
|
-
record.update_file('path', mtime: 1.1)
|
|
265
|
-
end
|
|
266
|
-
it { should be_empty }
|
|
267
|
-
end
|
|
268
|
-
end
|
|
269
|
-
end
|
|
270
|
-
|
|
271
|
-
describe '#build' do
|
|
272
|
-
let(:dir1) { Pathname('/dir1') }
|
|
273
|
-
|
|
274
|
-
before do
|
|
275
|
-
stubs = {
|
|
276
|
-
::File => %w[lstat realpath],
|
|
277
|
-
::Dir => %w[entries exist?]
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
stubs.each do |klass, meths|
|
|
281
|
-
meths.each do |meth|
|
|
282
|
-
allow(klass).to receive(meth.to_sym) do |*args|
|
|
283
|
-
fail "stub called: #{klass}.#{meth}(#{args.map(&:inspect) * ', '})"
|
|
284
|
-
end
|
|
285
|
-
end
|
|
286
|
-
end
|
|
287
|
-
end
|
|
288
|
-
|
|
289
|
-
it 're-inits paths' do
|
|
290
|
-
real_directory('/dir1' => [])
|
|
291
|
-
real_directory('/dir' => [])
|
|
292
|
-
|
|
293
|
-
record.update_file('path/file.rb', mtime: 1.1)
|
|
294
|
-
record.build
|
|
295
|
-
expect(record_tree(record)).to eq({})
|
|
296
|
-
expect(record.file_data('path/file.rb')).to be_empty
|
|
297
|
-
end
|
|
298
|
-
|
|
299
|
-
let(:foo_stat) { instance_double(::File::Stat, mtime: 1.0, mode: 0644, size: 42) }
|
|
300
|
-
let(:bar_stat) { instance_double(::File::Stat, mtime: 2.3, mode: 0755, size: 42) }
|
|
301
|
-
|
|
302
|
-
context 'with no subdirs' do
|
|
303
|
-
before do
|
|
304
|
-
real_directory('/dir' => %w[foo bar])
|
|
305
|
-
lstat(file('/dir/foo'), foo_stat)
|
|
306
|
-
lstat(file('/dir/bar'), bar_stat)
|
|
307
|
-
real_directory('/dir2' => [])
|
|
308
|
-
end
|
|
309
|
-
|
|
310
|
-
it 'builds record' do
|
|
311
|
-
record.build
|
|
312
|
-
expect(record_tree(record)).
|
|
313
|
-
to eq(
|
|
314
|
-
'foo' => { mtime: 1.0, mode: 0644, size: 42 },
|
|
315
|
-
'bar' => { mtime: 2.3, mode: 0755, size: 42 })
|
|
316
|
-
end
|
|
317
|
-
end
|
|
318
|
-
|
|
319
|
-
context 'with subdir containing files' do
|
|
320
|
-
before do
|
|
321
|
-
real_directory('/dir' => %w[dir1 dir2 .ignored])
|
|
322
|
-
real_directory('/dir/dir1' => %w[foo])
|
|
323
|
-
real_directory('/dir/dir1/foo' => %w[bar])
|
|
324
|
-
lstat(file('/dir/.ignored/FETCH_HEAD'))
|
|
325
|
-
lstat(file('/dir/dir1/foo/bar'))
|
|
326
|
-
real_directory('/dir/dir2' => [])
|
|
327
|
-
end
|
|
328
|
-
|
|
329
|
-
it 'builds record, skipping silenced patterns' do
|
|
330
|
-
record.build
|
|
331
|
-
expect(record_tree(record)).
|
|
332
|
-
to eq(
|
|
333
|
-
'dir1' => {},
|
|
334
|
-
'dir1/foo' => { 'bar' => { mtime: 2.3, mode: 0755, size: 42 } },
|
|
335
|
-
'dir2' => {}
|
|
336
|
-
)
|
|
337
|
-
end
|
|
338
|
-
end
|
|
339
|
-
|
|
340
|
-
context 'with subdir containing dirs' do
|
|
341
|
-
before do
|
|
342
|
-
real_directory('/dir' => %w[dir1 dir2 .ignored])
|
|
343
|
-
real_directory('/dir/.ignored' => %w[ignored_file])
|
|
344
|
-
real_directory('/dir/dir1' => %w[foo])
|
|
345
|
-
real_directory('/dir/dir1/foo' => %w[bar baz])
|
|
346
|
-
real_directory('/dir/dir1/foo/bar' => [])
|
|
347
|
-
real_directory('/dir/dir1/foo/baz' => [])
|
|
348
|
-
real_directory('/dir/dir2' => [])
|
|
349
|
-
|
|
350
|
-
allow(::File).to receive(:realpath) { |path| path }
|
|
351
|
-
end
|
|
352
|
-
|
|
353
|
-
it 'builds record' do
|
|
354
|
-
record.build
|
|
355
|
-
expect(record_tree(record)).
|
|
356
|
-
to eq(
|
|
357
|
-
'dir1' => {},
|
|
358
|
-
'dir1/foo' => {},
|
|
359
|
-
'dir1/foo/bar' => {},
|
|
360
|
-
'dir1/foo/baz' => {},
|
|
361
|
-
'dir2' => {}
|
|
362
|
-
)
|
|
363
|
-
end
|
|
364
|
-
end
|
|
365
|
-
|
|
366
|
-
context 'with subdir containing symlink to parent' do
|
|
367
|
-
subject { record.paths }
|
|
368
|
-
before do
|
|
369
|
-
real_directory('/dir' => %w[dir1 dir2])
|
|
370
|
-
real_directory('/dir/dir1' => %w[foo])
|
|
371
|
-
dir_entries_for('/dir/dir1/foo' => %w[dir1])
|
|
372
|
-
symlink('/dir/dir1/foo' => '/dir/dir1')
|
|
373
|
-
|
|
374
|
-
real_directory('/dir/dir2' => [])
|
|
375
|
-
end
|
|
376
|
-
|
|
377
|
-
it 'shows a warning' do
|
|
378
|
-
expect_any_instance_of(Listen::Record::SymlinkDetector).to receive(:warn).
|
|
379
|
-
with(/directory is already being watched/)
|
|
380
|
-
|
|
381
|
-
record.build
|
|
382
|
-
# expect { record.build }.
|
|
383
|
-
# to raise_error(RuntimeError, /Failed due to looped symlinks/)
|
|
384
|
-
end
|
|
385
|
-
end
|
|
386
|
-
|
|
387
|
-
context 'with a normal symlinked directory to another' do
|
|
388
|
-
subject { record.paths }
|
|
389
|
-
|
|
390
|
-
before do
|
|
391
|
-
real_directory('/dir' => %w[dir1])
|
|
392
|
-
real_directory('/dir/dir1' => %w[foo])
|
|
393
|
-
|
|
394
|
-
symlink('/dir/dir1/foo' => '/dir/dir2')
|
|
395
|
-
dir_entries_for('/dir/dir1/foo' => %w[bar])
|
|
396
|
-
lstat(realpath(file('/dir/dir1/foo/bar')))
|
|
397
|
-
|
|
398
|
-
real_directory('/dir/dir2' => %w[bar])
|
|
399
|
-
lstat(file('/dir/dir2/bar'))
|
|
400
|
-
end
|
|
401
|
-
|
|
402
|
-
it 'shows message' do
|
|
403
|
-
expect(STDERR).to_not receive(:puts)
|
|
404
|
-
record.build
|
|
405
|
-
end
|
|
406
|
-
end
|
|
407
|
-
|
|
408
|
-
context 'with subdir containing symlinked file' do
|
|
409
|
-
subject { record.paths }
|
|
410
|
-
before do
|
|
411
|
-
real_directory('/dir' => %w[dir1 dir2])
|
|
412
|
-
real_directory('/dir/dir1' => %w[foo])
|
|
413
|
-
lstat(file('/dir/dir1/foo'))
|
|
414
|
-
real_directory('/dir/dir2' => [])
|
|
415
|
-
end
|
|
416
|
-
|
|
417
|
-
it 'shows a warning' do
|
|
418
|
-
expect(STDERR).to_not receive(:puts)
|
|
419
|
-
|
|
420
|
-
record.build
|
|
421
|
-
end
|
|
422
|
-
end
|
|
423
|
-
end
|
|
424
|
-
end
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'listen/silencer/controller'
|
|
4
|
-
|
|
5
|
-
RSpec.describe Listen::Silencer::Controller do
|
|
6
|
-
let(:silencer) { instance_double(Listen::Silencer) }
|
|
7
|
-
|
|
8
|
-
describe 'append_ignores' do
|
|
9
|
-
context 'with no previous :ignore rules' do
|
|
10
|
-
subject do
|
|
11
|
-
described_class.new(silencer, {})
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
before do
|
|
15
|
-
allow(silencer).to receive(:configure).with({})
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
context 'when providing a nil' do
|
|
19
|
-
it 'sets the given :ignore rules as empty array' do
|
|
20
|
-
subject
|
|
21
|
-
allow(silencer).to receive(:configure).with(ignore: [])
|
|
22
|
-
subject.append_ignores(nil)
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
context 'when providing a single regexp as argument' do
|
|
27
|
-
it 'sets the given :ignore rules as array' do
|
|
28
|
-
subject
|
|
29
|
-
allow(silencer).to receive(:configure).with({ ignore: [/foo/] })
|
|
30
|
-
subject.append_ignores(/foo/)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
context 'when providing multiple arguments' do
|
|
35
|
-
it 'sets the given :ignore rules as a flat array' do
|
|
36
|
-
subject
|
|
37
|
-
allow(silencer).to receive(:configure).with({ ignore: [/foo/, /bar/] })
|
|
38
|
-
subject.append_ignores(/foo/, /bar/)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
context 'when providing as array' do
|
|
43
|
-
it 'sets the given :ignore rules' do
|
|
44
|
-
subject
|
|
45
|
-
allow(silencer).to receive(:configure).with({ ignore: [/foo/, /bar/] })
|
|
46
|
-
subject.append_ignores([/foo/, /bar/])
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
context 'with previous :ignore rules' do
|
|
52
|
-
subject do
|
|
53
|
-
described_class.new(silencer, { ignore: [/foo/, /bar/] })
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
before do
|
|
57
|
-
allow(silencer).to receive(:configure).with({ ignore: [/foo/, /bar/] })
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
context 'when providing a nil' do
|
|
61
|
-
# TODO: should this invocation maybe reset the rules?
|
|
62
|
-
it 'reconfigures with existing :ignore rules' do
|
|
63
|
-
subject
|
|
64
|
-
allow(silencer).to receive(:configure).with({ ignore: [/foo/, /bar/] })
|
|
65
|
-
subject.append_ignores(nil)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
context 'when providing a single regexp as argument' do
|
|
70
|
-
it 'appends the given :ignore rules as array' do
|
|
71
|
-
subject
|
|
72
|
-
expected = { ignore: [/foo/, /bar/, /baz/] }
|
|
73
|
-
allow(silencer).to receive(:configure).with(expected)
|
|
74
|
-
subject.append_ignores(/baz/)
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
context 'when providing multiple arguments' do
|
|
79
|
-
it 'appends the given :ignore rules as a flat array' do
|
|
80
|
-
subject
|
|
81
|
-
expected = { ignore: [/foo/, /bar/, /baz/, /bak/] }
|
|
82
|
-
allow(silencer).to receive(:configure).with(expected)
|
|
83
|
-
subject.append_ignores(/baz/, /bak/)
|
|
84
|
-
end
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
context 'when providing as array' do
|
|
88
|
-
it 'appends the given :ignore rules' do
|
|
89
|
-
subject
|
|
90
|
-
expected = { ignore: [/foo/, /bar/, /baz/, /bak/] }
|
|
91
|
-
allow(silencer).to receive(:configure).with(expected)
|
|
92
|
-
subject.append_ignores([/baz/, /bak/])
|
|
93
|
-
end
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
end
|
|
97
|
-
end
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec::Matchers.define :accept do |type, path|
|
|
4
|
-
match { |actual| !actual.silenced?(Pathname(path), type) }
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
RSpec.describe Listen::Silencer do
|
|
8
|
-
let(:options) { {} }
|
|
9
|
-
subject { described_class.new(**options) }
|
|
10
|
-
|
|
11
|
-
describe '#silenced?' do
|
|
12
|
-
it { should accept(:file, Pathname('some_dir').join("some_file.rb")) }
|
|
13
|
-
|
|
14
|
-
context 'with default ignore' do
|
|
15
|
-
hidden_ignored = %w[.git .svn .hg .rbx .bundle]
|
|
16
|
-
other_ignored = %w[bundle vendor/bundle log tmp vendor/ruby]
|
|
17
|
-
(hidden_ignored + other_ignored).each do |dir|
|
|
18
|
-
it { should_not accept(:dir, dir) }
|
|
19
|
-
it { should accept(:dir, "#{dir}foo") }
|
|
20
|
-
it { should accept(:dir, "foo#{dir}") }
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
ignored = %w[.DS_Store foo.tmp foo~]
|
|
24
|
-
|
|
25
|
-
# Gedit swap files
|
|
26
|
-
ignored += %w[.goutputstream-S3FBGX]
|
|
27
|
-
|
|
28
|
-
# Kate editor swap files
|
|
29
|
-
ignored += %w[foo.rbo54321.new foo.rbB22583.new foo.rb.kate-swp]
|
|
30
|
-
|
|
31
|
-
# Intellij swap files
|
|
32
|
-
ignored += %w[foo.rb___jb_bak___ foo.rb___jb_old___]
|
|
33
|
-
|
|
34
|
-
# Vim swap files
|
|
35
|
-
ignored += %w[foo.swp foo.swx foo.swpx 4913]
|
|
36
|
-
|
|
37
|
-
# Emacs backup/swap files
|
|
38
|
-
ignored += %w[#hello.rb# .#hello.rb]
|
|
39
|
-
|
|
40
|
-
# sed temp files
|
|
41
|
-
ignored += %w[sedq7eVAR sed86w1kB]
|
|
42
|
-
|
|
43
|
-
# mutagen temp files
|
|
44
|
-
ignored += %w[
|
|
45
|
-
.mutagen-temporary-cross-device-rename0
|
|
46
|
-
.mutagen-temporary-unicode-test-éntry0
|
|
47
|
-
]
|
|
48
|
-
|
|
49
|
-
ignored.each do |path|
|
|
50
|
-
it { should_not accept(:file, path) }
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
%w[
|
|
54
|
-
foo.tmpl file.new file54321.new a.swf 14913 49131
|
|
55
|
-
|
|
56
|
-
sed_ABCDE
|
|
57
|
-
sedabcdefg
|
|
58
|
-
.sedq7eVAR
|
|
59
|
-
foo.sedq7eVAR
|
|
60
|
-
sedatives
|
|
61
|
-
sediments
|
|
62
|
-
sedan2014
|
|
63
|
-
|
|
64
|
-
].each do |path|
|
|
65
|
-
it { should accept(:file, path) }
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
context 'when ignoring *.pid' do
|
|
70
|
-
let(:options) { { ignore: /\.pid$/ } }
|
|
71
|
-
it { should_not accept(:file, 'foo.pid') }
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
context 'when ignoring foo/bar* and *.pid' do
|
|
75
|
-
let(:options) { { ignore: [%r{^foo/bar}, /\.pid$/] } }
|
|
76
|
-
it { should_not accept(:file, 'foo/bar/baz') }
|
|
77
|
-
it { should_not accept(:file, 'foo.pid') }
|
|
78
|
-
end
|
|
79
|
-
|
|
80
|
-
context 'when ignoring only *.pid' do
|
|
81
|
-
let(:options) { { ignore!: /\.pid$/ } }
|
|
82
|
-
it { should_not accept(:file, 'foo.pid') }
|
|
83
|
-
it { should accept(:file, '.git') }
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
context 'when accepting only *foo*' do
|
|
87
|
-
let(:options) { { only: /foo/ } }
|
|
88
|
-
it { should accept(:file, 'foo') }
|
|
89
|
-
it { should_not accept(:file, 'bar') }
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
context 'when accepting only foo/* and *.txt' do
|
|
93
|
-
let(:options) { { only: [%r{^foo/}, /\.txt$/] } }
|
|
94
|
-
it { should accept(:file, 'foo/bar.rb') }
|
|
95
|
-
it { should accept(:file, 'bar.txt') }
|
|
96
|
-
it { should_not accept(:file, 'bar/baz.rb') }
|
|
97
|
-
it { should_not accept(:file, 'bar.rb') }
|
|
98
|
-
end
|
|
99
|
-
|
|
100
|
-
context 'when accepting only *.pid' do
|
|
101
|
-
context 'when ignoring bar*' do
|
|
102
|
-
let(:options) { { only: /\.pid$/, ignore: /^bar/ } }
|
|
103
|
-
it { should_not accept(:file, 'foo.rb') }
|
|
104
|
-
it { should_not accept(:file, 'bar.pid') }
|
|
105
|
-
it { should accept(:file, 'foo.pid') }
|
|
106
|
-
end
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
end
|