-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extending the events array with #files and #modified_files.
- Loading branch information
Showing
6 changed files
with
60 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require 'fsevents/ext/array' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module EventArray | ||
def files | ||
collect { |x| x.files }.flatten | ||
end | ||
|
||
def modified_files | ||
collect { |x| x.modified_files }.flatten | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require File.dirname(__FILE__) + '/spec_helper.rb' | ||
|
||
describe EventArray do | ||
before :each do | ||
@event_array = [] | ||
@event_array.extend(EventArray) | ||
end | ||
|
||
it 'should return files' do | ||
@event_array.should respond_to(:files) | ||
end | ||
|
||
describe 'returning files' do | ||
it 'should collect files from its events' do | ||
events = Array.new(3) { stub('event', :files => Array.new(3) { stub('file') }) } | ||
files = [] | ||
events.each do |event| | ||
@event_array << event | ||
files += event.files | ||
end | ||
|
||
@event_array.files.should == files | ||
end | ||
end | ||
|
||
it 'should return modified files' do | ||
@event_array.should respond_to(:modified_files) | ||
end | ||
|
||
describe 'returning modified files' do | ||
it 'should collect modified files from its events' do | ||
events = Array.new(3) { stub('event', :modified_files => Array.new(3) { stub('file') }) } | ||
files = [] | ||
events.each do |event| | ||
@event_array << event | ||
files += event.modified_files | ||
end | ||
|
||
@event_array.modified_files.should == files | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters