Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'master' of https://github.com/niklas/guard into niklas-…

…master

Conflicts:
	lib/guard/listener.rb
	spec/guard/listeners/linux_spec.rb
  • Loading branch information...
commit 6a77f01645711215b4cd8003f0b4a30eaa5413b5 2 parents 1628a1f + b12769d
Thibaud Guillaume-Gentil thibaudgg authored
61 lib/guard/listener.rb
@@ -9,35 +9,80 @@ module Guard
9 9 autoload :Polling, 'guard/listeners/polling'
10 10
11 11 class Listener
12   - attr_reader :last_event, :sha1_checksums_hash
  12 + attr_reader :last_event, :sha1_checksums_hash, :directory, :callback
13 13
14   - def self.select_and_init
  14 + def self.select_and_init(*a)
15 15 if mac? && Darwin.usable?
16   - Darwin.new
  16 + Darwin.new(*a)
17 17 elsif linux? && Linux.usable?
18   - Linux.new
  18 + Linux.new(*a)
19 19 elsif windows? && Windows.usable?
20   - Windows.new
  20 + Windows.new(*a)
21 21 else
22 22 UI.info "Using polling (Please help us to support your system better than that.)"
23   - Polling.new
  23 + Polling.new(*a)
24 24 end
25 25 end
26 26
27   - def initialize
  27 + def initialize(directory=Dir.pwd, options={})
  28 + @directory = directory.to_s
28 29 @sha1_checksums_hash = {}
  30 + @relativate_paths = options.fetch(:relativate_paths, true)
29 31 update_last_event
30 32 end
31 33
  34 + def start
  35 + watch directory
  36 + end
  37 +
  38 + def stop
  39 + end
  40 +
  41 + def on_change(&callback)
  42 + @callback = callback
  43 + end
  44 +
32 45 def update_last_event
33 46 @last_event = Time.now
34 47 end
35 48
36 49 def modified_files(dirs, options = {})
  50 +# <<<<<<< HEAD
  51 +# files = potentially_modified_files(dirs, options).select { |path| File.file?(path) && file_modified?(path) }
  52 +# files.map! { |file| file.gsub("#{Dir.pwd}/", '') }
  53 +# =======
37 54 files = potentially_modified_files(dirs, options).select { |path| File.file?(path) && file_modified?(path) }
38   - files.map! { |file| file.gsub("#{Dir.pwd}/", '') }
  55 + relativate_paths files
  56 + end
  57 +
  58 + def worker
  59 + raise NotImplementedError, "should respond to #watch"
  60 + end
  61 +
  62 + # register a directory to watch. must be implemented by the subclasses
  63 + def watch(directory)
  64 + raise NotImplementedError, "do whatever you want here, given the directory as only argument"
  65 + end
  66 +
  67 + def all_files
  68 + potentially_modified_files [directory + '/'], :all => true
  69 +# >>>>>>> b12769d2bf385b3c69973721144cae3d5d8fbed9
