Skip to content

Commit

Permalink
Letting paths default to present working directory.
Browse files Browse the repository at this point in the history
  • Loading branch information
ymendel committed Jun 13, 2008
1 parent 1d62afd commit 70a7ec0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions lib/fsevents/stream.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
11 changes: 8 additions & 3 deletions spec/stream_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 70a7ec0

Please sign in to comment.