sass 3.3.0.alpha.93 → 3.3.0.alpha.101

Sign up to get free protection for your applications and to get access to all the features.
Files changed (61) hide show
  1. data/REVISION +1 -1
  2. data/VERSION +1 -1
  3. data/VERSION_DATE +1 -1
  4. data/bin/sass +2 -1
  5. data/bin/sass-convert +2 -1
  6. data/bin/scss +2 -1
  7. data/lib/sass/cache_stores/chain.rb +1 -1
  8. data/lib/sass/cache_stores/filesystem.rb +0 -1
  9. data/lib/sass/engine.rb +7 -1
  10. data/lib/sass/exec.rb +1 -0
  11. data/lib/sass/importers/filesystem.rb +1 -1
  12. data/lib/sass/media.rb +1 -4
  13. data/lib/sass/plugin/compiler.rb +1 -1
  14. data/lib/sass/script/funcall.rb +43 -8
  15. data/lib/sass/script/functions.rb +8 -16
  16. data/lib/sass/script/lexer.rb +0 -2
  17. data/lib/sass/script/parser.rb +26 -25
  18. data/lib/sass/scss/parser.rb +13 -1
  19. data/lib/sass/selector/simple_sequence.rb +1 -1
  20. data/lib/sass/tree/comment_node.rb +2 -2
  21. data/lib/sass/tree/visitors/cssize.rb +10 -1
  22. data/lib/sass/tree/visitors/perform.rb +4 -2
  23. data/lib/sass/util.rb +54 -1
  24. data/lib/sass/util/multibyte_string_scanner.rb +29 -8
  25. data/test/sass/engine_test.rb +20 -4
  26. data/test/sass/extend_test.rb +15 -0
  27. data/test/sass/functions_test.rb +20 -1
  28. data/test/sass/script_test.rb +5 -1
  29. data/vendor/listen/CHANGELOG.md +76 -2
  30. data/vendor/listen/CONTRIBUTING.md +38 -0
  31. data/vendor/listen/Gemfile +8 -1
  32. data/vendor/listen/Guardfile +1 -1
  33. data/vendor/listen/LICENSE +1 -1
  34. data/vendor/listen/README.md +8 -5
  35. data/vendor/listen/lib/listen.rb +7 -5
  36. data/vendor/listen/lib/listen/adapter.rb +76 -29
  37. data/vendor/listen/lib/listen/adapters/bsd.rb +112 -0
  38. data/vendor/listen/lib/listen/adapters/darwin.rb +11 -10
  39. data/vendor/listen/lib/listen/adapters/linux.rb +33 -30
  40. data/vendor/listen/lib/listen/adapters/polling.rb +2 -1
  41. data/vendor/listen/lib/listen/adapters/windows.rb +27 -21
  42. data/vendor/listen/lib/listen/dependency_manager.rb +126 -0
  43. data/vendor/listen/lib/listen/directory_record.rb +63 -10
  44. data/vendor/listen/lib/listen/listener.rb +22 -0
  45. data/vendor/listen/lib/listen/multi_listener.rb +22 -0
  46. data/vendor/listen/lib/listen/version.rb +1 -1
  47. data/vendor/listen/listen.gemspec +0 -4
  48. data/vendor/listen/spec/listen/adapter_spec.rb +45 -4
  49. data/vendor/listen/spec/listen/adapters/bsd_spec.rb +36 -0
  50. data/vendor/listen/spec/listen/adapters/darwin_spec.rb +6 -0
  51. data/vendor/listen/spec/listen/adapters/linux_spec.rb +6 -0
  52. data/vendor/listen/spec/listen/adapters/windows_spec.rb +7 -1
  53. data/vendor/listen/spec/listen/dependency_manager_spec.rb +107 -0
  54. data/vendor/listen/spec/listen/directory_record_spec.rb +91 -4
  55. data/vendor/listen/spec/listen/listener_spec.rb +14 -0
  56. data/vendor/listen/spec/listen/multi_listener_spec.rb +19 -1
  57. data/vendor/listen/spec/spec_helper.rb +6 -3
  58. data/vendor/listen/spec/support/adapter_helper.rb +125 -212
  59. data/vendor/listen/spec/support/listeners_helper.rb +13 -1
  60. data/vendor/listen/spec/support/platform_helper.rb +4 -0
  61. metadata +11 -6
@@ -1,3 +1,4 @@
1
+ # encoding: UTF-8
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Listen::DirectoryRecord do
@@ -41,12 +42,19 @@ describe Listen::DirectoryRecord do
41
42
  end
42
43
 
43
44
  describe '#ignore' do
44
- it 'adds the passed paths to the list of ignoted paths in the record' do
45
+ it 'adds the passed paths to the list of ignored paths in the record' do
45
46
  subject.ignore(%r{^\.old/}, %r{\.pid$})
46
47
  subject.ignoring_patterns.should include(%r{^\.old/}, %r{\.pid$})
47
48
  end
48
49
  end
49
50
 
51
+ describe '#ignore!' do
52
+ it 'replace the ignored paths in the record' do
53
+ subject.ignore!(%r{^\.old/}, %r{\.pid$})
54
+ subject.ignoring_patterns.should =~ [%r{^\.old/}, %r{\.pid$}]
55
+ end
56
+ end
57
+
50
58
  describe '#filter' do
51
59
  it 'adds the passed regexps to the list of filters that determine the stored paths' do
