sass 3.4.25 → 3.5.0

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.
Files changed (135) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/Rakefile +2 -117
  4. data/VERSION +1 -1
  5. data/VERSION_DATE +1 -1
  6. data/VERSION_NAME +1 -1
  7. data/lib/sass/cache_stores/filesystem.rb +1 -1
  8. data/lib/sass/css.rb +1 -2
  9. data/lib/sass/engine.rb +38 -20
  10. data/lib/sass/environment.rb +26 -5
  11. data/lib/sass/error.rb +2 -2
  12. data/lib/sass/exec/base.rb +2 -11
  13. data/lib/sass/features.rb +1 -0
  14. data/lib/sass/importers/filesystem.rb +2 -2
  15. data/lib/sass/plugin/compiler.rb +20 -50
  16. data/lib/sass/plugin/configuration.rb +2 -2
  17. data/lib/sass/railtie.rb +1 -1
  18. data/lib/sass/script/functions.rb +235 -43
  19. data/lib/sass/script/lexer.rb +13 -2
  20. data/lib/sass/script/parser.rb +69 -67
  21. data/lib/sass/script/tree/funcall.rb +35 -30
  22. data/lib/sass/script/tree/list_literal.rb +23 -8
  23. data/lib/sass/script/tree/map_literal.rb +2 -2
  24. data/lib/sass/script/tree/node.rb +0 -8
  25. data/lib/sass/script/tree/operation.rb +0 -7
  26. data/lib/sass/script/value/arg_list.rb +1 -1
  27. data/lib/sass/script/value/base.rb +17 -0
  28. data/lib/sass/script/value/callable.rb +25 -0
  29. data/lib/sass/script/value/color.rb +5 -0
  30. data/lib/sass/script/value/function.rb +19 -0
  31. data/lib/sass/script/value/helpers.rb +29 -9
  32. data/lib/sass/script/value/list.rb +35 -14
  33. data/lib/sass/script/value/map.rb +2 -2
  34. data/lib/sass/script/value/number.rb +1 -1
  35. data/lib/sass/script/value.rb +2 -0
  36. data/lib/sass/scss/parser.rb +99 -40
  37. data/lib/sass/scss/rx.rb +4 -10
  38. data/lib/sass/scss/static_parser.rb +5 -24
  39. data/lib/sass/selector/abstract_sequence.rb +7 -6
  40. data/lib/sass/selector/comma_sequence.rb +7 -4
  41. data/lib/sass/selector/pseudo.rb +19 -2
  42. data/lib/sass/selector/sequence.rb +35 -6
  43. data/lib/sass/selector/simple.rb +9 -2
  44. data/lib/sass/selector/simple_sequence.rb +8 -4
  45. data/lib/sass/selector.rb +4 -0
  46. data/lib/sass/source/map.rb +2 -2
  47. data/lib/sass/stack.rb +21 -1
  48. data/lib/sass/tree/charset_node.rb +1 -1
  49. data/lib/sass/tree/prop_node.rb +45 -53
  50. data/lib/sass/tree/rule_node.rb +3 -2
  51. data/lib/sass/tree/visitors/check_nesting.rb +1 -1
  52. data/lib/sass/tree/visitors/convert.rb +2 -3
  53. data/lib/sass/tree/visitors/cssize.rb +4 -15
  54. data/lib/sass/tree/visitors/deep_copy.rb +1 -1
  55. data/lib/sass/tree/visitors/extend.rb +2 -8
  56. data/lib/sass/tree/visitors/perform.rb +21 -9
  57. data/lib/sass/tree/visitors/set_options.rb +1 -1
  58. data/lib/sass/tree/visitors/to_css.rb +47 -13
  59. data/lib/sass/util/multibyte_string_scanner.rb +127 -131
  60. data/lib/sass/util/normalized_map.rb +1 -8
  61. data/lib/sass/util.rb +12 -290
  62. data/lib/sass/version.rb +0 -2
  63. data/lib/sass.rb +0 -7
  64. data/test/sass/cache_test.rb +0 -1
  65. data/test/sass/callbacks_test.rb +0 -1
  66. data/test/sass/compiler_test.rb +4 -15
  67. data/test/sass/conversion_test.rb +113 -163
  68. data/test/sass/css2sass_test.rb +16 -19
  69. data/test/sass/css_variable_test.rb +176 -71
  70. data/test/sass/encoding_test.rb +2 -33
  71. data/test/sass/engine_test.rb +71 -19
  72. data/test/sass/exec_test.rb +0 -1
  73. data/test/sass/extend_test.rb +37 -92
  74. data/test/sass/functions_test.rb +58 -14
  75. data/test/sass/importer_test.rb +2 -3
  76. data/test/sass/logger_test.rb +0 -1
  77. data/test/sass/plugin_test.rb +6 -10
  78. data/test/sass/results/script.css +1 -1
  79. data/test/sass/results/units.css +2 -2
  80. data/test/sass/script_conversion_test.rb +10 -2
  81. data/test/sass/script_test.rb +22 -24
  82. data/test/sass/scss/css_test.rb +3 -18
  83. data/test/sass/scss/rx_test.rb +0 -1
  84. data/test/sass/scss/scss_test.rb +49 -16
  85. data/test/sass/source_map_test.rb +13 -16
  86. data/test/sass/superselector_test.rb +0 -1
  87. data/test/sass/util/multibyte_string_scanner_test.rb +121 -124
  88. data/test/sass/util/normalized_map_test.rb +0 -1
  89. data/test/sass/util/subset_map_test.rb +0 -1
  90. data/test/sass/util_test.rb +4 -39
  91. data/test/sass/value_helpers_test.rb +0 -1
  92. data/test/sass-spec.yml +1 -1
  93. data/test/test_helper.rb +39 -0
  94. metadata +19 -44
  95. data/lib/sass/script/css_variable_warning.rb +0 -52
  96. data/lib/sass/util/cross_platform_random.rb +0 -19
  97. data/lib/sass/util/ordered_hash.rb +0 -192
  98. data/test/sass/results/import_charset_1_8.css +0 -5
  99. data/test/sass/templates/import_charset_1_8.sass +0 -6
  100. data/vendor/listen/CHANGELOG.md +0 -1
  101. data/vendor/listen/CONTRIBUTING.md +0 -38
  102. data/vendor/listen/Gemfile +0 -20
  103. data/vendor/listen/Guardfile +0 -8
  104. data/vendor/listen/LICENSE +0 -20
  105. data/vendor/listen/README.md +0 -349
  106. data/vendor/listen/Rakefile +0 -5
  107. data/vendor/listen/Vagrantfile +0 -96
  108. data/vendor/listen/lib/listen/adapter.rb +0 -327
  109. data/vendor/listen/lib/listen/adapters/bsd.rb +0 -75
  110. data/vendor/listen/lib/listen/adapters/darwin.rb +0 -48
  111. data/vendor/listen/lib/listen/adapters/linux.rb +0 -81
  112. data/vendor/listen/lib/listen/adapters/polling.rb +0 -58
  113. data/vendor/listen/lib/listen/adapters/windows.rb +0 -91
  114. data/vendor/listen/lib/listen/directory_record.rb +0 -406
  115. data/vendor/listen/lib/listen/listener.rb +0 -323
  116. data/vendor/listen/lib/listen/turnstile.rb +0 -32
  117. data/vendor/listen/lib/listen/version.rb +0 -3
  118. data/vendor/listen/lib/listen.rb +0 -54
  119. data/vendor/listen/listen.gemspec +0 -28
  120. data/vendor/listen/spec/listen/adapter_spec.rb +0 -149
  121. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +0 -36
  122. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -37
  123. data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -47
  124. data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
  125. data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -30
  126. data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1250
  127. data/vendor/listen/spec/listen/listener_spec.rb +0 -258
  128. data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
  129. data/vendor/listen/spec/listen_spec.rb +0 -67
  130. data/vendor/listen/spec/spec_helper.rb +0 -25
  131. data/vendor/listen/spec/support/adapter_helper.rb +0 -666
  132. data/vendor/listen/spec/support/directory_record_helper.rb +0 -57
  133. data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
  134. data/vendor/listen/spec/support/listeners_helper.rb +0 -179
  135. data/vendor/listen/spec/support/platform_helper.rb +0 -15