39 70 end
40 71
  72 + # scopes all given paths to the current #directory
  73 + def relativate_paths(paths)
  74 + return paths unless relativate_paths?
  75 + paths.map do |path|
  76 + path.gsub(%r~^#{directory}/~, '')
  77 + end
  78 + end
  79 +
  80 + attr_writer :relativate_paths
  81 + def relativate_paths?
  82 + !!@relativate_paths
  83 + end
  84 +
  85 +
41 86 private
42 87
43 88 def potentially_modified_files(dirs, options = {})
26 lib/guard/listeners/darwin.rb
@@ -2,25 +2,23 @@ module Guard
2 2 class Darwin < Listener
3 3 attr_reader :fsevent
4 4
5   - def initialize
  5 + def initialize(*)
6 6 super
7 7 @fsevent = FSEvent.new
8 8 end
9 9
10   - def on_change(&callback)
11   - @fsevent.watch Dir.pwd do |modified_dirs|
12   - files = modified_files(modified_dirs)
13   - update_last_event
14   - callback.call(files)
15   - end
  10 + def worker
  11 + @fsevent
16 12 end
17 13
18 14 def start
19   - @fsevent.run
  15 + super
  16 + fsevent.run
20 17 end
21 18
22 19 def stop
23   - @fsevent.stop
  20 + super
  21 + fsevent.stop
24 22 end
25 23
26 24 def self.usable?
@@ -36,5 +34,15 @@ def self.usable?
36 34 false
37 35 end
38 36
  37 + private
  38 +
  39 + def watch(directory)
  40 + worker.watch directory do |modified_dirs|
  41 + files = modified_files(modified_dirs)
  42 + update_last_event
  43 + callback.call(files)
  44 + end
  45 + end
  46 +
39 47 end
40 48 end
32 lib/guard/listeners/linux.rb
... ... @@ -1,8 +1,8 @@
1 1 module Guard
2 2 class Linux < Listener
3   - attr_reader :inotify, :files, :latency, :callback
  3 + attr_reader :inotify, :files, :latency
4 4
5   - def initialize
  5 + def initialize(*)
6 6 super
7 7
8 8 @inotify = INotify::Notifier.new
@@ -12,24 +12,16 @@ def initialize
12 12
13 13 def start
14 14 @stop = false
  15 + super
15 16 watch_change unless watch_change?
16 17 end
17 18
18 19 def stop
  20 + super
19 21 @stop = true
20 22 sleep latency
21 23 end
22 24
23   - def on_change(&callback)
24   - @callback = callback
25   - inotify.watch(Dir.pwd, :recursive, :modify, :create, :delete, :move) do |event|
26   - unless event.name == "" # Event on root directory
27   - @files << event.absolute_name
28   - end
29   - end
30   - rescue Interrupt
31   - end
32   -
33 25 def self.usable?
34 26 require 'rb-inotify'
35 27 if !defined?(INotify::VERSION) || Gem::Version.new(INotify::VERSION.join('.')) < Gem::Version.new('0.5.1')
@@ -49,6 +41,19 @@ def watch_change?
49 41
50 42 private
51 43
  44 + def worker
  45 + @inotify
  46 + end
  47 +
  48 + def watch(directory)
  49 + worker.watch(directory, :recursive, :modify, :create) do |event|
  50 + unless event.name == "" # Event on root directory
  51 + @files << event.absolute_name
  52 + end
  53 + end
  54 + rescue Interrupt
  55 + end
  56 +
52 57 def watch_change
53 58 @watch_change = true
54 59 until @stop
@@ -61,8 +66,7 @@ def watch_change
61 66
62 67 unless files.empty?
63 68 files.uniq!
64   - files.map! { |file| file.gsub("#{Dir.pwd}/", '') }
65   - callback.call(files)
  69 + callback.call( relativate_paths(files) )
66 70 files.clear
67 71 end
68 72 end
16 lib/guard/listeners/polling.rb
... ... @@ -1,22 +1,20 @@
1 1 module Guard
2 2 class Polling < Listener
3   - attr_reader :callback, :latency
  3 + attr_reader :latency
4 4
5   - def initialize
  5 + def initialize(*)
6 6 super
7 7 @latency = 1.5
8 8 end
9 9
10   - def on_change(&callback)
11   - @callback = callback
12   - end
13   -
14 10 def start
15 11 @stop = false
  12 + super
16 13 watch_change
17 14 end
18 15
19 16 def stop
  17 + super
20 18 @stop = true
21 19 end
22 20
@@ -27,11 +25,15 @@ def watch_change
27 25 start = Time.now.to_f
28 26 files = modified_files([Dir.pwd + '/'], :all => true)
29 27 update_last_event
30   - callback.call(files) unless files.empty?
  28 + callback.call(relativate_paths(files)) unless files.empty?
31 29 nap_time = latency - (Time.now.to_f - start)
32 30 sleep(nap_time) if nap_time > 0
33 31 end
34 32 end
35 33
  34 + def watch(directory)
  35 + @existing = all_files
  36 + end
  37 +
36 38 end
37 39 end
26 lib/guard/listeners/windows.rb
@@ -7,20 +7,13 @@ def initialize
7 7 @fchange = FChange::Notifier.new
8 8 end
9 9
10   - def on_change(&callback)
11   - @fchange.watch(Dir.pwd, :all_events, :recursive) do |event|
12   - paths = [File.expand_path(event.watcher.path) + '/']
13   - files = modified_files(paths, {:all => true})
14   - update_last_event
15   - callback.call(files)
16   - end
17   - end
18   -
19 10 def start
  11 + super
20 12 @fchange.run
21 13 end
22 14
23 15 def stop
  16 + super
24 17 @fchange.stop
25 18 end
26 19
@@ -32,5 +25,20 @@ def self.usable?
32 25 false
33 26 end
34 27
  28 + private
  29 +
  30 + def worker
  31 + @fchange
  32 + end
  33 +
  34 + def watch(directory)
  35 + worker.watch(directory, :all_events, :recursive) do |event|
  36 + paths = [File.expand_path(event.watcher.path) + '/']
  37 + files = modified_files(paths, {:all => true})
  38 + update_last_event
  39 + callback.call(files)
  40 + end
  41 + end
  42 +
35 43 end
36 44 end
68 spec/guard/listener_spec.rb
@@ -27,6 +27,39 @@
27 27 Guard::Linux.should_receive(:new)
28 28 subject.select_and_init
29 29 end
  30 +
  31 + it "forwards its arguments to the constructor" do
  32 + subject.stub!(:mac?).and_return(true)
  33 + Guard::Darwin.stub!(:usable?).and_return(true)
  34 +
  35 + path, opts = 'path', {:foo => 23}
  36 + Guard::Darwin.should_receive(:new).with(path, opts).and_return(true)
  37 + subject.select_and_init path, opts
  38 + end
  39 + end
  40 +
  41 + describe "#all_files" do
  42 + subject { described_class.new(@fixture_path) }
  43 +
  44 + it "should return all files" do
  45 + subject.all_files.should =~ Dir.glob("#{@fixture_path}/**/*")
  46 + end
  47 + end
  48 +
  49 + describe "#relativate_paths" do
  50 + subject { described_class.new('/tmp') }
  51 + before :each do
  52 + @paths = %w( /tmp/a /tmp/a/b /tmp/a.b/c.d )
  53 + end
  54 +
  55 + it "should relativate paths to the configured directory" do
  56 + subject.relativate_paths(@paths).should =~ %w( a a/b a.b/c.d )
  57 + end
  58 +
  59 + it "can be disabled" do
  60 + subject.relativate_paths = false
  61 + subject.relativate_paths(@paths).should == @paths
  62 + end
30 63 end
31 64
32 65 describe "#update_last_event" do
@@ -91,4 +124,39 @@
91 124 end
92 125 end
93 126
  127 + describe "working directory" do
  128 +
  129 + context "unspecified" do
  130 + subject { described_class.new }
  131 + it "defaults to Dir.pwd" do
  132 + subject.directory.should == Dir.pwd
  133 + end
  134 + it "can be not changed" do
  135 + subject.should_not respond_to(:directory=)
  136 + end
  137 + end
  138 +
  139 + context "specified as first argument to ::new" do
  140 + before :each do
  141 + @wd = @fixture_path.join("folder1")
  142 + end
  143 + subject { described_class.new @wd }
  144 + it "can be inspected" do
  145 + subject.directory.should == @wd.to_s
  146 + end
  147 + it "can be not changed" do
  148 + subject.should_not respond_to(:directory=)
  149 + end
  150 +
  151 + it "will be used to watch" do
  152 + subject.should_receive(:watch).with(@wd.to_s)
  153 + @listener = subject # indeed.
  154 + start
  155 + stop
  156 + end
  157 + end
  158 +
  159 + end
  160 +
  161 +
94 162 end
62 spec/guard/listeners/darwin_spec.rb
@@ -4,6 +4,12 @@
4 4 describe Guard::Darwin do
5 5 subject { Guard::Darwin }
6 6
  7 + if windows?
  8 + it "isn't usable on windows" do
  9 + subject.should_not be_usable
  10 + end
  11 + end
  12 +
7 13 if linux?
8 14 it "isn't usable on linux" do
9 15 subject.should_not be_usable
@@ -15,61 +21,9 @@
15 21 subject.should be_usable
16 22 end
17 23
18   - describe "#on_change" do
19   - before(:each) do
20   - @results = []
21   - @listener = Guard::Darwin.new
22   - @listener.on_change do |files|
23   - @results += files
24   - end
25   - end
26   -
27   - it "catches a new file" do
28   - file = @fixture_path.join("newfile.rb")
29   - File.exists?(file).should be_false
30   - start
31   - FileUtils.touch file
32   - stop
33   - File.delete file
34   - @results.should == ['spec/fixtures/newfile.rb']
35   - end
36   -
37   - it "catches a single file update" do
38   - file = @fixture_path.join("folder1/file1.txt")
39   - File.exists?(file).should be_true
40   - start
41   - FileUtils.touch file
42   - stop
43   - @results.should == ['spec/fixtures/folder1/file1.txt']
44   - end
45   -
46   - it "catches multiple file updates" do
47   - file1 = @fixture_path.join("folder1/file1.txt")
48   - file2 = @fixture_path.join("folder1/folder2/file2.txt")
49   - File.exists?(file1).should be_true
50   - File.exists?(file2).should be_true
51   - start
52   - FileUtils.touch file1
53   - FileUtils.touch file2
54   - stop
55   - @results.should == ['spec/fixtures/folder1/file1.txt', 'spec/fixtures/folder1/folder2/file2.txt']
56   - end
57   - end
58   - end
59   -
60   -private
61   -
62   - def start
63   - sleep 1
64   - @listener.update_last_event
65   - Thread.new { @listener.start }
66   - sleep 1
67   - end
  24 + it_should_behave_like "a listener that reacts to #on_change"
  25 + it_should_behave_like "a listener scoped to a specific directory"
68 26
69   - def stop
70   - sleep 1
71   - @listener.stop
72   - sleep 1
73 27 end
74 28
75 29 end
101 spec/guard/listeners/linux_spec.rb
@@ -11,6 +11,12 @@
11 11 end
12 12 end
13 13
  14 + if windows?
  15 + it "isn't usable on windows" do
  16 + subject.should_not be_usable
  17 + end
  18 + end
  19 +
14 20 if linux? && Guard::Linux.usable?
15 21 it "is usable on linux" do
16 22 subject.should be_usable
@@ -37,95 +43,24 @@
37 43 stop
38 44 @listener.should_not be_watch_change
39 45 end
40   -
41 46 end
42 47
43   - describe "#on_change", :long_running=> true do
44   - before(:each) do
45   - @results = []
46   - @listener = Guard::Linux.new
47   - @listener.on_change do |files|
48   - @results += files
49   - end
50   - end
51   -
52   - it "catches a new file" do
53   - file = @fixture_path.join("newfile.rb")
54   - File.exists?(file).should be_false
55   - start
56   - FileUtils.touch file
57   - stop
58   - File.delete file
59   - @results.should == ['fixtures/newfile.rb']
60   - end
61   -
62   - it "catches a single file update" do
63   - file = @fixture_path.join("folder1/file1.txt")
64   - File.exists?(file).should be_true
65   - start
66   - File.open(file, 'w') {|f| f.write('') }
67   - stop
68   - @results.should == ['fixtures/folder1/file1.txt']
69   - end
70   -
71   - it "catches multiple file updates" do
72   - file1 = @fixture_path.join("folder1/file1.txt")
73   - file2 = @fixture_path.join("folder1/folder2/file2.txt")
74   - File.exists?(file1).should be_true
75   - File.exists?(file2).should be_true
76   - start
77   - File.open(file1, 'w') {|f| f.write('') }
78   - File.open(file2, 'w') {|f| f.write('') }
79   - stop
80   - @results.should == ['fixtures/folder1/file1.txt', 'fixtures/folder1/folder2/file2.txt']
81   - end
  48 + it_should_behave_like "a listener that reacts to #on_change"
  49 + it_should_behave_like "a listener scoped to a specific directory"
82 50
83   - it "catches a deleted file" do
84   - file = @fixture_path.join("folder1/file1.txt")
85   - File.exists?(file).should be_true
86   - start
87   - File.delete file
88   - stop
89   - FileUtils.touch file
90   - @results.should == ['fixtures/folder1/file1.txt']
91   - end
  51 + # Fun fact: File.touch seems not to be enough on Linux to trigger a modify event
92 52
93   - it "catches a moved file" do
94   - file1 = @fixture_path.join("folder1/file1.txt")
95   - file2 = @fixture_path.join("folder1/movedfile1.txt")
96   - File.exists?(file1).should be_true
97   - File.exists?(file2).should be_false
98   - start
99   - FileUtils.mv file1, file2
100   - stop
101   - FileUtils.mv file2, file1
102   - @results.should == ['fixtures/folder1/file1.txt', 'fixtures/folder1/movedfile1.txt']
103   - end
104   -
105   - it "doesn't process a change when it is stopped" do
106   - file = @fixture_path.join("folder1/file1.txt")
107   - File.exists?(file).should be_true
108   - start
109   - @listener.inotify.should_not_receive(:process)
110   - stop
111   - File.open(file, 'w') {|f| f.write('') }
112   - end
  53 + it "doesn't process a change when it is stopped" do
  54 + @listener = described_class.new
  55 + record_results
  56 + file = @fixture_path.join("folder1/file1.txt")
  57 + File.exists?(file).should be_true
  58 + start
  59 + @listener.inotify.should_not_receive(:process)
  60 + stop
  61 + File.open(file, 'w') {|f| f.write('') }
113 62 end
114   - end
115   -
116   -private
117   -
118   - def start
119   - sleep 1
120   - @listener.update_last_event
121   - Thread.new { @listener.start }
122   - sleep 1
123   - end
124 63
125   - def stop
126   - sleep 1
127   - @listener.stop
128   - sleep 1
129 64 end
130 65
131 66 end
57 spec/guard/listeners/polling_spec.rb
@@ -3,60 +3,9 @@
3 3
4 4 describe Guard::Polling do
5 5
6   - before(:each) do
7   - @results = []
8   - @listener = Guard::Polling.new
9   - @listener.on_change do |files|
10   - @results += files
11   - end
12   - end
  6 + subject { Guard::Polling }
13 7
14   - describe "#on_change" do
15   - it "catches a new file" do
16   - file = @fixture_path.join("newfile.rb")
17   - File.exists?(file).should be_false
18   - start
19   - FileUtils.touch file
20   - stop
21   - File.delete file
22   - @results.should == ['spec/fixtures/newfile.rb']
23   - end
24   -
25   - it "catches a single file update" do
26   - file = @fixture_path.join("folder1/file1.txt")
27   - File.exists?(file).should be_true
28   - start
29   - FileUtils.touch file
30   - stop
31   - @results.should == ['spec/fixtures/folder1/file1.txt']
32   - end
33   -
34   - it "catches multiple file updates" do
35   - file1 = @fixture_path.join("folder1/file1.txt")
36   - file2 = @fixture_path.join("folder1/folder2/file2.txt")
37   - File.exists?(file1).should be_true
38   - File.exists?(file2).should be_true
39   - start
40   - FileUtils.touch file1
41   - FileUtils.touch file2
42   - stop
43   - @results.should =~ ['spec/fixtures/folder1/file1.txt', 'spec/fixtures/folder1/folder2/file2.txt']
44   - end
45   - end
46   -
47   -private
48   -
49   - def start
50   - sleep 1
51   - @listener.update_last_event
52   - Thread.new { @listener.start }
53   - sleep 1
54   - end
55   -
56   - def stop
57   - sleep 1
58   - @listener.stop
59   - sleep 1
60   - end
  8 + it_should_behave_like "a listener that reacts to #on_change"
  9 + it_should_behave_like "a listener scoped to a specific directory"
61 10
62 11 end
65 spec/guard/listeners/windows_spec.rb
@@ -21,70 +21,9 @@
21 21 subject.should be_usable
22 22 end
23 23
24   - describe "#on_change" do
25   - before(:each) do
26   - @results = []
27   - @listener = Guard::Windows.new
28   - @listener.on_change do |files|
29   - @results += files
30   - end
31   - end
  24 + it_should_behave_like "a listener that reacts to #on_change"
  25 + it_should_behave_like "a listener scoped to a specific directory"
32 26
33   - it "catches a new file" do
34   - file = @fixture_path.join("newfile.rb")
35   - if File.exists?(file)
36   - begin
37   - File.delete file
38   - rescue
39   - end
40   - end
41   - File.exists?(file).should be_false
42   - start
43   - FileUtils.touch file
44   - stop
45   - begin
46   - File.delete file
47   - rescue
48   - end
49   - @results.should == ['spec/fixtures/newfile.rb']
50   - end
51   -
52   - it "catches a single file update" do
53   - file = @fixture_path.join("folder1/file1.txt")
54   - File.exists?(file).should be_true
55   - start
56   - FileUtils.touch file
57   - stop
58   - @results.should == ['spec/fixtures/folder1/file1.txt']
59   - end
60   -
61   - it "catches multiple file updates" do
62   - file1 = @fixture_path.join("folder1/file1.txt")
63   - file2 = @fixture_path.join("folder1/folder2/file2.txt")
64   - File.exists?(file1).should be_true
65   - File.exists?(file2).should be_true
66   - start
67   - FileUtils.touch file1
68   - FileUtils.touch file2
69   - stop
70   - @results.should == ['spec/fixtures/folder1/file1.txt', 'spec/fixtures/folder1/folder2/file2.txt']
71   - end
72   - end
73   - end
74   -
75   -private
76   -
77   - def start
78   - sleep 1
79   - @listener.update_last_event
80   - Thread.new { @listener.start }
81   - sleep 1
82   - end
83   -
84   - def stop
85   - sleep 1
86   - @listener.stop
87   - sleep 1
88 27 end
89 28
90 29 end
116 spec/support/listener_helper.rb
... ... @@ -0,0 +1,116 @@
  1 +private
  2 +
  3 + def start
  4 + sleep 1
  5 + @listener.update_last_event
  6 + Thread.new { @listener.start }
  7 + sleep 1
  8 + end
  9 +
  10 + def record_results
  11 + @results = []
  12 + @listener.on_change do |files|
  13 + @results += files
  14 + end
  15 + end
  16 +
  17 + def stop
  18 + sleep 1
  19 + @listener.stop
  20 + sleep 1
  21 + end
  22 +
  23 + def results
  24 + @results.flatten
  25 + end
  26 +
  27 +shared_examples_for 'a listener that reacts to #on_change' do
  28 + before(:each) do
  29 + @listener = described_class.new
  30 + record_results
  31 + end
  32 +
  33 + it "catches a new file" do
  34 + file = @fixture_path.join("newfile.rb")
  35 + if File.exists?(file)
  36 + begin
  37 + File.delete file
  38 + rescue
  39 + end
  40 + end
  41 + File.exists?(file).should be_false
  42 + start
  43 + FileUtils.touch file
  44 + stop
  45 + begin
  46 + File.delete file
  47 + rescue
  48 + end
  49 + results.should =~ ['spec/fixtures/newfile.rb']
  50 + end
  51 +
  52 + it "catches a single file update" do
  53 + file = @fixture_path.join("folder1/file1.txt")
  54 + File.exists?(file).should be_true
  55 + start
  56 + File.open(file, 'w') {|f| f.write('') }
  57 + stop
  58 + results.should =~ ['spec/fixtures/folder1/file1.txt']
  59 + end
  60 +
  61 + it "catches multiple file updates" do
  62 + file1 = @fixture_path.join("folder1/file1.txt")
  63 + file2 = @fixture_path.join("folder1/folder2/file2.txt")
  64 + File.exists?(file1).should be_true
  65 + File.exists?(file2).should be_true
  66 + start
  67 + File.open(file1, 'w') {|f| f.write('') }
  68 + File.open(file2, 'w') {|f| f.write('') }
  69 + stop
  70 + results.should =~ ['spec/fixtures/folder1/file1.txt', 'spec/fixtures/folder1/folder2/file2.txt']
  71 + end
  72 +
  73 + it "not catches a deleted file" do
  74 + file = @fixture_path.join("folder1/file1.txt")
  75 + File.exists?(file).should be_true
  76 + start
  77 + File.delete file
  78 + stop
  79 + FileUtils.touch file
  80 + results.should =~ []
  81 + end
  82 +
  83 + it "not catches a moved file" do
  84 + file1 = @fixture_path.join("folder1/file1.txt")
  85 + file2 = @fixture_path.join("folder1/movedfile1.txt")
  86 + File.exists?(file1).should be_true
  87 + File.exists?(file2).should be_false
  88 + start
  89 + FileUtils.mv file1, file2
  90 + stop
  91 + FileUtils.mv file2, file1
  92 + results.should =~ []
  93 + end
  94 +
  95 +end
  96 +
  97 +shared_examples_for "a listener scoped to a specific directory" do
  98 + before :each do
  99 + @wd = @fixture_path.join("folder1")
  100 + @listener = described_class.new @wd
  101 + end
  102 + it "should base paths within this directory" do
  103 + record_results
  104 + new_file = @wd.join("folder2/newfile.rb")
  105 + modified = @wd.join("file1.txt")
  106 + File.exists?(modified).should be_true
  107 + File.exists?(new_file).should be_false
  108 + start
  109 + FileUtils.touch new_file
  110 + File.open(modified, 'w') {|f| f.write('') }
  111 + stop
  112 + File.delete new_file
  113 + results.should =~ ["folder2/newfile.rb", 'file1.txt']
  114 + end
  115 +end
  116 +

0 comments on commit 6a77f01

Please sign in to comment.
Something went wrong with that request. Please try again.