fluid_cli 0.1.4 → 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
- data/packaging/homebrew/fluid_cli.base.rb +5 -9
- metadata +30 -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,320 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe 'Listen', acceptance: true do
|
|
4
|
-
let(:base_options) { { latency: 0.1 } }
|
|
5
|
-
let(:polling_options) { {} }
|
|
6
|
-
let(:options) { {} }
|
|
7
|
-
let(:all_options) { base_options.merge(polling_options).merge(options) }
|
|
8
|
-
|
|
9
|
-
let(:wrapper) { setup_listener(all_options, :track_changes) }
|
|
10
|
-
|
|
11
|
-
context 'with normal start/stop' do
|
|
12
|
-
before { wrapper.listener.start }
|
|
13
|
-
after { wrapper.listener.stop }
|
|
14
|
-
|
|
15
|
-
subject { wrapper }
|
|
16
|
-
|
|
17
|
-
context 'with one listen dir' do
|
|
18
|
-
let(:paths) { Pathname.new(Dir.pwd) }
|
|
19
|
-
around { |example| fixtures { example.run } }
|
|
20
|
-
|
|
21
|
-
modes =
|
|
22
|
-
case ENV['TEST_LISTEN_ADAPTER_MODES']
|
|
23
|
-
when 'polling'
|
|
24
|
-
[true]
|
|
25
|
-
when 'native'
|
|
26
|
-
[false]
|
|
27
|
-
else
|
|
28
|
-
[false, true]
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
# TODO: make it configurable
|
|
32
|
-
# TODO: restore
|
|
33
|
-
modes.each do |polling|
|
|
34
|
-
context "force_polling option to #{polling}" do
|
|
35
|
-
let(:polling_options) { { force_polling: polling } }
|
|
36
|
-
|
|
37
|
-
if polling
|
|
38
|
-
context 'when polling' do
|
|
39
|
-
context 'with a large latency' do
|
|
40
|
-
let(:options) { { latency: 10 } }
|
|
41
|
-
it 'passes the latency option correctly' do
|
|
42
|
-
expect(subject).to_not process_addition_of('file.rb')
|
|
43
|
-
end
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
else
|
|
47
|
-
unless darwin?
|
|
48
|
-
context 'when driver does not support option' do
|
|
49
|
-
let(:options) { { latency: 10 } }
|
|
50
|
-
it 'does not pass the latency option' do
|
|
51
|
-
expect(subject).to process_addition_of('file.rb')
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
context 'with default ignore options' do
|
|
58
|
-
context 'with nothing in listen dir' do
|
|
59
|
-
it { is_expected.to process_addition_of('file.rb') }
|
|
60
|
-
it { is_expected.to process_addition_of('.hidden') }
|
|
61
|
-
|
|
62
|
-
it 'listens to multiple files addition' do
|
|
63
|
-
result = wrapper.listen do
|
|
64
|
-
change_fs(:added, 'file1.rb')
|
|
65
|
-
change_fs(:added, 'file2.rb')
|
|
66
|
-
end
|
|
67
|
-
|
|
68
|
-
expect(result).to eq(modified: [],
|
|
69
|
-
added: %w[file1.rb file2.rb],
|
|
70
|
-
removed: [])
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it 'listens to file moved inside' do
|
|
74
|
-
touch '../file.rb'
|
|
75
|
-
expect(wrapper.listen do
|
|
76
|
-
mv '../file.rb', 'file.rb'
|
|
77
|
-
end).to eq(modified: [], added: ['file.rb'], removed: [])
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
context 'existing file.rb in listen dir' do
|
|
82
|
-
around do |example|
|
|
83
|
-
change_fs(:added, 'file.rb')
|
|
84
|
-
example.run
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
it { is_expected.to process_modification_of('file.rb') }
|
|
88
|
-
it { is_expected.to process_removal_of('file.rb') }
|
|
89
|
-
|
|
90
|
-
it 'listens to file.rb moved out' do
|
|
91
|
-
expect(wrapper.listen do
|
|
92
|
-
mv 'file.rb', '../file.rb'
|
|
93
|
-
end).to eq(modified: [], added: [], removed: ['file.rb'])
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
it 'listens to file mode change' do
|
|
97
|
-
prev_mode = File.stat('file.rb').mode
|
|
98
|
-
|
|
99
|
-
result = wrapper.listen do
|
|
100
|
-
windows? ? `attrib +r file.rb` : chmod(0444, 'file.rb')
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
new_mode = File.stat('file.rb').mode
|
|
104
|
-
no_event = result[:modified].empty? && prev_mode == new_mode
|
|
105
|
-
|
|
106
|
-
# Check if chmod actually works or an attrib event happens,
|
|
107
|
-
# or expect nothing otherwise
|
|
108
|
-
#
|
|
109
|
-
# (e.g. fails for polling+vfat on Linux, but works with
|
|
110
|
-
# INotify+vfat because you get an event regardless if mode
|
|
111
|
-
# actually changes)
|
|
112
|
-
#
|
|
113
|
-
files = no_event ? [] : ['file.rb']
|
|
114
|
-
|
|
115
|
-
expect(result).to eq(modified: files, added: [], removed: [])
|
|
116
|
-
end
|
|
117
|
-
end
|
|
118
|
-
|
|
119
|
-
context 'hidden file in listen dir' do
|
|
120
|
-
around do |example|
|
|
121
|
-
change_fs(:added, '.hidden')
|
|
122
|
-
example.run
|
|
123
|
-
end
|
|
124
|
-
|
|
125
|
-
it { is_expected.to process_modification_of('.hidden') }
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
context 'dir in listen dir' do
|
|
129
|
-
around do |example|
|
|
130
|
-
mkdir_p 'dir'
|
|
131
|
-
example.run
|
|
132
|
-
end
|
|
133
|
-
|
|
134
|
-
it { is_expected.to process_addition_of('dir/file.rb') }
|
|
135
|
-
end
|
|
136
|
-
|
|
137
|
-
context 'dir with file in listen dir' do
|
|
138
|
-
around do |example|
|
|
139
|
-
mkdir_p 'dir'
|
|
140
|
-
touch 'dir/file.rb'
|
|
141
|
-
example.run
|
|
142
|
-
end
|
|
143
|
-
|
|
144
|
-
it 'listens to file move' do
|
|
145
|
-
expected = { modified: [],
|
|
146
|
-
added: %w[file.rb],
|
|
147
|
-
removed: %w[dir/file.rb] }
|
|
148
|
-
|
|
149
|
-
expect(wrapper.listen do
|
|
150
|
-
mv 'dir/file.rb', 'file.rb'
|
|
151
|
-
end).to eq expected
|
|
152
|
-
end
|
|
153
|
-
end
|
|
154
|
-
|
|
155
|
-
context 'two dirs with files in listen dir' do
|
|
156
|
-
around do |example|
|
|
157
|
-
mkdir_p 'dir1'
|
|
158
|
-
touch 'dir1/file1.rb'
|
|
159
|
-
mkdir_p 'dir2'
|
|
160
|
-
touch 'dir2/file2.rb'
|
|
161
|
-
example.run
|
|
162
|
-
end
|
|
163
|
-
|
|
164
|
-
it 'listens to multiple file moves' do
|
|
165
|
-
expected = {
|
|
166
|
-
modified: [],
|
|
167
|
-
added: ['dir1/file2.rb', 'dir2/file1.rb'],
|
|
168
|
-
removed: ['dir1/file1.rb', 'dir2/file2.rb']
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
expect(wrapper.listen do
|
|
172
|
-
mv 'dir1/file1.rb', 'dir2/file1.rb'
|
|
173
|
-
mv 'dir2/file2.rb', 'dir1/file2.rb'
|
|
174
|
-
end).to eq expected
|
|
175
|
-
end
|
|
176
|
-
|
|
177
|
-
it 'listens to dir move' do
|
|
178
|
-
expected = { modified: [],
|
|
179
|
-
added: ['dir2/dir1/file1.rb'],
|
|
180
|
-
removed: ['dir1/file1.rb'] }
|
|
181
|
-
|
|
182
|
-
expect(wrapper.listen do
|
|
183
|
-
mv 'dir1', 'dir2/'
|
|
184
|
-
end).to eq expected
|
|
185
|
-
end
|
|
186
|
-
end
|
|
187
|
-
|
|
188
|
-
context 'listens to subdirectory removed' do
|
|
189
|
-
around do |example|
|
|
190
|
-
mkdir_p 'dir1'
|
|
191
|
-
mkdir_p 'dir1/subdir1'
|
|
192
|
-
mkdir_p 'dir1/subdir1/subdir2'
|
|
193
|
-
touch 'dir1/subdir1/file.rb'
|
|
194
|
-
touch 'dir1/subdir1/subdir2/file.rb'
|
|
195
|
-
example.run
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
it 'listen to the files of a removed directory' do
|
|
199
|
-
expected = {
|
|
200
|
-
modified: [],
|
|
201
|
-
added: [],
|
|
202
|
-
removed: %w[dir1/subdir1/file.rb dir1/subdir1/subdir2/file.rb]
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
expect(wrapper.listen do
|
|
206
|
-
rm_rf 'dir1'
|
|
207
|
-
end).to eq expected
|
|
208
|
-
end
|
|
209
|
-
end
|
|
210
|
-
|
|
211
|
-
context 'listens to sub-subdirectory removed' do
|
|
212
|
-
around do |example|
|
|
213
|
-
mkdir_p 'dir1'
|
|
214
|
-
mkdir_p 'dir1/subdir1'
|
|
215
|
-
mkdir_p 'dir1/subdir1/subdir2'
|
|
216
|
-
touch 'dir1/subdir1/file.rb'
|
|
217
|
-
touch 'dir1/subdir1/subdir2/file.rb'
|
|
218
|
-
example.run
|
|
219
|
-
end
|
|
220
|
-
|
|
221
|
-
it 'listen to the files of a removed directory' do
|
|
222
|
-
expected = {
|
|
223
|
-
modified: [],
|
|
224
|
-
added: [],
|
|
225
|
-
removed: %w[dir1/subdir1/file.rb dir1/subdir1/subdir2/file.rb]
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
expect(wrapper.listen do
|
|
229
|
-
rm_rf 'dir1/subdir1'
|
|
230
|
-
end).to eq expected
|
|
231
|
-
end
|
|
232
|
-
end
|
|
233
|
-
|
|
234
|
-
context 'with .bundle dir ignored by default' do
|
|
235
|
-
around do |example|
|
|
236
|
-
mkdir_p '.bundle'
|
|
237
|
-
example.run
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
it { is_expected.not_to process_addition_of('.bundle/file.rb') }
|
|
241
|
-
end
|
|
242
|
-
end
|
|
243
|
-
|
|
244
|
-
context 'when :ignore is *ignored_dir*' do
|
|
245
|
-
context 'ignored dir with file in listen dir' do
|
|
246
|
-
let(:options) { { ignore: /ignored_dir/ } }
|
|
247
|
-
|
|
248
|
-
around do |example|
|
|
249
|
-
mkdir_p 'ignored_dir'
|
|
250
|
-
example.run
|
|
251
|
-
end
|
|
252
|
-
|
|
253
|
-
it { is_expected.not_to process_addition_of('ignored_dir/file.rb') }
|
|
254
|
-
end
|
|
255
|
-
|
|
256
|
-
context 'when :only is *.rb' do
|
|
257
|
-
let(:options) { { only: /\.rb$/ } }
|
|
258
|
-
|
|
259
|
-
it { is_expected.to process_addition_of('file.rb') }
|
|
260
|
-
it { is_expected.not_to process_addition_of('file.txt') }
|
|
261
|
-
end
|
|
262
|
-
|
|
263
|
-
context 'when :ignore is bar.rb' do
|
|
264
|
-
context 'when :only is *.rb' do
|
|
265
|
-
let(:options) { { ignore: /bar\.rb$/, only: /\.rb$/ } }
|
|
266
|
-
|
|
267
|
-
it { is_expected.to process_addition_of('file.rb') }
|
|
268
|
-
it { is_expected.not_to process_addition_of('file.txt') }
|
|
269
|
-
it { is_expected.not_to process_addition_of('bar.rb') }
|
|
270
|
-
end
|
|
271
|
-
end
|
|
272
|
-
|
|
273
|
-
context 'when default ignore is *.rb' do
|
|
274
|
-
let(:options) { { ignore: /\.rb$/ } }
|
|
275
|
-
|
|
276
|
-
it { is_expected.not_to process_addition_of('file.rb') }
|
|
277
|
-
|
|
278
|
-
context 'with #ignore on *.txt mask' do
|
|
279
|
-
before { wrapper.listener.ignore(/\.txt/) }
|
|
280
|
-
|
|
281
|
-
it { is_expected.not_to process_addition_of('file.rb') }
|
|
282
|
-
it { is_expected.not_to process_addition_of('file.txt') }
|
|
283
|
-
end
|
|
284
|
-
|
|
285
|
-
context 'with #ignore! on *.txt mask' do
|
|
286
|
-
before { wrapper.listener.ignore!(/\.txt/) }
|
|
287
|
-
|
|
288
|
-
it { is_expected.to process_addition_of('file.rb') }
|
|
289
|
-
it { is_expected.not_to process_addition_of('file.txt') }
|
|
290
|
-
end
|
|
291
|
-
end
|
|
292
|
-
end
|
|
293
|
-
end
|
|
294
|
-
end
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
context 'with paths set' do
|
|
298
|
-
let(:paths) { Pathname.new(Dir.pwd) }
|
|
299
|
-
|
|
300
|
-
it 'allows extra calls to stop' do
|
|
301
|
-
wrapper.listener.stop
|
|
302
|
-
wrapper.listener.stop
|
|
303
|
-
end
|
|
304
|
-
end
|
|
305
|
-
end
|
|
306
|
-
|
|
307
|
-
context 'when never started' do
|
|
308
|
-
let(:paths) { Pathname.new(Dir.pwd) }
|
|
309
|
-
|
|
310
|
-
it 'allows stop' do
|
|
311
|
-
wrapper.listener.stop
|
|
312
|
-
end
|
|
313
|
-
|
|
314
|
-
it 'extra calls to stop' do
|
|
315
|
-
wrapper.listener.stop
|
|
316
|
-
wrapper.listener.stop
|
|
317
|
-
wrapper.listener.stop
|
|
318
|
-
end
|
|
319
|
-
end
|
|
320
|
-
end
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
RSpec.describe Listen::Adapter::Base do
|
|
4
|
-
class FakeAdapter < described_class
|
|
5
|
-
def initialize(config)
|
|
6
|
-
@my_callbacks = {}
|
|
7
|
-
super
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def _run
|
|
11
|
-
fail NotImplementedError
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def _configure(dir, &callback)
|
|
15
|
-
@my_callbacks[dir.to_s] = callback
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def fake_event(event)
|
|
19
|
-
dir = event[:dir]
|
|
20
|
-
@my_callbacks[dir].call(event)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def _process_event(dir, event)
|
|
24
|
-
_queue_change(:file, dir, event[:file], cookie: event[:cookie])
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
let(:thread) { instance_double(Thread, "thread") }
|
|
29
|
-
let(:dir1) { instance_double(Pathname, 'dir1', to_s: '/foo/dir1') }
|
|
30
|
-
|
|
31
|
-
let(:config) { instance_double(Listen::Adapter::Config) }
|
|
32
|
-
let(:queue) { instance_double(Queue) }
|
|
33
|
-
let(:silencer) { instance_double(Listen::Silencer) }
|
|
34
|
-
let(:adapter_options) { {} }
|
|
35
|
-
|
|
36
|
-
let(:snapshot) { instance_double(Listen::Change) }
|
|
37
|
-
let(:record) { instance_double(Listen::Record) }
|
|
38
|
-
|
|
39
|
-
subject { FakeAdapter.new(config) }
|
|
40
|
-
|
|
41
|
-
before do
|
|
42
|
-
allow(config).to receive(:directories).and_return([dir1])
|
|
43
|
-
allow(config).to receive(:queue).and_return(queue)
|
|
44
|
-
allow(config).to receive(:silencer).and_return(silencer)
|
|
45
|
-
allow(config).to receive(:adapter_options).and_return(adapter_options)
|
|
46
|
-
|
|
47
|
-
allow(Thread).to receive(:new) do |&block|
|
|
48
|
-
block.call
|
|
49
|
-
allow(thread).to receive(:name=)
|
|
50
|
-
thread
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
# Stuff that happens in configure()
|
|
54
|
-
allow(Listen::Record).to receive(:new).with(dir1, silencer).and_return(record)
|
|
55
|
-
|
|
56
|
-
allow(Listen::Change::Config).to receive(:new).with(queue, silencer).
|
|
57
|
-
and_return(config)
|
|
58
|
-
|
|
59
|
-
allow(Listen::Change).to receive(:new).with(config, record).
|
|
60
|
-
and_return(snapshot)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
describe '#start' do
|
|
64
|
-
before do
|
|
65
|
-
allow(subject).to receive(:_run)
|
|
66
|
-
|
|
67
|
-
allow(snapshot).to receive(:record).and_return(record)
|
|
68
|
-
allow(record).to receive(:build)
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
it 'builds record' do
|
|
72
|
-
expect(record).to receive(:build)
|
|
73
|
-
subject.start
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
it 'runs the adapter' do
|
|
77
|
-
expect(subject).to receive(:_run)
|
|
78
|
-
subject.start
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
describe 'handling events' do
|
|
83
|
-
before do
|
|
84
|
-
allow(subject).to receive(:_run)
|
|
85
|
-
|
|
86
|
-
allow(snapshot).to receive(:record).and_return(record)
|
|
87
|
-
allow(record).to receive(:build)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
context 'when an event occurs' do
|
|
91
|
-
it 'passes invalidates the snapshot based on the event' do
|
|
92
|
-
subject.start
|
|
93
|
-
|
|
94
|
-
expect(snapshot).to receive(:invalidate).with(:file, 'bar', { cookie: 3 })
|
|
95
|
-
|
|
96
|
-
event = { dir: '/foo/dir1', file: 'bar', type: :moved, cookie: 3 }
|
|
97
|
-
subject.fake_event(event)
|
|
98
|
-
end
|
|
99
|
-
end
|
|
100
|
-
end
|
|
101
|
-
end
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
require 'listen/adapter/config'
|
|
4
|
-
|
|
5
|
-
RSpec.describe Listen::Adapter::Config do
|
|
6
|
-
let(:directories) { [path1, path2] }
|
|
7
|
-
let(:queue) { instance_double(Queue) }
|
|
8
|
-
let(:silencer) { instance_double(Listen::Silencer) }
|
|
9
|
-
|
|
10
|
-
# NOTE: defaults are handled later in Listen::Options
|
|
11
|
-
let(:adapter_options) { { latency: 1.234 } }
|
|
12
|
-
|
|
13
|
-
subject do
|
|
14
|
-
described_class.new(directories, queue, silencer, adapter_options)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Here's what may be passed to initializer
|
|
18
|
-
let(:path1) { fake_path('/real/path1', realpath: real_path1) }
|
|
19
|
-
let(:path2) { fake_path('/real/path2', realpath: real_path2) }
|
|
20
|
-
let(:path3) { fake_path('/real/path3', realpath: real_path3) }
|
|
21
|
-
|
|
22
|
-
let(:current_path) do
|
|
23
|
-
fake_path('/real/current_path', realpath: real_current_path)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
let(:symlinked_dir1) { fake_path('symlinked_dir1', realpath: real_path1) }
|
|
27
|
-
let(:symlinked_dir2) { fake_path('symlinked_dir1', realpath: real_path2) }
|
|
28
|
-
|
|
29
|
-
# Here's what expected to be returned (just so that realpath() calls return
|
|
30
|
-
# something useful)
|
|
31
|
-
let(:real_path1) { fake_path('/real/path1') }
|
|
32
|
-
let(:real_path2) { fake_path('/real/path2') }
|
|
33
|
-
let(:real_path3) { fake_path('/real/path3', directory?: false) }
|
|
34
|
-
let(:real_current_path) { fake_path('/real/current_path') }
|
|
35
|
-
|
|
36
|
-
before do
|
|
37
|
-
allow(Pathname).to receive(:new) do |*args|
|
|
38
|
-
fail "unstubbed Pathname.new(#{args.map(&:inspect) * ','})"
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
allow(Pathname).to receive(:new).with('/real/path1').and_return(path1)
|
|
42
|
-
allow(Pathname).to receive(:new).with('/real/path2').and_return(path2)
|
|
43
|
-
allow(Pathname).to receive(:new).with('/real/path3').and_return(path3)
|
|
44
|
-
|
|
45
|
-
allow(Pathname).to receive(:new).with(path1).and_return(path1)
|
|
46
|
-
allow(Pathname).to receive(:new).with(path2).and_return(path2)
|
|
47
|
-
|
|
48
|
-
allow(Pathname).to receive(:new).with('symlinked_dir1').
|
|
49
|
-
and_return(symlinked_dir1)
|
|
50
|
-
|
|
51
|
-
allow(Pathname).to receive(:new).with('symlinked_dir2').
|
|
52
|
-
and_return(symlinked_dir2)
|
|
53
|
-
|
|
54
|
-
allow(Dir).to receive(:pwd).and_return('/real/current_path')
|
|
55
|
-
|
|
56
|
-
allow(Pathname).to receive(:new).
|
|
57
|
-
with('/real/current_path').and_return(current_path)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
describe '#initialize' do
|
|
61
|
-
context 'with directories as array' do
|
|
62
|
-
context 'with strings for directories' do
|
|
63
|
-
context 'when already resolved' do
|
|
64
|
-
let(:directories) { ['/real/path1', '/real/path2'] }
|
|
65
|
-
it 'returns array of pathnames' do
|
|
66
|
-
expect(subject.directories).to eq([real_path1, real_path2])
|
|
67
|
-
end
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
context 'when not resolved' do
|
|
71
|
-
let(:directories) { %w[symlinked_dir1 symlinked_dir2] }
|
|
72
|
-
it 'returns array of resolved pathnames' do
|
|
73
|
-
expect(subject.directories).to eq([real_path1, real_path2])
|
|
74
|
-
end
|
|
75
|
-
end
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
context 'with Pathnames for directories' do
|
|
79
|
-
let(:directories) { [path1, path2] }
|
|
80
|
-
it 'returns array of pathnames' do
|
|
81
|
-
expect(subject.directories).to eq([real_path1, real_path2])
|
|
82
|
-
end
|
|
83
|
-
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
context 'with directories as messy array' do
|
|
87
|
-
pending 'implement me'
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
context 'with no directories' do
|
|
91
|
-
let(:directories) { }
|
|
92
|
-
it 'returns the current path in array' do
|
|
93
|
-
expect(subject.directories).to eq([real_current_path])
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
context 'with file path' do
|
|
98
|
-
let(:directories) { ['/real/path3'] }
|
|
99
|
-
it 'raises argument error requesting a directory' do
|
|
100
|
-
expect { subject }.to raise_error(ArgumentError, /must be a directory/)
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
describe '#adapter_options' do
|
|
106
|
-
it 'provides a set of adapter_specific options' do
|
|
107
|
-
expect(subject.adapter_options).to eq(latency: 1.234)
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
describe '#queue' do
|
|
112
|
-
it 'provides a direct queue for filesystem events' do
|
|
113
|
-
expect(subject.queue).to eq(queue)
|
|
114
|
-
end
|
|
115
|
-
end
|
|
116
|
-
|
|
117
|
-
describe '#silencer' do
|
|
118
|
-
it 'provides a silencer object' do
|
|
119
|
-
expect(subject.silencer).to eq(silencer)
|
|
120
|
-
end
|
|
121
|
-
end
|
|
122
|
-
end
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
# This is just so stubs work
|
|
4
|
-
require 'rb-fsevent'
|
|
5
|
-
|
|
6
|
-
require 'listen/adapter/darwin'
|
|
7
|
-
|
|
8
|
-
include Listen
|
|
9
|
-
|
|
10
|
-
RSpec.describe Adapter::Darwin do
|
|
11
|
-
describe 'class' do
|
|
12
|
-
subject { described_class }
|
|
13
|
-
|
|
14
|
-
context 'on darwin 13.0 (OS X Mavericks)' do
|
|
15
|
-
before do
|
|
16
|
-
allow(RbConfig::CONFIG).to receive(:[]).and_return('darwin13.0')
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
it { should be_usable }
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
context 'on darwin20 (macOS Big Sur)' do
|
|
23
|
-
before do
|
|
24
|
-
allow(RbConfig::CONFIG).to receive(:[]).and_return('darwin20')
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it { should be_usable }
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
context 'on darwin10.0 (OS X Snow Leopard)' do
|
|
31
|
-
before do
|
|
32
|
-
allow(RbConfig::CONFIG).to receive(:[]).and_return('darwin10.0')
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
context 'with rb-fsevent > 0.9.4' do
|
|
36
|
-
before { stub_const('FSEvent::VERSION', '0.9.6') }
|
|
37
|
-
it 'shows a warning and should not be usable' do
|
|
38
|
-
expect(Listen).to receive(:adapter_warn)
|
|
39
|
-
expect(subject).to_not be_usable
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
context 'with rb-fsevent <= 0.9.4' do
|
|
44
|
-
before { stub_const('FSEvent::VERSION', '0.9.4') }
|
|
45
|
-
it { should be_usable }
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
context 'on another platform (linux)' do
|
|
50
|
-
before { allow(RbConfig::CONFIG).to receive(:[]).and_return('linux') }
|
|
51
|
-
it { should_not be_usable }
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
let(:options) { {} }
|
|
56
|
-
let(:config) { instance_double(Listen::Adapter::Config) }
|
|
57
|
-
let(:queue) { instance_double(::Queue) }
|
|
58
|
-
let(:silencer) { instance_double(Listen::Silencer) }
|
|
59
|
-
|
|
60
|
-
let(:dir1) { fake_path('/foo/dir1', cleanpath: fake_path('/foo/dir1')) }
|
|
61
|
-
let(:directories) { [dir1] }
|
|
62
|
-
|
|
63
|
-
subject { described_class.new(config) }
|
|
64
|
-
|
|
65
|
-
before do
|
|
66
|
-
allow(config).to receive(:directories).and_return(directories)
|
|
67
|
-
allow(config).to receive(:adapter_options).and_return(options)
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
describe '#_latency' do
|
|
71
|
-
subject { described_class.new(config).options.latency }
|
|
72
|
-
|
|
73
|
-
context 'with no overriding option' do
|
|
74
|
-
it { should eq 0.1 }
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
context 'with custom latency overriding' do
|
|
78
|
-
let(:options) { { latency: 1234 } }
|
|
79
|
-
it { should eq 1234 }
|
|
80
|
-
end
|
|
81
|
-
end
|
|
82
|
-
end
|