Permalink
Browse files

Merge pull request #30 from benhoskings/6ec03cfc05dbc6b0602924a3ce868…

…de66812b705

Take two: supplying #watch arguments via FSEvent.new
  • Loading branch information...
2 parents 10c7980 + 6ec03cf commit a3315374ae21a7dc94205605f5a6675468da55e2 @ttilley ttilley committed Feb 18, 2012
Showing with 17 additions and 0 deletions.
  1. +4 −0 lib/rb-fsevent/fsevent.rb
  2. +13 −0 spec/rb-fsevent/fsevent_spec.rb
View
4 lib/rb-fsevent/fsevent.rb
@@ -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
View
13 spec/rb-fsevent/fsevent_spec.rb
@@ -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

0 comments on commit a331537

Please sign in to comment.