Skip to content

Commit

Permalink
Merge pull request #74 from tscholz/file_list_special_returns
Browse files Browse the repository at this point in the history
Fix special_return method's result wrapping to be more dynamic
  • Loading branch information
hsbt committed Jan 12, 2016
2 parents e81659d + f4553ab commit 9ff282b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/rake/file_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class FileList
def #{sym}(*args, &block)
resolve
result = @items.send(:#{sym}, *args, &block)
FileList.new.import(result)
self.class.new.import(result)
end
}, __FILE__, ln
else
Expand Down
15 changes: 15 additions & 0 deletions test/test_rake_file_list.rb
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,21 @@ def test_other_array_returning_methods
assert_equal FileList, r.class
end

def test_special_return_delegating_methods_object_type
custom_file_list = Class.new(FileList)
f = custom_file_list.new

FileList::SPECIAL_RETURN.each do |m|
r = if [].method(m).arity == 1
f.send(m, [])
else
f.send(m)
end

assert_equal custom_file_list, r.class
end
end

def test_file_utils_can_use_filelists
cfiles = FileList['*.c']

Expand Down

0 comments on commit 9ff282b

Please sign in to comment.