From 7b95eeb275422a131d5f56c500f4a7b12781102b Mon Sep 17 00:00:00 2001 From: Niklas Hofer Date: Fri, 13 May 2011 23:56:39 +0200 Subject: [PATCH] must not use touch on Linux --- spec/guard/listeners/linux_spec.rb | 2 ++ spec/support/listener_helper.rb | 6 +++--- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/spec/guard/listeners/linux_spec.rb b/spec/guard/listeners/linux_spec.rb index 646087e..1c834a0 100644 --- a/spec/guard/listeners/linux_spec.rb +++ b/spec/guard/listeners/linux_spec.rb @@ -46,6 +46,8 @@ describe Guard::Linux do it_should_behave_like "a listener that reacts to #on_change" it_should_behave_like "a listener scoped to a specific directory" + + # Fun fact: File.touch seems not to be enough on Linux to trigger a modify event it "doesn't process a change when it is stopped" do @listener = described_class.new diff --git a/spec/support/listener_helper.rb b/spec/support/listener_helper.rb index a68db1d..828a8ae 100644 --- a/spec/support/listener_helper.rb +++ b/spec/support/listener_helper.rb @@ -53,7 +53,7 @@ shared_examples_for 'a listener that reacts to #on_change' do file = @fixture_path.join("folder1/file1.txt") File.exists?(file).should be_true start - FileUtils.touch file + File.open(file, 'w') {|f| f.write('') } stop results.should =~ ['spec/fixtures/folder1/file1.txt'] end @@ -64,8 +64,8 @@ shared_examples_for 'a listener that reacts to #on_change' do File.exists?(file1).should be_true File.exists?(file2).should be_true start - FileUtils.touch file1 - FileUtils.touch file2 + File.open(file1, 'w') {|f| f.write('') } + File.open(file2, 'w') {|f| f.write('') } stop results.should =~ ['spec/fixtures/folder1/file1.txt', 'spec/fixtures/folder1/folder2/file2.txt'] end