@@ -1,666 +0,0 @@
1
- # Adapter watch
2
- #
3
- # @param [Listen::Listener] listener the adapter listener
4
- # @param [String] path the path to watch
5
- #
6
- def watch(listener, expected_changes, *paths)
7
- sleep 0.05 # allow file/creation to be done (!)
8
-
9
- callback = lambda do |changed_directories, options|
10
- @called = true
11
- listener.on_change(changed_directories)
12
- end
13
- @adapter = Listen::Adapter.select_and_initialize(paths, { :latency => test_latency }, &callback)
14
- @adapter.stub(:start_poller) { nil }
15
-
16
- forced_stop = false
17
- prevent_deadlock = lambda do
18
- sleep(10)
19
- puts 'Forcing stop'
20
- @adapter.stop
21
- forced_stop = true
22
- end
23
-
24
- @adapter.start
25
-
26
- yield
27
-
28
- t = Thread.new(&prevent_deadlock)
29
- @adapter.wait_for_changes(expected_changes)
30
-
31
- unless forced_stop
32
- Thread.kill(t)
33
- @adapter.report_changes
34
- end
35
- ensure
36
- unless forced_stop
37
- Thread.kill(t) if t
38
- @adapter.stop
39
- end
40
- end
41
-
42
- shared_examples_for 'a filesystem adapter' do
43
- subject { described_class.new(File.dirname(__FILE__), &Proc.new {}) }
44
-
45
- describe '#start' do
46
- before { Kernel.stub(:warn) }
47
- after { subject.stop }
48
-
49
- it 'do not block the current thread after starting the workers' do
50
- @called = false
51
- t = Thread.new { subject.start; @called = true }
52
- sleep(test_latency * 3)
53
- Thread.kill(t) if t
54
- @called.should be_true
55
- end
56
-
57
- context 'with the blocking hash option set to false' do
58
- subject { described_class.new(File.dirname(__FILE__), { :blocking => false }, &Proc.new {}) }
59
-
60
- it 'does not block the current thread after starting the workers' do
61
- @called = false
62
- t = Thread.new { subject.start; @called = true }
63
- sleep(test_latency * 3)
64
- Thread.kill(t) if t
65
- @called.should be_true
66
- end
67
- end
68
- end
69
-
70
- describe '#start!' do
71
- before { Kernel.stub(:warn) }
72
- after { subject.stop }
73
-
74
- it 'blocks the current thread after starting the workers' do
75
- @called = false
76
- t = Thread.new { subject.start!; @called = true }
77
- sleep(test_latency * 3)
78
- Thread.kill(t) if t
79
- @called.should be_false
80
- end
81
-
82
- context 'with the blocking hash option set to false' do
83
- subject { described_class.new(File.dirname(__FILE__), { :blocking => true }, &Proc.new {}) }
84
-
85
- it 'blocks the current thread after starting the workers' do
86
- @called = false
87
- t = Thread.new { subject.start!; @called = true }
88
- sleep(test_latency * 3)
89
- Thread.kill(t) if t
90
- @called.should be_false
91
- end
92
- end
93
- end
94
-
95
- describe '#started?' do
96
- context 'with a new adapter' do
97
- it 'returns false' do
98
- subject.should_not be_started
99
- end
100
- end
101
-
102
- context 'with a stopped adapter' do
103
- before { subject.start; subject.stop }
104
-
105
- it 'returns false' do
106
- subject.should_not be_started
107
- end
108
- end
109
-
110
- context 'with a started adapter' do
111
- before { subject.start }
112
- after { subject.stop }
113
-
114
- it 'returns true' do
115
- subject.should be_started
116
- end
117
- end
118
- end
119
- end
120
-
121
- shared_examples_for 'an adapter that call properly listener#on_change' do |*args|
122
- options = (args.first && args.first.is_a?(Hash)) ? args.first : {}
123
- let(:listener) { double(Listen::Listener) }
124
- before { described_class.stub(:works?) { true } }
125
-
126
- context 'single file operations' do
127
- context 'when a file is created' do
128
- it 'detects the added file' do
129
- fixtures do |path|
130
- listener.should_receive(:on_change).once.with do |array|
131
- array.should include(path)
132
- end
133
-
134
- watch(listener, 1, path) do
135
- touch 'new_file.rb'
136
- end
137
- end
138
- end
139
-
140
- context 'given a symlink', :unless => windows? do
141
- it 'detects the added file' do
142
- fixtures do |path|
143
- listener.should_receive(:on_change).once.with do |array|
144
- array.should include(path)
145
- end
146
-
147
- touch 'new_file.rb'
148
-
149
- watch(listener, 1, path) do
150
- ln_s 'new_file.rb', 'new_file_symlink.rb'
151
- end
152
- end
153
- end
154
- end
155
-
156
- context 'given a new created directory' do
157
- it 'detects the added file' do
158
- fixtures do |path|
159
- listener.should_receive(:on_change).once.with do |array|
160
- array.should include(path, "#{path}/a_directory")
161
- end
162
-
163
- watch(listener, 2, path) do
164
- mkdir 'a_directory'
165
- # Needed for INotify, because of :recursive rb-inotify custom flag?
166
- sleep 0.05
167
- touch 'a_directory/new_file.rb'
168
- end
169
- end
170
- end
171
- end
172
-
173
- context 'given an existing directory' do
174
- it 'detects the added file' do
175
- fixtures do |path|
176
- listener.should_receive(:on_change).once.with do |array|
177
- array.should include("#{path}/a_directory")
178
- end
179
-
180
- mkdir 'a_directory'
181
-
182
- watch(listener, 1, path) do
183
- touch 'a_directory/new_file.rb'
184
- end
185
- end
186
- end
187
- end
188
-
189
- context 'given a directory with subdirectories' do
190
- it 'detects the added file' do
191
- fixtures do |path|
192
- listener.should_receive(:on_change).once.with do |array|
193
- array.should include("#{path}/a_directory/subdirectory")
194
- end
195
-
196
- mkdir_p 'a_directory/subdirectory'
197
-
198
- watch(listener, 1, path) do
199
- touch 'a_directory/subdirectory/new_file.rb'
200
- end
201
- end
202
- end
203
- end
204
- end
205
-
206
- context 'when a file is modified' do
207
- it 'detects the modified file' do
208
- fixtures do |path|
209
- listener.should_receive(:on_change).once.with do |array|
210
- array.should include(path)
211
- end
212
-
213
- touch 'existing_file.txt'
214
-
215
- watch(listener, 1, path) do
216
- touch 'existing_file.txt'
217
- end
218
- end
219
- end
220
-
221
- context 'given a symlink', :unless => windows? do
222
- it 'detects the modified file' do
223
- fixtures do |path|
224
- listener.should_receive(:on_change).once.with do |array|
225
- array.should include(path)
226
- end
227
-
228
- touch 'existing_file.rb'
229
- ln_s 'existing_file.rb', 'existing_file_symlink.rb'
230
-
231
- watch(listener, 1, path) do
232
- touch 'existing_file.rb'
233
- end
234
- end
235
- end
236
- end
237
-
238
- context 'given a hidden file' do
239
- it 'detects the modified file' do
240
- fixtures do |path|
241
- listener.should_receive(:on_change).once.with do |array|
242
- array.should include(path)
243
- end
244
-
245
- touch '.hidden'
246
-
247
- watch(listener, 1, path) do
248
- touch '.hidden'
249
- end
250
- end
251
- end
252
- end
253
-
254
- context 'given a file mode change', :unless => windows? do
255
- it 'does not detect the mode change' do
256
- fixtures do |path|
257
- listener.should_receive(:on_change).once.with do |array|
258
- array.should include(path)
259
- end
260
-
261
- touch 'run.rb'
262
-
263
- watch(listener, 1, path) do
264
- chmod 0777, 'run.rb'
265
- end
266
- end
267
- end
268
- end
269
-
270
- context 'given an existing directory' do
271
- it 'detects the modified file' do
272
- fixtures do |path|
273
- listener.should_receive(:on_change).once.with do |array|
274
- array.should include("#{path}/a_directory")
275
- end
276
-
277
- mkdir 'a_directory'
278
- touch 'a_directory/existing_file.txt'
279
-
280
- watch(listener, 1, path) do
281
- touch 'a_directory/existing_file.txt'
282
- end
283
- end
284
- end
285
- end
286
-
287
- context 'given a directory with subdirectories' do
288
- it 'detects the modified file' do
289
- fixtures do |path|
290
- listener.should_receive(:on_change).once.with do |array|
291
- array.should include("#{path}/a_directory/subdirectory")
292
- end
293
-
294
- mkdir_p 'a_directory/subdirectory'
295
- touch 'a_directory/subdirectory/existing_file.txt'
296
-
297
- watch(listener, 1, path) do
298
- touch 'a_directory/subdirectory/new_file.rb'
299
- end
300
- end
301
- end
302
- end
303
- end
304
-
305
- context 'when a file is moved' do
306
- it 'detects the file move' do
307
- fixtures do |path|
308
- listener.should_receive(:on_change).once.with do |array|
309
- array.should include(path)
310
- end
311
-
312
- touch 'move_me.txt'
313
-
314
- watch(listener, 1, path) do
315
- mv 'move_me.txt', 'new_name.txt'
316
- end
317
- end
318
- end
319
-
320
- context 'given a symlink', :unless => windows? do
321
- it 'detects the file move' do
322
- fixtures do |path|
323
- listener.should_receive(:on_change).once.with do |array|
324
- array.should include(path)
325
- end
326
-
327
- touch 'move_me.rb'
328
- ln_s 'move_me.rb', 'move_me_symlink.rb'
329
-
330
- watch(listener, 1, path) do
331
- mv 'move_me_symlink.rb', 'new_symlink.rb'
332
- end
333
- end
334
- end
335
- end
336
-
337
- context 'given an existing directory' do
338
- it 'detects the file move into the directory' do
339
- fixtures do |path|
340
- listener.should_receive(:on_change).once.with do |array|
341
- array.should include(path, "#{path}/a_directory")
342
- end
343
-
344
- mkdir 'a_directory'
345
- touch 'move_me.txt'
346
-
347
- watch(listener, 2, path) do
348
- mv 'move_me.txt', 'a_directory/move_me.txt'
349
- end
350
- end
351
- end
352
-
353
- it 'detects a file move out of the directory' do
354
- fixtures do |path|
355
- listener.should_receive(:on_change).once.with do |array|
356
- array.should include(path, "#{path}/a_directory")
357
- end
358
-
359
- mkdir 'a_directory'
360
- touch 'a_directory/move_me.txt'
361
-
362
- watch(listener, 2, path) do
363
- mv 'a_directory/move_me.txt', 'i_am_here.txt'
364
- end
365
- end
366
- end
367
-
368
- it 'detects a file move between two directories' do
369
- fixtures do |path|
370
- listener.should_receive(:on_change).once.with do |array|
371
- array.should include("#{path}/from_directory", "#{path}/to_directory")
372
- end
373
-
374
- mkdir 'from_directory'
375
- touch 'from_directory/move_me.txt'
376
- mkdir 'to_directory'
377
-
378
- watch(listener, 2, path) do
379
- mv 'from_directory/move_me.txt', 'to_directory/move_me.txt'
380
- end
381
- end
382
- end
383
- end
384
-
385
- context 'given a directory with subdirectories' do
386
- it 'detects files movements between subdirectories' do
387
- fixtures do |path|
388
- listener.should_receive(:on_change).once.with do |array|
389
- array.should include("#{path}/a_directory/subdirectory", "#{path}/b_directory/subdirectory")
390
- end
391
-
392
- mkdir_p 'a_directory/subdirectory'
393
- mkdir_p 'b_directory/subdirectory'
394
- touch 'a_directory/subdirectory/move_me.txt'
395
-
396
- watch(listener, 2, path) do
397
- mv 'a_directory/subdirectory/move_me.txt', 'b_directory/subdirectory'
398
- end
399
- end
400
- end
401
- end
402
- end
403
-
404
- context 'when a file is deleted' do
405
- it 'detects the file removal' do
406
- fixtures do |path|
407
- listener.should_receive(:on_change).once.with do |array|
408
- array.should include(path)
409
- end
410
-
411
- touch 'unnecessary.txt'
412
-
413
- watch(listener, 1, path) do
414
- rm 'unnecessary.txt'
415
- end
416
- end
417
- end
418
-
419
- context 'given a symlink', :unless => windows? do
420
- it 'detects the file removal' do
421
- fixtures do |path|
422
- listener.should_receive(:on_change).once.with do |array|
423
- array.should include(path)
424
- end
425
-
426
- touch 'unnecessary.rb'
427
- ln_s 'unnecessary.rb', 'unnecessary_symlink.rb'
428
-
429
- watch(listener, 1, path) do
430
- rm 'unnecessary_symlink.rb'
431
- end
432
- end
433
- end
434
- end
435
-
436
- context 'given an existing directory' do
437
- it 'detects the file removal' do
438
- fixtures do |path|
439
- listener.should_receive(:on_change).once.with do |array|
440
- array.should include("#{path}/a_directory")
441
- end
442
-
443
- mkdir 'a_directory'
444
- touch 'a_directory/do_not_use.rb'
445
-
446
- watch(listener, 1, path) do
447
- rm 'a_directory/do_not_use.rb'
448
- end
449
- end
450
- end
451
- end
452
-
453
- context 'given a directory with subdirectories' do
454
- it 'detects the file removal' do
455
- fixtures do |path|
456
- listener.should_receive(:on_change).once.with do |array|
457
- array.should include("#{path}/a_directory/subdirectory")
458
- end
459
-
460
- mkdir_p 'a_directory/subdirectory'
461
- touch 'a_directory/subdirectory/do_not_use.rb'
462
-
463
- watch(listener, 1, path) do
464
- rm 'a_directory/subdirectory/do_not_use.rb'
465
- end
466
- end
467
- end
468
- end
469
- end
470
- end
471
-
472
- context 'multiple file operations' do
473
- it 'detects the added files' do
474
- fixtures do |path|
475
- listener.should_receive(:on_change).once.with do |array|
476
- array.should include(path, "#{path}/a_directory")
477
- end
478
-
479
- watch(listener, 2, path) do
480
- touch 'a_file.rb'
481
- touch 'b_file.rb'
482
- mkdir 'a_directory'
483
- # Needed for INotify, because of :recursive rb-inotify custom flag?
484
- # Also needed for the osx adapter
485
- sleep 0.05
486
- touch 'a_directory/a_file.rb'
487
- touch 'a_directory/b_file.rb'
488
- end
489
- end
490
- end
491
-
492
- it 'detects the modified files' do
493
- fixtures do |path|
494
- listener.should_receive(:on_change).once.with do |array|
495
- array.should include(path, "#{path}/a_directory")
496
- end
497
-
498
- touch 'a_file.rb'
499
- touch 'b_file.rb'
500
- mkdir 'a_directory'
501
- touch 'a_directory/a_file.rb'
502
- touch 'a_directory/b_file.rb'
503
-
504
- watch(listener, 2, path) do
505
- touch 'b_file.rb'
506
- touch 'a_directory/a_file.rb'
507
- end
508
- end
509
- end
510
-
511
- it 'detects the removed files' do
512
- fixtures do |path|
513
- listener.should_receive(:on_change).once.with do |array|
514
- array.should include(path, "#{path}/a_directory")
515
- end
516
-
517
- touch 'a_file.rb'
518
- touch 'b_file.rb'
519
- mkdir 'a_directory'
520
- touch 'a_directory/a_file.rb'
521
- touch 'a_directory/b_file.rb'
522
-
523
- watch(listener, 2, path) do
524
- rm 'b_file.rb'
525
- rm 'a_directory/a_file.rb'
526
- end
527
- end
528
- end
529
- end
530
-
531
- context 'single directory operations' do
532
- it 'detects a moved directory' do
533
- fixtures do |path|
534
- listener.should_receive(:on_change).once.with do |array|
535
- array.should include(path)
536
- end
537
-
538
- mkdir 'a_directory'
539
- touch 'a_directory/a_file.rb'
540
- touch 'a_directory/b_file.rb'
541
-
542
- watch(listener, 1, path) do
543
- mv 'a_directory', 'renamed'
544
- end
545
- end
546
- end
547
-
548
- it 'detects a removed directory' do
549
- fixtures do |path|
550
- listener.should_receive(:on_change).once.with do |array|
551
- array.should include(path, "#{path}/a_directory")
552
- end
553
-
554
- mkdir 'a_directory'
555
- touch 'a_directory/a_file.rb'
556
- touch 'a_directory/b_file.rb'
557
-
558
- watch(listener, 2, path) do
559
- rm_rf 'a_directory'
560
- end
561
- end
562
- end
563
- end
564
-
565
- context "paused adapter" do
566
- context 'when a file is created' do
567
- it "doesn't detects the added file" do
568
- fixtures do |path|
569
- watch(listener, 1, path) do # The expected changes param is set to one!
570
- @adapter.paused = true
571
- touch 'new_file.rb'
572
- end
573
- @called.should be_nil
574
- end
575
- end
576
- end
577
- end
578
-
579
- context "when multiple directories are listened to" do
580
- context 'when files are added to one of multiple directories' do
581
- it 'detects added files' do
582
- fixtures(2) do |path1, path2|
583
- listener.should_receive(:on_change).once.with do |array|
584
- array.should include(path2)
585
- end
586
-
587
- watch(listener, 1, path1, path2) do
588
- touch "#{path2}/new_file.rb"
589
- end
590
- end
591
- end
592
- end
593
-
594
- context 'when files are added to multiple directories' do
595
- it 'detects added files' do
596
- fixtures(2) do |path1, path2|
597
- listener.should_receive(:on_change).once.with do |array|
598
- array.should include(path1, path2)
599
- end
600
-
601
- watch(listener, 2, path1, path2) do
602
- touch "#{path1}/new_file.rb"
603
- touch "#{path2}/new_file.rb"
604
- end
605
- end
606
- end
607
- end
608
-
609
- context 'given a new and an existing directory on multiple directories' do
610
- it 'detects the added file' do
611
- fixtures(2) do |path1, path2|
612
- listener.should_receive(:on_change).once.with do |array|
613
- array.should include(path2, "#{path1}/a_directory", "#{path2}/b_directory")
614
- end
615
-
616
- mkdir "#{path1}/a_directory"
617
-
618
- watch(listener, 3, path1, path2) do
619
- mkdir "#{path2}/b_directory"
620
- # Needed for INotify
621
- sleep 0.05
622
- touch "#{path1}/a_directory/new_file.rb"
623
- touch "#{path2}/b_directory/new_file.rb"
624
- end
625
- end
626
- end
627
- end
628
-
629
- context 'when a file is moved between the multiple watched directories' do
630
- it 'detects the movements of the file' do
631
- fixtures(3) do |path1, path2, path3|
632
- listener.should_receive(:on_change).once.with do |array|
633
- array.should include("#{path1}/from_directory", path2, "#{path3}/to_directory")
634
- end
635
-
636
- mkdir "#{path1}/from_directory"
637
- touch "#{path1}/from_directory/move_me.txt"
638
- mkdir "#{path3}/to_directory"
639
-
640
- watch(listener, 3, path1, path2, path3) do
641
- mv "#{path1}/from_directory/move_me.txt", "#{path2}/move_me.txt"
642
- mv "#{path2}/move_me.txt", "#{path3}/to_directory/move_me.txt"
643
- end
644
- end
645
- end
646
- end
647
-
648
- context 'when files are deleted from the multiple watched directories' do
649
- it 'detects the files removal' do
650
- fixtures(2) do |path1, path2|
651
- listener.should_receive(:on_change).once.with do |array|
652
- array.should include(path1, path2)
653
- end
654
-
655
- touch "#{path1}/unnecessary.txt"
656
- touch "#{path2}/unnecessary.txt"
657
-
658
- watch(listener, 2, path1, path2) do
659
- rm "#{path1}/unnecessary.txt"
660
- rm "#{path2}/unnecessary.txt"
661
- end
662
- end
663
- end
664
- end
665
- end
666
- end