From 70a7ec0a34174c04a1af5b5843bec22a71ff73e3 Mon Sep 17 00:00:00 2001 From: Yossef Mendelssohn Date: Fri, 13 Jun 2008 16:03:57 -0500 Subject: [PATCH] Letting paths default to present working directory. --- lib/fsevents/stream.rb | 4 ++-- spec/stream_spec.rb | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/fsevents/stream.rb b/lib/fsevents/stream.rb index 9afd731..77292af 100644 --- a/lib/fsevents/stream.rb +++ b/lib/fsevents/stream.rb @@ -8,12 +8,12 @@ def initialize(*paths) options = {} options = paths.pop if paths.last.is_a?(Hash) - raise ArgumentError, "path required" if paths.empty? + paths = Dir.pwd if paths.empty? allocator = options[:allocator] || OSX::KCFAllocatorDefault callback = options[:callback] context = options[:context] || nil - paths = [*paths].flatten + paths = [paths].flatten since = options[:since] || OSX::KFSEventStreamEventIdSinceNow latency = options[:latency] || 1.0 flags = options[:flags ] || 0 diff --git a/spec/stream_spec.rb b/spec/stream_spec.rb index 853537e..bc5c7d2 100644 --- a/spec/stream_spec.rb +++ b/spec/stream_spec.rb @@ -20,8 +20,8 @@ lambda { FSEvents::Stream.new(@path) }.should_not raise_error(ArgumentError) end - it 'should require a path' do - lambda { FSEvents::Stream.new }.should raise_error(ArgumentError) + it 'should not require a path' do + lambda { FSEvents::Stream.new }.should_not raise_error(ArgumentError) end it 'should accept a hash of options' do @@ -145,7 +145,12 @@ FSEvents::Stream.new(@path, @options) end - # it 'should default the path' # Dir.pwd + it 'should default the path to the present working directory' do + args = @arg_placeholders + args[3] = [Dir.pwd] + OSX.expects(:FSEventStreamCreate).with(*args).returns(@stream) + FSEvents::Stream.new(@options) + end it 'should default the since to KFSEventStreamEventIdSinceNow' do @options.delete(:since)