52
60
  subject.filter(%r{\.(?:jpe?g|gif|png)}, %r{\.(?:mp3|ogg|a3c)})
@@ -54,6 +62,13 @@ describe Listen::DirectoryRecord do
54
62
  end
55
63
  end
56
64
 
65
+ describe '#filter!' do
66
+ it 'replaces the passed regexps in the list of filters that determine the stored paths' do
67
+ subject.filter!(%r{\.(?:jpe?g|gif|png)}, %r{\.(?:mp3|ogg|a3c)})
68
+ subject.filtering_patterns.should =~ [%r{\.(?:mp3|ogg|a3c)}, %r{\.(?:jpe?g|gif|png)}]
69
+ end
70
+ end
71
+
57
72
  describe '#ignored?' do
58
73
  before { subject.stub(:relative_to_base) { |path| path } }
59
74
 
@@ -193,7 +208,12 @@ describe Listen::DirectoryRecord do
193
208
  it 'returns nil when the passed path is not inside the base-directory' do
194
209
  subject.relative_to_base('/tmp/some_random_path').should be_nil
195
210
  end
196
-
211
+
212
+ it 'works with non UTF-8 paths' do
213
+ path = "tmp/\xE4\xE4"
214
+ subject.relative_to_base(File.join(base_directory, path))
215
+ end
216
+
197
217
  context 'when containing regexp characters in the base directory' do
198
218
  before do
199
219
  fixtures do |path|
@@ -442,6 +462,11 @@ describe Listen::DirectoryRecord do
442
462
  it 'detects the modified file the second time if the content have changed' do
443
463
  fixtures do |path|
444
464
  touch 'existing_file.txt'
465
+ # Set sha1 path checksum
466
+ changes(path) do
467
+ touch 'existing_file.txt'
468
+ end
469
+ small_time_difference
445
470
 
446
471
  changes(path) do
447
472
  touch 'existing_file.txt'
@@ -456,6 +481,58 @@ describe Listen::DirectoryRecord do
456
481
  removed.should be_empty
457
482
  end
458
483
  end
484
+
485
+ it "doesn't detects the modified file the second time if just touched - #62" do
486
+ fixtures do |path|
487
+ touch 'existing_file.txt'
488
+ # Set sha1 path checksum
489
+ changes(path) do
490
+ touch 'existing_file.txt'
491
+ end
492
+ small_time_difference
493
+
494
+ changes(path, :use_last_record => true) do
495
+ open('existing_file.txt', 'w') { |f| f.write('foo') }
496
+ end
497
+
498
+ modified, added, removed = changes(path, :use_last_record => true) do
499
+ touch 'existing_file.txt'
500
+ end
501
+
502
+ added.should be_empty
503
+ modified.should be_empty
504
+ removed.should be_empty
505
+ end
506
+ end
507
+
508
+ it "adds the path in the paths checksums if just touched - #62" do
509
+ fixtures do |path|
510
+ touch 'existing_file.txt'
511
+ small_time_difference
512
+
513
+ changes(path) do
514
+ touch 'existing_file.txt'
515
+ end
516
+
517
+ @record.sha1_checksums["#{path}/existing_file.txt"].should_not be_nil
518
+ end
519
+ end
520
+
521
+ it "deletes the path from the paths checksums" do
522
+ fixtures do |path|
523
+ touch 'unnecessary.txt'
524
+
525
+ changes(path) do
526
+ @record.sha1_checksums["#{path}/unnecessary.txt"] = 'foo'
527
+
528
+ rm 'unnecessary.txt'
529
+ end
530
+
531
+ @record.sha1_checksums["#{path}/unnecessary.txt"].should be_nil
532
+ end
533
+ end
534
+
535
+
459
536
  end
460
537
 
461
538
  context 'given a hidden file' do
@@ -1092,7 +1169,7 @@ describe Listen::DirectoryRecord do
1092
1169
 
1093
1170
  # simulate a race condition where the file is removed after the
1094
1171
  # change event is tracked, but before the hash is calculated
1095
- Digest::SHA1.should_receive(:file).and_raise(Errno::ENOENT)
1172
+ Digest::SHA1.should_receive(:file).twice.and_raise(Errno::ENOENT)
1096
1173
 
