diff --git a/lib/fsevents/stream.rb b/lib/fsevents/stream.rb index 769afe7..6fdada1 100644 --- a/lib/fsevents/stream.rb +++ b/lib/fsevents/stream.rb @@ -34,7 +34,7 @@ def stream_callback paths.regard_as('*') events = [] - event_count.times { |i| events << paths[i] } + event_count.times { |i| events << Event.new(event_IDs[i], paths[i], self) } callback.call(events) end diff --git a/spec/stream_spec.rb b/spec/stream_spec.rb index 21dee4a..9d68071 100644 --- a/spec/stream_spec.rb +++ b/spec/stream_spec.rb @@ -251,17 +251,22 @@ @proc.call(*@args) end - it 'should collect the paths and pass them to the stored callback' do + it 'should collect the paths and IDs, create Event objects, and pass them to the stored callback' do event_count = 3 @args_hash[:event_count] = event_count - paths = [] + events = [] event_count.times do |i| - val = "/some/path/to/dir/number/#{i+1}" - @args_hash[:paths].push val - paths.push val + path = "/some/path/to/dir/number/#{i+1}" + id = i + 1 + @args_hash[:paths].push path + @args_hash[:event_IDs].push id + + event = stub("event #{path}") + FSEvents::Event.stubs(:new).with(id, path, @stream).returns(event) + events.push event end @args = @args_hash.values_at(*@callback_arg_order) - @callback.expects(:call).with(paths) + @callback.expects(:call).with(events) @proc.call(*@args) end end