sass 3.2.19 → 3.3.0.alpha.1

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