Skip to content

Commit

Permalink
Merge pull request guard#30 from benhoskings/6ec03cfc05dbc6b0602924a3…
Browse files Browse the repository at this point in the history
…ce868de66812b705

Take two: supplying #watch arguments via FSEvent.new
  • Loading branch information
ttilley committed Feb 18, 2012
2 parents 10c7980 + 6ec03cf commit a331537
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/rb-fsevent/fsevent.rb
Expand Up @@ -14,6 +14,10 @@ def watcher_path

attr_reader :paths, :callback

def initialize args = nil, &block
watch(args, &block) unless args.nil?
end

def watch(watch_paths, options=nil, &block)
@paths = watch_paths.kind_of?(Array) ? watch_paths : [watch_paths]
@callback = block
Expand Down
13 changes: 13 additions & 0 deletions spec/rb-fsevent/fsevent_spec.rb
Expand Up @@ -10,6 +10,19 @@
end
end

it "shouldn't pass anything to watch when instantiated without a path" do
fsevent = FSEvent.new
fsevent.paths.should be_nil
fsevent.callback.should be_nil
end

it "should pass path and block to watch when instantiated with them" do
blk = proc { }
fsevent = FSEvent.new(@fixture_path, &blk)
fsevent.paths.should == [@fixture_path]
fsevent.callback.should == blk
end

it "should have a watcher_path that resolves to an executable file" do
File.exists?(FSEvent.watcher_path).should be_true
File.executable?(FSEvent.watcher_path).should be_true
Expand Down

0 comments on commit a331537

Please sign in to comment.