diff --git a/lib/guard/listener.rb b/lib/guard/listener.rb index 6fba4e7..d03839e 100644 --- a/lib/guard/listener.rb +++ b/lib/guard/listener.rb @@ -10,23 +10,23 @@ module Guard class Listener attr_reader :last_event, :sha1_checksums_hash, :directory - def self.select_and_init + def self.select_and_init(*a) if mac? && Darwin.usable? - Darwin.new + Darwin.new(*a) elsif linux? && Linux.usable? - Linux.new + Linux.new(*a) elsif windows? && Windows.usable? - Windows.new + Windows.new(*a) else UI.info "Using polling (Please help us to support your system better than that.)" - Polling.new + Polling.new(*a) end end - def initialize(directory=Dir.pwd) + def initialize(directory=Dir.pwd, options={}) @directory = directory.to_s @sha1_checksums_hash = {} - @relativate_paths = true + @relativate_paths = options.fetch(:relativate_paths, true) update_last_event end diff --git a/spec/guard/listener_spec.rb b/spec/guard/listener_spec.rb index a2cc1f7..b6aeb5c 100644 --- a/spec/guard/listener_spec.rb +++ b/spec/guard/listener_spec.rb @@ -27,6 +27,15 @@ describe Guard::Listener do Guard::Linux.should_receive(:new) subject.select_and_init end + + it "forwards its arguments to the constructor" do + subject.stub!(:mac?).and_return(true) + Guard::Darwin.stub!(:usable?).and_return(true) + + path, opts = 'path', {:foo => 23} + Guard::Darwin.should_receive(:new).with(path, opts).and_return(true) + subject.select_and_init path, opts + end end describe "#all_files" do