sass 3.1.21 → 3.2.0.alpha.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +5 -4
- data/REVISION +1 -1
- data/Rakefile +6 -15
- data/VERSION +1 -1
- data/VERSION_NAME +1 -1
- data/lib/sass.rb +0 -1
- data/lib/sass/cache_stores/base.rb +1 -3
- data/lib/sass/cache_stores/filesystem.rb +0 -3
- data/lib/sass/css.rb +49 -145
- data/lib/sass/engine.rb +23 -47
- data/lib/sass/environment.rb +5 -30
- data/lib/sass/exec.rb +7 -30
- data/lib/sass/importers/base.rb +1 -2
- data/lib/sass/importers/filesystem.rb +13 -18
- data/lib/sass/less.rb +1 -1
- data/lib/sass/plugin.rb +8 -4
- data/lib/sass/plugin/compiler.rb +67 -93
- data/lib/sass/plugin/configuration.rb +2 -0
- data/lib/sass/plugin/staleness_checker.rb +4 -14
- data/lib/sass/repl.rb +3 -2
- data/lib/sass/script.rb +1 -0
- data/lib/sass/script/color.rb +9 -4
- data/lib/sass/script/funcall.rb +3 -16
- data/lib/sass/script/functions.rb +55 -98
- data/lib/sass/script/interpolation.rb +0 -9
- data/lib/sass/script/lexer.rb +4 -2
- data/lib/sass/script/list.rb +0 -8
- data/lib/sass/script/literal.rb +20 -5
- data/lib/sass/script/node.rb +0 -8
- data/lib/sass/script/number.rb +11 -35
- data/lib/sass/script/operation.rb +0 -16
- data/lib/sass/script/parser.rb +5 -12
- data/lib/sass/script/string_interpolation.rb +0 -9
- data/lib/sass/script/unary_operation.rb +0 -7
- data/lib/sass/script/variable.rb +1 -5
- data/lib/sass/scss/parser.rb +54 -191
- data/lib/sass/scss/rx.rb +3 -15
- data/lib/sass/scss/static_parser.rb +3 -3
- data/lib/sass/selector.rb +3 -15
- data/lib/sass/selector/abstract_sequence.rb +2 -11
- data/lib/sass/selector/comma_sequence.rb +3 -8
- data/lib/sass/selector/sequence.rb +11 -74
- data/lib/sass/selector/simple.rb +1 -7
- data/lib/sass/selector/simple_sequence.rb +8 -28
- data/lib/sass/shared.rb +5 -3
- data/lib/sass/tree/comment_node.rb +12 -25
- data/lib/sass/tree/debug_node.rb +1 -1
- data/lib/sass/tree/directive_node.rb +0 -5
- data/lib/sass/tree/each_node.rb +1 -1
- data/lib/sass/tree/extend_node.rb +1 -1
- data/lib/sass/tree/for_node.rb +2 -2
- data/lib/sass/tree/function_node.rb +1 -1
- data/lib/sass/tree/if_node.rb +14 -1
- data/lib/sass/tree/media_node.rb +4 -4
- data/lib/sass/tree/mixin_def_node.rb +1 -1
- data/lib/sass/tree/mixin_node.rb +2 -2
- data/lib/sass/tree/node.rb +26 -10
- data/lib/sass/tree/return_node.rb +1 -1
- data/lib/sass/tree/root_node.rb +1 -1
- data/lib/sass/tree/rule_node.rb +11 -9
- data/lib/sass/tree/variable_node.rb +1 -1
- data/lib/sass/tree/visitors/base.rb +1 -1
- data/lib/sass/tree/visitors/check_nesting.rb +36 -29
- data/lib/sass/tree/visitors/convert.rb +9 -16
- data/lib/sass/tree/visitors/cssize.rb +9 -40
- data/lib/sass/tree/visitors/perform.rb +23 -79
- data/lib/sass/tree/visitors/to_css.rb +21 -23
- data/lib/sass/tree/warn_node.rb +1 -1
- data/lib/sass/tree/while_node.rb +1 -1
- data/lib/sass/util.rb +9 -147
- data/lib/sass/version.rb +0 -14
- data/test/sass/cache_test.rb +0 -15
- data/test/sass/conversion_test.rb +8 -50
- data/test/sass/css2sass_test.rb +0 -33
- data/test/sass/engine_test.rb +32 -283
- data/test/sass/extend_test.rb +0 -315
- data/test/sass/functions_test.rb +23 -60
- data/test/sass/importer_test.rb +0 -110
- data/test/sass/more_results/more_import.css +2 -2
- data/test/sass/plugin_test.rb +13 -40
- data/test/sass/results/import.css +2 -2
- data/test/sass/results/import_charset.css +0 -1
- data/test/sass/results/import_charset_1_8.css +0 -1
- data/test/sass/results/import_charset_ibm866.css +0 -1
- data/test/sass/results/scss_import.css +2 -2
- data/test/sass/results/units.css +1 -1
- data/test/sass/script_conversion_test.rb +0 -2
- data/test/sass/script_test.rb +4 -28
- data/test/sass/scss/css_test.rb +1 -79
- data/test/sass/scss/scss_test.rb +16 -96
- data/test/sass/templates/import_charset.sass +0 -2
- data/test/sass/templates/import_charset_1_8.sass +0 -2
- data/test/sass/templates/import_charset_ibm866.sass +0 -2
- data/test/sass/test_helper.rb +1 -1
- data/test/sass/util_test.rb +0 -28
- data/test/test_helper.rb +0 -2
- data/vendor/{listen → fssm}/LICENSE +1 -1
- data/vendor/fssm/README.markdown +55 -0
- data/vendor/fssm/Rakefile +59 -0
- data/vendor/fssm/VERSION.yml +5 -0
- data/vendor/fssm/example.rb +9 -0
- data/vendor/fssm/fssm.gemspec +77 -0
- data/vendor/fssm/lib/fssm.rb +33 -0
- data/vendor/fssm/lib/fssm/backends/fsevents.rb +36 -0
- data/vendor/fssm/lib/fssm/backends/inotify.rb +26 -0
- data/vendor/fssm/lib/fssm/backends/polling.rb +25 -0
- data/vendor/fssm/lib/fssm/backends/rubycocoa/fsevents.rb +131 -0
- data/vendor/fssm/lib/fssm/monitor.rb +26 -0
- data/vendor/fssm/lib/fssm/path.rb +91 -0
- data/vendor/fssm/lib/fssm/pathname.rb +502 -0
- data/vendor/fssm/lib/fssm/state/directory.rb +57 -0
- data/vendor/fssm/lib/fssm/state/file.rb +24 -0
- data/vendor/fssm/lib/fssm/support.rb +63 -0
- data/vendor/fssm/lib/fssm/tree.rb +176 -0
- data/vendor/fssm/profile/prof-cache.rb +40 -0
- data/vendor/fssm/profile/prof-fssm-pathname.html +1231 -0
- data/vendor/fssm/profile/prof-pathname.rb +68 -0
- data/vendor/fssm/profile/prof-plain-pathname.html +988 -0
- data/vendor/fssm/profile/prof.html +2379 -0
- data/vendor/fssm/spec/path_spec.rb +75 -0
- data/vendor/fssm/spec/root/duck/quack.txt +0 -0
- data/vendor/fssm/spec/root/file.css +0 -0
- data/vendor/fssm/spec/root/file.rb +0 -0
- data/vendor/fssm/spec/root/file.yml +0 -0
- data/vendor/fssm/spec/root/moo/cow.txt +0 -0
- data/vendor/fssm/spec/spec_helper.rb +14 -0
- metadata +246 -281
- data/VERSION_DATE +0 -1
- data/lib/sass/logger.rb +0 -15
- data/lib/sass/logger/base.rb +0 -32
- data/lib/sass/logger/log_level.rb +0 -49
- data/lib/sass/tree/visitors/deep_copy.rb +0 -87
- data/lib/sass/tree/visitors/extend.rb +0 -42
- data/lib/sass/tree/visitors/set_options.rb +0 -97
- data/lib/sass/util/multibyte_string_scanner.rb +0 -134
- data/test/Gemfile +0 -4
- data/test/Gemfile.lock +0 -19
- data/test/sass/fixtures/test_staleness_check_across_importers.css +0 -1
- data/test/sass/fixtures/test_staleness_check_across_importers.scss +0 -1
- data/test/sass/logger_test.rb +0 -58
- data/test/sass/templates/_double_import_loop2.sass +0 -1
- data/test/sass/templates/bork5.sass +0 -3
- data/test/sass/templates/double_import_loop1.sass +0 -1
- data/test/sass/templates/nested_bork5.sass +0 -2
- data/test/sass/templates/single_import_loop.sass +0 -1
- data/test/sass/util/multibyte_string_scanner_test.rb +0 -147
- data/vendor/listen/CHANGELOG.md +0 -147
- data/vendor/listen/Gemfile +0 -23
- data/vendor/listen/Guardfile +0 -8
- data/vendor/listen/README.md +0 -312
- data/vendor/listen/Rakefile +0 -47
- data/vendor/listen/Vagrantfile +0 -96
- data/vendor/listen/lib/listen.rb +0 -38
- data/vendor/listen/lib/listen/adapter.rb +0 -167
- data/vendor/listen/lib/listen/adapters/darwin.rb +0 -84
- data/vendor/listen/lib/listen/adapters/linux.rb +0 -110
- data/vendor/listen/lib/listen/adapters/polling.rb +0 -66
- data/vendor/listen/lib/listen/adapters/windows.rb +0 -81
- data/vendor/listen/lib/listen/directory_record.rb +0 -318
- data/vendor/listen/lib/listen/listener.rb +0 -203
- data/vendor/listen/lib/listen/multi_listener.rb +0 -121
- data/vendor/listen/lib/listen/turnstile.rb +0 -28
- data/vendor/listen/lib/listen/version.rb +0 -3
- data/vendor/listen/listen.gemspec +0 -26
- data/vendor/listen/spec/listen/adapter_spec.rb +0 -142
- data/vendor/listen/spec/listen/adapters/darwin_spec.rb +0 -31
- data/vendor/listen/spec/listen/adapters/linux_spec.rb +0 -41
- data/vendor/listen/spec/listen/adapters/polling_spec.rb +0 -68
- data/vendor/listen/spec/listen/adapters/windows_spec.rb +0 -24
- data/vendor/listen/spec/listen/directory_record_spec.rb +0 -1138
- data/vendor/listen/spec/listen/listener_spec.rb +0 -155
- data/vendor/listen/spec/listen/multi_listener_spec.rb +0 -156
- data/vendor/listen/spec/listen/turnstile_spec.rb +0 -56
- data/vendor/listen/spec/listen_spec.rb +0 -73
- data/vendor/listen/spec/spec_helper.rb +0 -18
- data/vendor/listen/spec/support/adapter_helper.rb +0 -716
- data/vendor/listen/spec/support/directory_record_helper.rb +0 -55
- data/vendor/listen/spec/support/fixtures_helper.rb +0 -29
- data/vendor/listen/spec/support/listeners_helper.rb +0 -144
- data/vendor/listen/spec/support/platform_helper.rb +0 -11
@@ -1,155 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Listen::Listener do
|
4
|
-
let(:adapter) { mock(Listen::Adapter, :start => true).as_null_object }
|
5
|
-
let(:watched_directory) { File.dirname(__FILE__) }
|
6
|
-
|
7
|
-
subject { described_class.new(watched_directory) }
|
8
|
-
|
9
|
-
before do
|
10
|
-
Listen::Adapter.stub(:select_and_initialize) { adapter }
|
11
|
-
# Don't build a record of the files inside the base directory.
|
12
|
-
subject.directory_record.stub(:build)
|
13
|
-
end
|
14
|
-
|
15
|
-
it_should_behave_like 'a listener to changes on a file-system'
|
16
|
-
|
17
|
-
describe '#initialize' do
|
18
|
-
context 'with no options' do
|
19
|
-
it 'sets the directory' do
|
20
|
-
subject.directory.should eq watched_directory
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'converts the passed path into an absolute path - #21' do
|
24
|
-
described_class.new(File.join(watched_directory, '..')).directory.should eq File.expand_path('..', watched_directory)
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'sets the option for using relative paths in the callback to the default one' do
|
28
|
-
subject.instance_variable_get(:@use_relative_paths).should eq described_class::DEFAULT_TO_RELATIVE_PATHS
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context 'with custom options' do
|
33
|
-
subject { described_class.new(watched_directory, :ignore => /\.ssh/, :filter => [/.*\.rb/,/.*\.md/],
|
34
|
-
:latency => 0.5, :force_polling => true, :relative_paths => true) }
|
35
|
-
|
36
|
-
it 'passes the custom ignored paths to the directory record' do
|
37
|
-
subject.directory_record.ignoring_patterns.should include /\.ssh/
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'passes the custom filters to the directory record' do
|
41
|
-
subject.directory_record.filtering_patterns.should =~ [/.*\.rb/,/.*\.md/]
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'sets the cutom option for using relative paths in the callback' do
|
45
|
-
subject.instance_variable_get(:@use_relative_paths).should be_true
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'sets adapter_options' do
|
49
|
-
subject.instance_variable_get(:@adapter_options).should eq(:latency => 0.5, :force_polling => true)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '#start' do
|
55
|
-
it 'selects and initializes an adapter' do
|
56
|
-
Listen::Adapter.should_receive(:select_and_initialize).with(watched_directory, {}) { adapter }
|
57
|
-
subject.start
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'builds the directory record' do
|
61
|
-
subject.directory_record.should_receive(:build)
|
62
|
-
subject.start
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
context 'with a started listener' do
|
67
|
-
before do
|
68
|
-
subject.stub(:initialize_adapter) { adapter }
|
69
|
-
subject.start
|
70
|
-
end
|
71
|
-
|
72
|
-
describe '#unpause' do
|
73
|
-
it 'rebuilds the directory record' do
|
74
|
-
subject.directory_record.should_receive(:build)
|
75
|
-
subject.unpause
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe '#ignore'do
|
81
|
-
it 'delegates the work to the directory record' do
|
82
|
-
subject.directory_record.should_receive(:ignore).with 'some_directory'
|
83
|
-
subject.ignore 'some_directory'
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe '#filter' do
|
88
|
-
it 'delegates the work to the directory record' do
|
89
|
-
subject.directory_record.should_receive(:filter).with /\.txt$/
|
90
|
-
subject.filter /\.txt$/
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
|
-
|
95
|
-
describe '#on_change' do
|
96
|
-
let(:directories) { %w{dir1 dir2 dir3} }
|
97
|
-
let(:changes) { {:modified => [], :added => [], :removed => []} }
|
98
|
-
let(:callback) { Proc.new { @called = true } }
|
99
|
-
|
100
|
-
before do
|
101
|
-
@called = false
|
102
|
-
subject.directory_record.stub(:fetch_changes => changes)
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'fetches the changes of the directory record' do
|
106
|
-
subject.directory_record.should_receive(:fetch_changes).with(
|
107
|
-
directories, hash_including(:relative_paths => described_class::DEFAULT_TO_RELATIVE_PATHS)
|
108
|
-
)
|
109
|
-
subject.on_change(directories)
|
110
|
-
end
|
111
|
-
|
112
|
-
context 'with relative paths option set to true' do
|
113
|
-
subject { described_class.new(watched_directory, :relative_paths => true) }
|
114
|
-
|
115
|
-
it 'fetches the changes of the directory record' do
|
116
|
-
subject.directory_record.should_receive(:fetch_changes).with(directories, hash_including(:relative_paths => true))
|
117
|
-
subject.on_change(directories)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
context 'with no changes to report' do
|
122
|
-
if RUBY_VERSION[/^1.8/]
|
123
|
-
it 'does not run the callback' do
|
124
|
-
subject.change(&callback)
|
125
|
-
subject.on_change(directories)
|
126
|
-
@called.should be_false
|
127
|
-
end
|
128
|
-
else
|
129
|
-
it 'does not run the callback' do
|
130
|
-
callback.should_not_receive(:call)
|
131
|
-
subject.change(&callback)
|
132
|
-
subject.on_change(directories)
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
context 'with changes to report' do
|
138
|
-
let(:changes) { {:modified => %w{path1}, :added => [], :removed => %w{path2}} }
|
139
|
-
|
140
|
-
if RUBY_VERSION[/^1.8/]
|
141
|
-
it 'runs the callback passing it the changes' do
|
142
|
-
subject.change(&callback)
|
143
|
-
subject.on_change(directories)
|
144
|
-
@called.should be_true
|
145
|
-
end
|
146
|
-
else
|
147
|
-
it 'runs the callback passing it the changes' do
|
148
|
-
callback.should_receive(:call).with(changes[:modified], changes[:added], changes[:removed])
|
149
|
-
subject.change(&callback)
|
150
|
-
subject.on_change(directories)
|
151
|
-
end
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
@@ -1,156 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Listen::MultiListener do
|
4
|
-
let(:adapter) { mock(Listen::Adapter, :start => true).as_null_object }
|
5
|
-
let(:watched_directories) { [File.dirname(__FILE__), File.expand_path('../..', __FILE__)] }
|
6
|
-
|
7
|
-
subject { described_class.new(*watched_directories) }
|
8
|
-
|
9
|
-
before do
|
10
|
-
Listen::Adapter.stub(:select_and_initialize) { adapter }
|
11
|
-
# Don't build a record of the files inside the base directory.
|
12
|
-
Listen::DirectoryRecord.any_instance.stub(:build)
|
13
|
-
end
|
14
|
-
|
15
|
-
it_should_behave_like 'a listener to changes on a file-system'
|
16
|
-
|
17
|
-
describe '#initialize' do
|
18
|
-
context 'with no options' do
|
19
|
-
it 'sets the directories' do
|
20
|
-
subject.directories.should =~ watched_directories
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'converts the passed paths into absolute paths - #21' do
|
24
|
-
paths = watched_directories.map { |d| File.join(d, '..') }
|
25
|
-
described_class.new(*paths).directories.should =~ watched_directories.map{ |d| File.expand_path('..', d) }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with custom options' do
|
30
|
-
subject do
|
31
|
-
args = watched_directories << {:ignore => /\.ssh/, :filter => [/.*\.rb/,/.*\.md/], :latency => 0.5, :force_polling => true}
|
32
|
-
described_class.new(*args)
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'passes the custom ignored paths to each directory record' do
|
36
|
-
subject.directories_records.each do |r|
|
37
|
-
r.ignoring_patterns.should include /\.ssh/
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'passes the custom filters to each directory record' do
|
42
|
-
subject.directories_records.each do |r|
|
43
|
-
r.filtering_patterns.should =~ [/.*\.rb/,/.*\.md/]
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'sets adapter_options' do
|
48
|
-
subject.instance_variable_get(:@adapter_options).should eq(:latency => 0.5, :force_polling => true)
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#start' do
|
54
|
-
it 'selects and initializes an adapter' do
|
55
|
-
Listen::Adapter.should_receive(:select_and_initialize).with(watched_directories, {}) { adapter }
|
56
|
-
subject.start
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'builds all directories records' do
|
60
|
-
subject.directories_records.each do |r|
|
61
|
-
r.should_receive(:build)
|
62
|
-
end
|
63
|
-
subject.start
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'with a started listener' do
|
68
|
-
before do
|
69
|
-
subject.stub(:initialize_adapter) { adapter }
|
70
|
-
subject.start
|
71
|
-
end
|
72
|
-
|
73
|
-
describe '#unpause' do
|
74
|
-
it 'rebuilds all directories records' do
|
75
|
-
subject.directories_records.each do |r|
|
76
|
-
r.should_receive(:build)
|
77
|
-
end
|
78
|
-
subject.unpause
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
describe '#ignore'do
|
84
|
-
it 'delegates the work to each directory record' do
|
85
|
-
subject.directories_records.each do |r|
|
86
|
-
r.should_receive(:ignore).with 'some_directory'
|
87
|
-
end
|
88
|
-
subject.ignore 'some_directory'
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
describe '#filter' do
|
93
|
-
it 'delegates the work to each directory record' do
|
94
|
-
subject.directories_records.each do |r|
|
95
|
-
r.should_receive(:filter).with /\.txt$/
|
96
|
-
end
|
97
|
-
subject.filter /\.txt$/
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
describe '#on_change' do
|
102
|
-
let(:directories) { %w{dir1 dir2 dir3} }
|
103
|
-
let(:changes) { {:modified => [], :added => [], :removed => []} }
|
104
|
-
let(:callback) { Proc.new { @called = true } }
|
105
|
-
|
106
|
-
before do
|
107
|
-
@called = false
|
108
|
-
subject.stub(:fetch_records_changes => changes)
|
109
|
-
end
|
110
|
-
|
111
|
-
it 'fetches the changes of all directories records' do
|
112
|
-
subject.unstub(:fetch_records_changes)
|
113
|
-
|
114
|
-
subject.directories_records.each do |record|
|
115
|
-
record.should_receive(:fetch_changes).with(
|
116
|
-
directories, hash_including(:relative_paths => described_class::DEFAULT_TO_RELATIVE_PATHS)
|
117
|
-
).and_return(changes)
|
118
|
-
end
|
119
|
-
subject.on_change(directories)
|
120
|
-
end
|
121
|
-
|
122
|
-
context 'with no changes to report' do
|
123
|
-
if RUBY_VERSION[/^1.8/]
|
124
|
-
it 'does not run the callback' do
|
125
|
-
subject.change(&callback)
|
126
|
-
subject.on_change(directories)
|
127
|
-
@called.should be_false
|
128
|
-
end
|
129
|
-
else
|
130
|
-
it 'does not run the callback' do
|
131
|
-
callback.should_not_receive(:call)
|
132
|
-
subject.change(&callback)
|
133
|
-
subject.on_change(directories)
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
context 'with changes to report' do
|
139
|
-
let(:changes) { {:modified => %w{path1}, :added => [], :removed => %w{path2}} }
|
140
|
-
|
141
|
-
if RUBY_VERSION[/^1.8/]
|
142
|
-
it 'runs the callback passing it the changes' do
|
143
|
-
subject.change(&callback)
|
144
|
-
subject.on_change(directories)
|
145
|
-
@called.should be_true
|
146
|
-
end
|
147
|
-
else
|
148
|
-
it 'runs the callback passing it the changes' do
|
149
|
-
callback.should_receive(:call).with(changes[:modified], changes[:added], changes[:removed])
|
150
|
-
subject.change(&callback)
|
151
|
-
subject.on_change(directories)
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
156
|
-
end
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
def run_in_two_threads(proc1, proc2)
|
4
|
-
t1 = Thread.new &proc1
|
5
|
-
sleep test_latency # t1 must run before t2
|
6
|
-
t2 = Thread.new { proc2.call; Thread.kill t1 }
|
7
|
-
t2.join(test_latency * 2)
|
8
|
-
ensure
|
9
|
-
Thread.kill t1 if t1
|
10
|
-
Thread.kill t2 if t2
|
11
|
-
end
|
12
|
-
|
13
|
-
describe Listen::Turnstile do
|
14
|
-
before { @called = false }
|
15
|
-
|
16
|
-
describe '#wait' do
|
17
|
-
context 'without a signal' do
|
18
|
-
it 'blocks one thread indefinitely' do
|
19
|
-
run_in_two_threads lambda {
|
20
|
-
subject.wait
|
21
|
-
@called = true
|
22
|
-
}, lambda {
|
23
|
-
sleep test_latency
|
24
|
-
}
|
25
|
-
@called.should be_false
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with a signal' do
|
30
|
-
it 'blocks one thread until it recieves a signal from another thread' do
|
31
|
-
run_in_two_threads lambda {
|
32
|
-
subject.wait
|
33
|
-
@called = true
|
34
|
-
}, lambda {
|
35
|
-
subject.signal
|
36
|
-
sleep test_latency
|
37
|
-
}
|
38
|
-
@called.should be_true
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe '#signal' do
|
44
|
-
context 'without a wait-call before' do
|
45
|
-
it 'does nothing' do
|
46
|
-
run_in_two_threads lambda {
|
47
|
-
subject.signal
|
48
|
-
@called = true
|
49
|
-
}, lambda {
|
50
|
-
sleep test_latency
|
51
|
-
}
|
52
|
-
@called.should be_true
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Listen do
|
4
|
-
describe '#to' do
|
5
|
-
context 'with one path to listen to' do
|
6
|
-
let(:listener) { mock(Listen::Listener) }
|
7
|
-
let(:listener_class) { Listen::Listener }
|
8
|
-
|
9
|
-
before { listener_class.stub(:new => listener) }
|
10
|
-
|
11
|
-
context 'without options' do
|
12
|
-
it 'creates an instance of Listner' do
|
13
|
-
listener_class.should_receive(:new).with('/path')
|
14
|
-
described_class.to('/path')
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
context 'with options' do
|
19
|
-
it 'creates an instance of Listner with the passed params' do
|
20
|
-
listener_class.should_receive(:new).with('/path', :filter => '**/*')
|
21
|
-
described_class.to('/path', :filter => '**/*')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'without a block' do
|
26
|
-
it 'returns the listener' do
|
27
|
-
described_class.to('/path', :filter => '**/*').should eq listener
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
context 'with a block' do
|
32
|
-
it 'starts the listner after creating it' do
|
33
|
-
listener.should_receive(:start)
|
34
|
-
described_class.to('/path', :filter => '**/*') { |modified, added, removed| }
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'with multiple paths to listen to' do
|
40
|
-
let(:multi_listener) { mock(Listen::MultiListener) }
|
41
|
-
let(:multi_listener_class) { Listen::MultiListener }
|
42
|
-
|
43
|
-
before { multi_listener_class.stub(:new => multi_listener) }
|
44
|
-
|
45
|
-
context 'without options' do
|
46
|
-
it 'creates an instance of MultiListner' do
|
47
|
-
multi_listener_class.should_receive(:new).with('path1', 'path2')
|
48
|
-
described_class.to('path1', 'path2')
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
context 'with options' do
|
53
|
-
it 'creates an instance of MultiListner with the passed params' do
|
54
|
-
multi_listener_class.should_receive(:new).with('path1', 'path2', :filter => '**/*')
|
55
|
-
described_class.to('path1', 'path2', :filter => '**/*')
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'without a block' do
|
60
|
-
it 'returns a MultiListener instance created with the passed params' do
|
61
|
-
described_class.to('path1', 'path2', :filter => '**/*').should eq multi_listener
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
context 'with a block' do
|
66
|
-
it 'starts a MultiListener instance after creating it with the passed params' do
|
67
|
-
multi_listener.should_receive(:start)
|
68
|
-
described_class.to('path1', 'path2', :filter => '**/*') { |modified, added, removed| }
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'listen'
|
2
|
-
|
3
|
-
ENV["TEST_LATENCY"] ||= "0.25"
|
4
|
-
|
5
|
-
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
6
|
-
|
7
|
-
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
8
|
-
RSpec.configure do |config|
|
9
|
-
config.color_enabled = true
|
10
|
-
config.order = :random
|
11
|
-
config.filter_run :focus => true
|
12
|
-
config.treat_symbols_as_metadata_keys_with_true_values = true
|
13
|
-
config.run_all_when_everything_filtered = true
|
14
|
-
end
|
15
|
-
|
16
|
-
def test_latency
|
17
|
-
ENV["TEST_LATENCY"].to_f
|
18
|
-
end
|