1097
1174
  lambda {
1098
1175
  fixtures do |path|
@@ -1104,7 +1181,17 @@ describe Listen::DirectoryRecord do
1104
1181
  end
1105
1182
  end
1106
1183
 
1107
- context 'with symlinks' do
1184
+ context 'within a directory containing a unix domain socket file' do
1185
+ it 'does not raise an exception when hashing a unix domain socket file' do
1186
+ fixtures do |path|
1187
+ require 'socket'
1188
+ UNIXServer.new('unix_domain_socket.sock')
1189
+ lambda { changes(path){} }.should_not raise_error(Errno::ENXIO)
1190
+ end
1191
+ end
1192
+ end
1193
+
1194
+ context 'with symlinks', :unless => windows? do
1108
1195
  it 'looks at symlinks not their targets' do
1109
1196
  fixtures do |path|
1110
1197
  touch 'target'
@@ -84,6 +84,13 @@ describe Listen::Listener do
84
84
  end
85
85
  end
86
86
 
87
+ describe '#ignore!'do
88
+ it 'delegates the work to the directory record' do
89
+ subject.directory_record.should_receive(:ignore!).with 'some_directory'
90
+ subject.ignore! 'some_directory'
91
+ end
92
+ end
93
+
87
94
  describe '#filter' do
88
95
  it 'delegates the work to the directory record' do
89
96
  subject.directory_record.should_receive(:filter).with /\.txt$/
@@ -91,6 +98,13 @@ describe Listen::Listener do
91
98
  end
92
99
  end
93
100
 
101
+ describe '#filter!' do
102
+ it 'delegates the work to the directory record' do
103
+ subject.directory_record.should_receive(:filter!).with /\.txt$/
104
+ subject.filter! /\.txt$/
105
+ end
106
+ end
107
+
94
108
 
95
109
  describe '#on_change' do
96
110
  let(:directories) { %w{dir1 dir2 dir3} }
@@ -80,7 +80,7 @@ describe Listen::MultiListener do
80
80
  end
81
81
  end
82
82
 
83
- describe '#ignore'do
83
+ describe '#ignore' do
84
84
  it 'delegates the work to each directory record' do
85
85
  subject.directories_records.each do |r|
86
86
  r.should_receive(:ignore).with 'some_directory'
@@ -89,6 +89,15 @@ describe Listen::MultiListener do
89
89
  end
90
90
  end
91
91
 
92
+ describe '#ignore!' do
93
+ it 'delegates the work to each directory record' do
94
+ subject.directories_records.each do |r|
95
+ r.should_receive(:ignore!).with 'some_directory'
96
+ end
97
+ subject.ignore! 'some_directory'
98
+ end
99
+ end
100
+
92
101
  describe '#filter' do
93
102
  it 'delegates the work to each directory record' do
94
103
  subject.directories_records.each do |r|
@@ -98,6 +107,15 @@ describe Listen::MultiListener do
98
107
  end
99
108
  end
100
109
 
110
+ describe '#filter!' do
111
+ it 'delegates the work to each directory record' do
112
+ subject.directories_records.each do |r|
113
+ r.should_receive(:filter!).with /\.txt$/
114
+ end
115
+ subject.filter! /\.txt$/
116
+ end
117
+ end
118
+
101
119
  describe '#on_change' do
102
120
  let(:directories) { %w{dir1 dir2 dir3} }
103
121
  let(:changes) { {:modified => [], :added => [], :removed => []} }
@@ -1,7 +1,5 @@
1
1
  require 'listen'
2
2
 
3
- ENV["TEST_LATENCY"] ||= "0.25"
4
-
5
3
  Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
6
4
 
7
5
  # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
@@ -11,8 +9,13 @@ RSpec.configure do |config|
11
9
  config.filter_run :focus => true
12
10
  config.treat_symbols_as_metadata_keys_with_true_values = true
13
11
  config.run_all_when_everything_filtered = true
12
+ config.filter_run_excluding :broken => true
13
+ config.fail_fast = true
14
14
  end
15
15
 
16
16
  def test_latency
17
- ENV["TEST_LATENCY"].to_f
17
+ 0.1
18
18
  end
19
+
20
+ # Crash loud in tests!
21
+ Thread.abort_on_exception = true
@@ -3,18 +3,29 @@
3
3
  # @param [Listen::Listener] listener the adapter listener
4
4
  # @param [String] path the path to watch
5
5
  #
6
- def watch(listener, *paths)
7
- callback = lambda { |changed_dirs, options| @called = true; listener.on_change(changed_dirs, options) }
8
- @adapter = Listen::Adapter.select_and_initialize(paths, { :latency => test_latency }, &callback)
6
+ def watch(listener, expected_changes, *paths)
7
+ callback = lambda { |changed_dirs, options| @called = true; listener.on_change(changed_dirs) }
8
+ @adapter = Listen::Adapter.select_and_initialize(paths, { :report_changes => false, :latency => test_latency }, &callback)
9
+
10
+ forced_stop = false
11
+ prevent_deadlock = Proc.new { sleep(10); puts "Forcing stop"; @adapter.stop; forced_stop = true }
12
+
9
13
  @adapter.start(false)
10
14
 
11
15
  yield
12
16
 
13
- t = Thread.new { sleep(test_latency * 5); @adapter.stop }
14
- @adapter.wait_for_callback
17
+ t = Thread.new(&prevent_deadlock)
18
+ @adapter.wait_for_changes(expected_changes)
19
+
20
+ unless forced_stop
21
+ Thread.kill(t)
22
+ @adapter.report_changes
23
+ end
15
24
  ensure
16
- Thread.kill(t) if t
17
- @adapter.stop
25
+ unless forced_stop
26
+ Thread.kill(t) if t
27
+ @adapter.stop
28
+ end
18
29
  end
19
30
 
20
31
  shared_examples_for 'a filesystem adapter' do
@@ -61,7 +72,7 @@ shared_examples_for 'a filesystem adapter' do
61
72
 
62
73
  context 'with a started adapter' do
63
74
  before { subject.start(false) }
64
- after { subject.start }
75
+ after { subject.stop }
65
76
 
66
77
  it 'returns true' do
67
78
  subject.should be_started
@@ -79,30 +90,26 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
79
90
  context 'when a file is created' do
80
91
  it 'detects the added file' do
81
92
  fixtures do |path|
82
- if options[:recursive]
83
- listener.should_receive(:on_change).once.with([path], :recursive => true)
84
- else
85
- listener.should_receive(:on_change).once.with([path], {})
93
+ listener.should_receive(:on_change).once.with do |array|
94
+ array.should include(path)
86
95
  end
87
96
 
88
- watch(listener, path) do
97
+ watch(listener, 1, path) do
89
98
  touch 'new_file.rb'
90
99
  end
91
100
  end
92
101
  end
93
102
 
94
- context 'given a symlink' do
103
+ context 'given a symlink', :unless => windows? do
95
104
  it 'detects the added file' do
96
105
  fixtures do |path|
97
- if options[:recursive]
98
- listener.should_receive(:on_change).once.with([path], :recursive => true)
99
- else
100
- listener.should_receive(:on_change).once.with([path], {})
106
+ listener.should_receive(:on_change).once.with do |array|
107
+ array.should include(path)
101
108
  end
102
109
 
103
110
  touch 'new_file.rb'
104
111
 
105
- watch(listener, path) do
112
+ watch(listener, 1, path) do
106
113
  ln_s 'new_file.rb', 'new_file_symlink.rb'
107
114
  end
108
115
  end
@@ -112,18 +119,14 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
112
119
  context 'given a new created directory' do
113
120
  it 'detects the added file' do
114
121
  fixtures do |path|
115
- if options[:recursive]
116
- listener.should_receive(:on_change).once.with([path], :recursive => true)
117
- else
118
- listener.should_receive(:on_change).once.with do |array, options|
119
- array.should =~ [path, "#{path}/a_directory"]
120
- end
122
+ listener.should_receive(:on_change).once.with do |array|
123
+ array.should include(path, "#{path}/a_directory")
121
124
  end
122
125
 
123
- watch(listener, path) do
126
+ watch(listener, 2, path) do
124
127
  mkdir 'a_directory'
125
128
  # Needed for INotify, because of :recursive rb-inotify custom flag?
126
- sleep 0.05 if @adapter.is_a?(Listen::Adapters::Linux)
129
+ sleep 0.05
127
130
  touch 'a_directory/new_file.rb'
128
131
  end
129
132
  end
@@ -133,15 +136,13 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
133
136
  context 'given an existing directory' do
134
137
  it 'detects the added file' do
135
138
  fixtures do |path|
136
- if options[:recursive]
137
- listener.should_receive(:on_change).once.with([path], :recursive => true)
138
- else
139
- listener.should_receive(:on_change).once.with(["#{path}/a_directory"], {})
139
+ listener.should_receive(:on_change).once.with do |array|
140
+ array.should include("#{path}/a_directory")
140
141
  end
141
142
 
142
143
  mkdir 'a_directory'
143
144
 
144
- watch(listener, path) do
145
+ watch(listener, 1, path) do
145
146
  touch 'a_directory/new_file.rb'
146
147
  end
147
148
  end
@@ -151,15 +152,13 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
151
152
  context 'given a directory with subdirectories' do
152
153
  it 'detects the added file' do
153
154
  fixtures do |path|
154
- if options[:recursive]
155
- listener.should_receive(:on_change).once.with([path], :recursive => true)
156
- else
157
- listener.should_receive(:on_change).once.with(["#{path}/a_directory/subdirectory"], {})
155
+ listener.should_receive(:on_change).once.with do |array|
156
+ array.should include("#{path}/a_directory/subdirectory")
158
157
  end
159
158
 
160
159
  mkdir_p 'a_directory/subdirectory'
161
160
 
162
- watch(listener, path) do
161
+ watch(listener, 1, path) do
163
162
  touch 'a_directory/subdirectory/new_file.rb'
164
163
  end
165
164
  end
@@ -170,33 +169,29 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
170
169
  context 'when a file is modified' do
171
170
  it 'detects the modified file' do
172
171
  fixtures do |path|
173
- if options[:recursive]
174
- listener.should_receive(:on_change).once.with([path], :recursive => true)
175
- else
176
- listener.should_receive(:on_change).once.with([path], {})
172
+ listener.should_receive(:on_change).once.with do |array|
173
+ array.should include(path)
177
174
  end
178
175
 
179
176
  touch 'existing_file.txt'
180
177
 
181
- watch(listener, path) do
178
+ watch(listener, 1, path) do
182
179
  touch 'existing_file.txt'
183
180
  end
184
181
  end
185
182
  end
186
183
 
187
- context 'given a symlink' do
184
+ context 'given a symlink', :unless => windows? do
188
185
  it 'detects the modified file' do
189
186
  fixtures do |path|
190
- if options[:recursive]
191
- listener.should_receive(:on_change).once.with([path], :recursive => true)
192
- else
193
- listener.should_receive(:on_change).once.with([path], {})
187
+ listener.should_receive(:on_change).once.with do |array|
188
+ array.should include(path)
194
189
  end
195
190
 
196
191
  touch 'existing_file.rb'
197
192
  ln_s 'existing_file.rb', 'existing_file_symlink.rb'
198
193
 
199
- watch(listener, path) do
194
+ watch(listener, 1, path) do
200
195
  touch 'existing_file.rb'
201
196
  end
202
197
  end
@@ -206,36 +201,30 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
206
201
  context 'given a hidden file' do
207
202
  it 'detects the modified file' do
208
203
  fixtures do |path|
209
- if options[:recursive]
210
- listener.should_receive(:on_change).once.with([path], :recursive => true)
211
- else
212
- listener.should_receive(:on_change).once.with([path], {})
204
+ listener.should_receive(:on_change).once.with do |array|
205
+ array.should include(path)
213
206
  end
214
207
 
215
208
  touch '.hidden'
216
209
 
217
- watch(listener, path) do
210
+ watch(listener, 1, path) do
218
211
  touch '.hidden'
219
212
  end
220
213
  end
221
214
  end
222
215
  end
223
216
 
224
- unless options[:adapter] == :windows
225
- context 'given a file mode change' do
226
- it 'does not detect the mode change' do
227
- fixtures do |path|
228
- if options[:recursive]
229
- listener.should_receive(:on_change).once.with([path], :recursive => true)
230
- else
231
- listener.should_receive(:on_change).once.with([path], {})
232
- end
217
+ context 'given a file mode change', :unless => windows? do
218
+ it 'does not detect the mode change' do
219
+ fixtures do |path|
220
+ listener.should_receive(:on_change).once.with do |array|
221
+ array.should include(path)
222
+ end
233
223
 
234
- touch 'run.rb'
224
+ touch 'run.rb'
235
225
 
236
- watch(listener, path) do
237
- chmod 0777, 'run.rb'
238
- end
226
+ watch(listener, 1, path) do
227
+ chmod 0777, 'run.rb'
239
228
  end
240
229
  end
241
230
  end
@@ -244,16 +233,14 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
244
233
  context 'given an existing directory' do
245
234
  it 'detects the modified file' do
246
235
  fixtures do |path|
247
- if options[:recursive]
248
- listener.should_receive(:on_change).once.with([path], :recursive => true)
249
- else
250
- listener.should_receive(:on_change).once.with(["#{path}/a_directory"], {})
236
+ listener.should_receive(:on_change).once.with do |array|
237
+ array.should include("#{path}/a_directory")
251
238
  end
252
239
 
253
240
  mkdir 'a_directory'
254
241
  touch 'a_directory/existing_file.txt'
255
242
 
256
- watch(listener, path) do
243
+ watch(listener, 1, path) do
257
244
  touch 'a_directory/existing_file.txt'
258
245
  end
259
246
  end
@@ -263,16 +250,14 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
263
250
  context 'given a directory with subdirectories' do
264
251
  it 'detects the modified file' do
265
252
  fixtures do |path|
266
- if options[:recursive]
267
- listener.should_receive(:on_change).once.with([path], :recursive => true)
268
- else
269
- listener.should_receive(:on_change).once.with(["#{path}/a_directory/subdirectory"], {})
253
+ listener.should_receive(:on_change).once.with do |array|
254
+ array.should include("#{path}/a_directory/subdirectory")
270
255
  end
271
256
 
272
257
  mkdir_p 'a_directory/subdirectory'
273
258
  touch 'a_directory/subdirectory/existing_file.txt'
274
259
 
275
- watch(listener, path) do
260
+ watch(listener, 1, path) do
276
261
  touch 'a_directory/subdirectory/new_file.rb'
277
262
  end
278
263
  end
@@ -283,33 +268,29 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
283
268
  context 'when a file is moved' do
284
269
  it 'detects the file move' do
285
270
  fixtures do |path|
286
- if options[:recursive]
287
- listener.should_receive(:on_change).once.with([path], :recursive => true)
288
- else
289
- listener.should_receive(:on_change).once.with([path], {})
271
+ listener.should_receive(:on_change).once.with do |array|
272
+ array.should include(path)
290
273
  end
291
274
 
292
275
  touch 'move_me.txt'
293
276
 
294
- watch(listener, path) do
277
+ watch(listener, 1, path) do
295
278
  mv 'move_me.txt', 'new_name.txt'
296
279
  end
297
280
  end
298
281
  end
299
282
 
300
- context 'given a symlink' do
283
+ context 'given a symlink', :unless => windows? do
301
284
  it 'detects the file move' do
302
285
  fixtures do |path|
303
- if options[:recursive]
304
- listener.should_receive(:on_change).once.with([path], :recursive => true)
305
- else
306
- listener.should_receive(:on_change).once.with([path], {})
286
+ listener.should_receive(:on_change).once.with do |array|
287
+ array.should include(path)
307
288
  end
308
289
 
309
290
  touch 'move_me.rb'
310
291
  ln_s 'move_me.rb', 'move_me_symlink.rb'
311
292
 
312
- watch(listener, path) do
293
+ watch(listener, 1, path) do
313
294
  mv 'move_me_symlink.rb', 'new_symlink.rb'
314
295
  end
315
296
  end
@@ -319,18 +300,14 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
319
300
  context 'given an existing directory' do
320
301
  it 'detects the file move into the directory' do
321
302
  fixtures do |path|
322
- if options[:recursive]
323
- listener.should_receive(:on_change).once.with([path], :recursive => true)
324
- else
325
- listener.should_receive(:on_change).once.with do |array, options|
326
- array.should =~ [path, "#{path}/a_directory"]
327
- end
303
+ listener.should_receive(:on_change).once.with do |array|
304
+ array.should include(path, "#{path}/a_directory")
328
305
  end
329
306
 
330
307
  mkdir 'a_directory'
331
308
  touch 'move_me.txt'
332
309
 
333
- watch(listener, path) do
310
+ watch(listener, 2, path) do
334
311
  mv 'move_me.txt', 'a_directory/move_me.txt'
335
312
  end
336
313
  end
@@ -338,18 +315,14 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
338
315
 
339
316
  it 'detects a file move out of the directory' do
340
317
  fixtures do |path|
341
- if options[:recursive]
342
- listener.should_receive(:on_change).once.with([path], :recursive => true)
343
- else
344
- listener.should_receive(:on_change).once.with do |array, options|
345
- array.should =~ [path, "#{path}/a_directory"]
346
- end
318
+ listener.should_receive(:on_change).once.with do |array|
319
+ array.should include(path, "#{path}/a_directory")
347
320
  end
348
321
 
349
322
  mkdir 'a_directory'
350
323
  touch 'a_directory/move_me.txt'
351
324
 
352
- watch(listener, path) do
325
+ watch(listener, 2, path) do
353
326
  mv 'a_directory/move_me.txt', 'i_am_here.txt'
354
327
  end
355
328
  end
@@ -357,19 +330,15 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
357
330
 
358
331
  it 'detects a file move between two directories' do
359
332
  fixtures do |path|
360
- if options[:recursive]
361
- listener.should_receive(:on_change).once.with([path], :recursive => true)
362
- else
363
- listener.should_receive(:on_change).once.with do |array, options|
364
- array.should =~ ["#{path}/from_directory", "#{path}/to_directory"]
365
- end
333
+ listener.should_receive(:on_change).once.with do |array|
334
+ array.should include("#{path}/from_directory", "#{path}/to_directory")
366
335
  end
367
336
 
368
337
  mkdir 'from_directory'
369
338
  touch 'from_directory/move_me.txt'
370
339
  mkdir 'to_directory'
371
340
 
372
- watch(listener, path) do
341
+ watch(listener, 2, path) do
373
342
  mv 'from_directory/move_me.txt', 'to_directory/move_me.txt'
374
343
  end
375
344
  end
@@ -379,19 +348,15 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
379
348
  context 'given a directory with subdirectories' do
380
349
  it 'detects files movements between subdirectories' do
381
350
  fixtures do |path|
382
- if options[:recursive]
383
- listener.should_receive(:on_change).once.with([path], :recursive => true)
384
- else
385
- listener.should_receive(:on_change).once.with do |array, options|
386
- array.should =~ ["#{path}/a_directory/subdirectory", "#{path}/b_directory/subdirectory"]
387
- end
351
+ listener.should_receive(:on_change).once.with do |array|
352
+ array.should include("#{path}/a_directory/subdirectory", "#{path}/b_directory/subdirectory")
388
353
  end
389
354
 
390
355
  mkdir_p 'a_directory/subdirectory'
391
356
  mkdir_p 'b_directory/subdirectory'
392
357
  touch 'a_directory/subdirectory/move_me.txt'
393
358
 
394
- watch(listener, path) do
359
+ watch(listener, 2, path) do
395
360
  mv 'a_directory/subdirectory/move_me.txt', 'b_directory/subdirectory'
396
361
  end
397
362
  end
@@ -402,33 +367,29 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
402
367
  context 'when a file is deleted' do
403
368
  it 'detects the file removal' do
404
369
  fixtures do |path|
405
- if options[:recursive]
406
- listener.should_receive(:on_change).once.with([path], :recursive => true)
407
- else
408
- listener.should_receive(:on_change).once.with([path], {})
370
+ listener.should_receive(:on_change).once.with do |array|
371
+ array.should include(path)
409
372
  end
410
373
 
411
374
  touch 'unnecessary.txt'
412
375
 
413
- watch(listener, path) do
376
+ watch(listener, 1, path) do
414
377
  rm 'unnecessary.txt'
415
378
  end
416
379
  end
417
380
  end
418
381
 
419
- context 'given a symlink' do
382
+ context 'given a symlink', :unless => windows? do
420
383
  it 'detects the file removal' do
421
384
  fixtures do |path|
422
- if options[:recursive]
423
- listener.should_receive(:on_change).once.with([path], :recursive => true)
424
- else
425
- listener.should_receive(:on_change).once.with([path], {})
385
+ listener.should_receive(:on_change).once.with do |array|
386
+ array.should include(path)
426
387
  end
427
388
 
428
389
  touch 'unnecessary.rb'
429
390
  ln_s 'unnecessary.rb', 'unnecessary_symlink.rb'
430
391
 
431
- watch(listener, path) do
392
+ watch(listener, 1, path) do
432
393
  rm 'unnecessary_symlink.rb'
433
394
  end
434
395
  end
@@ -438,16 +399,14 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
438
399
  context 'given an existing directory' do
439
400
  it 'detects the file removal' do
440
401
  fixtures do |path|
441
- if options[:recursive]
442
- listener.should_receive(:on_change).once.with([path], :recursive => true)
443
- else
444
- listener.should_receive(:on_change).once.with(["#{path}/a_directory"], {})
402
+ listener.should_receive(:on_change).once.with do |array|
403
+ array.should include("#{path}/a_directory")
445
404
  end
446
405
 
447
406
  mkdir 'a_directory'
448
407
  touch 'a_directory/do_not_use.rb'
449
408
 
450
- watch(listener, path) do
409
+ watch(listener, 1, path) do
451
410
  rm 'a_directory/do_not_use.rb'
452
411
  end
453
412
  end
@@ -457,16 +416,14 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
457
416
  context 'given a directory with subdirectories' do
458
417
  it 'detects the file removal' do
459
418
  fixtures do |path|
460
- if options[:recursive]
461
- listener.should_receive(:on_change).once.with([path], :recursive => true)
462
- else
463
- listener.should_receive(:on_change).once.with(["#{path}/a_directory/subdirectory"], {})
419
+ listener.should_receive(:on_change).once.with do |array|
420
+ array.should include("#{path}/a_directory/subdirectory")
464
421
  end
465
422
 
466
423
  mkdir_p 'a_directory/subdirectory'
467
424
  touch 'a_directory/subdirectory/do_not_use.rb'
468
425
 
469
- watch(listener, path) do
426
+ watch(listener, 1, path) do
470
427
  rm 'a_directory/subdirectory/do_not_use.rb'
471
428
  end
472
429
  end
@@ -478,15 +435,11 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
478
435
  context 'multiple file operations' do
479
436
  it 'detects the added files' do
480
437
  fixtures do |path|
481
- if options[:recursive]
482
- listener.should_receive(:on_change).at_least(:once).with([path], :recursive => true)
483
- else
484
- listener.should_receive(:on_change).once.with do |array, options|
485
- array.should =~ [path, "#{path}/a_directory"]
486
- end
438
+ listener.should_receive(:on_change).once.with do |array|
439
+ array.should include(path, "#{path}/a_directory")
487
440
  end
488
441
 
489
- watch(listener, path) do
442
+ watch(listener, 2, path) do
490
443
  touch 'a_file.rb'
491
444
  touch 'b_file.rb'
492
445
  mkdir 'a_directory'
@@ -501,12 +454,8 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
501
454
 
502
455
  it 'detects the modified files' do
503
456
  fixtures do |path|
504
- if options[:recursive]
505
- listener.should_receive(:on_change).once.with([path], :recursive => true)
506
- else
507
- listener.should_receive(:on_change).once.with do |array, options|
508
- array.should =~ [path, "#{path}/a_directory"]
509
- end
457
+ listener.should_receive(:on_change).once.with do |array|
458
+ array.should include(path, "#{path}/a_directory")
510
459
  end
511
460
 
512
461
  touch 'a_file.rb'
@@ -515,7 +464,7 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
515
464
  touch 'a_directory/a_file.rb'
516
465
  touch 'a_directory/b_file.rb'
517
466
 
518
- watch(listener, path) do
467
+ watch(listener, 2, path) do
519
468
  touch 'b_file.rb'
520
469
  touch 'a_directory/a_file.rb'
521
470
  end
@@ -524,12 +473,8 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
524
473
 
525
474
  it 'detects the removed files' do
526
475
  fixtures do |path|
527
- if options[:recursive]
528
- listener.should_receive(:on_change).once.with([path], :recursive => true)
529
- else
530
- listener.should_receive(:on_change).once.with do |array, options|
531
- array.should =~ [path, "#{path}/a_directory"]
532
- end
476
+ listener.should_receive(:on_change).once.with do |array|
477
+ array.should include(path, "#{path}/a_directory")
533
478
  end
534
479
 
535
480
  touch 'a_file.rb'
@@ -538,7 +483,7 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
538
483
  touch 'a_directory/a_file.rb'
539
484
  touch 'a_directory/b_file.rb'
540
485
 
541
- watch(listener, path) do
486
+ watch(listener, 2, path) do
542
487
  rm 'b_file.rb'
543
488
  rm 'a_directory/a_file.rb'
544
489
  end
@@ -549,17 +494,15 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
549
494
  context 'single directory operations' do
550
495
  it 'detects a moved directory' do
551
496
  fixtures do |path|
552
- if options[:recursive]
553
- listener.should_receive(:on_change).once.with([path], :recursive => true)
554
- else
555
- listener.should_receive(:on_change).once.with([path], {})
497
+ listener.should_receive(:on_change).once.with do |array|
498
+ array.should include(path)
556
499
  end
557
500
 
558
501
  mkdir 'a_directory'
559
502
  touch 'a_directory/a_file.rb'
560
503
  touch 'a_directory/b_file.rb'
561
504
 
562
- watch(listener, path) do
505
+ watch(listener, 1, path) do
563
506
  mv 'a_directory', 'renamed'
564
507
  end
565
508
  end
@@ -567,19 +510,15 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
567
510
 
568
511
  it 'detects a removed directory' do
569
512
  fixtures do |path|
570
- if options[:recursive]
571
- listener.should_receive(:on_change).once.with([path], :recursive => true)
572
- else
573
- listener.should_receive(:on_change).once.with do |array, options|
574
- array.should =~ [path, "#{path}/a_directory"]
575
- end
513
+ listener.should_receive(:on_change).once.with do |array|
514
+ array.should include(path, "#{path}/a_directory")
576
515
  end
577
516
 
578
517
  mkdir 'a_directory'
579
518
  touch 'a_directory/a_file.rb'
580
519
  touch 'a_directory/b_file.rb'
581
520
 
582
- watch(listener, path) do
521
+ watch(listener, 2, path) do
583
522
  rm_rf 'a_directory'
584
523
  end
585
524
  end
@@ -590,7 +529,7 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
590
529
  context 'when a file is created' do
591
530
  it "doesn't detects the added file" do
592
531
  fixtures do |path|
593
- watch(listener, path) do
532
+ watch(listener, 1, path) do # The expected changes param is set to one!
594
533
  @adapter.paused = true
595
534
  touch 'new_file.rb'
596
535
  end
@@ -604,13 +543,11 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
604
543
  context 'when files are added to one of multiple directories' do
605
544
  it 'detects added files' do
606
545
  fixtures(2) do |path1, path2|
607
- if options[:recursive]
608
- listener.should_receive(:on_change).once.with([path2], :recursive => true)
609
- else
610
- listener.should_receive(:on_change).once.with([path2], {})
546
+ listener.should_receive(:on_change).once.with do |array|
547
+ array.should include(path2)
611
548
  end
612
549
 
613
- watch(listener, path1, path2) do
550
+ watch(listener, 1, path1, path2) do
614
551
  touch "#{path2}/new_file.rb"
615
552
  end
616
553
  end
@@ -620,17 +557,11 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
620
557
  context 'when files are added to multiple directories' do
621
558
  it 'detects added files' do
622
559
  fixtures(2) do |path1, path2|
623
- if options[:recursive]
624
- listener.should_receive(:on_change).once.with do |directories, options|
625
- directories.should =~ [path1, path2] && options.should == {:recursive => true}
626
- end
627
- else
628
- listener.should_receive(:on_change).once.with do |directories, options|
629
- directories.should =~ [path1, path2] && options.should == {}
630
- end
560
+ listener.should_receive(:on_change).once.with do |array|
561
+ array.should include(path1, path2)
631
562
  end
632
563
 
633
- watch(listener, path1, path2) do
564
+ watch(listener, 2, path1, path2) do
634
565
  touch "#{path1}/new_file.rb"
635
566
  touch "#{path2}/new_file.rb"
636
567
  end
@@ -641,20 +572,15 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
641
572
  context 'given a new and an existing directory on multiple directories' do
642
573
  it 'detects the added file' do
643
574
  fixtures(2) do |path1, path2|
644
- if options[:recursive]
645
- listener.should_receive(:on_change).once.with do |directories, options|
646
- directories.should =~ [path1, path2] && options.should == {:recursive => true}
647
- end
648
- else
649
- listener.should_receive(:on_change).once.with do |directories, options|
650
- directories.should =~ [path2, "#{path2}/b_directory", "#{path1}/a_directory"] && options.should == {}
651
- end
575
+ listener.should_receive(:on_change).once.with do |array|
576
+ array.should include(path2, "#{path1}/a_directory", "#{path2}/b_directory")
652
577
  end
653
578
 
654
579
  mkdir "#{path1}/a_directory"
655
580
 
656
- watch(listener, path1, path2) do
581
+ watch(listener, 3, path1, path2) do
657
582
  mkdir "#{path2}/b_directory"
583
+ # Needed for INotify
658
584
  sleep 0.05
659
585
  touch "#{path1}/a_directory/new_file.rb"
660
586
  touch "#{path2}/b_directory/new_file.rb"
@@ -666,21 +592,15 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
666
592
  context 'when a file is moved between the multiple watched directories' do
667
593
  it 'detects the movements of the file' do
668
594
  fixtures(3) do |path1, path2, path3|
669
- if options[:recursive]
670
- listener.should_receive(:on_change).once.with do |directories, options|
671
- directories.should =~ [path1, path2, path3] && options.should == {:recursive => true}
672
- end
673
- else
674
- listener.should_receive(:on_change).once.with do |directories, options|
675
- directories.should =~ ["#{path1}/from_directory", path2, "#{path3}/to_directory"] && options.should == {}
676
- end
595
+ listener.should_receive(:on_change).once.with do |array|
596
+ array.should include("#{path1}/from_directory", path2, "#{path3}/to_directory")
677
597
  end
678
598
 
679
599
  mkdir "#{path1}/from_directory"
680
600
  touch "#{path1}/from_directory/move_me.txt"
681
601
  mkdir "#{path3}/to_directory"
682
602
 
683
- watch(listener, path1, path2, path3) do
603
+ watch(listener, 3, path1, path2, path3) do
684
604
  mv "#{path1}/from_directory/move_me.txt", "#{path2}/move_me.txt"
685
605
  mv "#{path2}/move_me.txt", "#{path3}/to_directory/move_me.txt"
686
606
  end
@@ -691,20 +611,14 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
691
611
  context 'when files are deleted from the multiple watched directories' do
692
612
  it 'detects the files removal' do
693
613
  fixtures(2) do |path1, path2|
694
- if options[:recursive]
695
- listener.should_receive(:on_change).once.with do |directories, options|
696
- directories.should =~ [path1, path2] && options.should == {:recursive => true}
697
- end
698
- else
699
- listener.should_receive(:on_change).once.with do |directories, options|
700
- directories.should =~ [path1, path2] && options.should == {}
701
- end
614
+ listener.should_receive(:on_change).once.with do |array|
615
+ array.should include(path1, path2)
702
616
  end
703
617
 
704
618
  touch "#{path1}/unnecessary.txt"
705
619
  touch "#{path2}/unnecessary.txt"
706
620
 
707
- watch(listener, path1, path2) do
621
+ watch(listener, 2, path1, path2) do
708
622
  rm "#{path1}/unnecessary.txt"
709
623
  rm "#{path2}/unnecessary.txt"
710
624
  end
@@ -712,5 +626,4 @@ shared_examples_for 'an adapter that call properly listener#on_change' do |*args
712
626
  end
713
627
  end
714
628
  end
715
-
716
629
  end