Skip to content

Commit

Permalink
Dir.glob uses #to_path when the receiver responds to it. Closes ruby#36.
Browse files Browse the repository at this point in the history
Signed-off-by: Brian Ford <brixen@gmail.com>
  • Loading branch information
calavera authored and brixen committed Jan 21, 2011
1 parent be23d4c commit fd53047
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions core/dir/shared/glob.rb
Expand Up @@ -8,14 +8,25 @@
Dir.chdir @cwd
end

it "converts patterns with to_str" do
obj = mock('file_one.ext')
obj.should_receive(:to_str).and_return('file_one.ext')
ruby_version_is ""..."1.9" do
it "calls #to_str to convert patterns" do
obj = mock('file_one.ext')
obj.should_receive(:to_str).and_return('file_one.ext')

Dir.send(@method, obj).should == %w[file_one.ext]
Dir.send(@method, obj).should == %w[file_one.ext]
end
end

ruby_version_is "1.9" do
it "calls #to_path to convert patterns" do
obj = mock('file_one.ext')
obj.should_receive(:to_path).and_return('file_one.ext')

Dir.send(@method, obj).should == %w[file_one.ext]
end
end

it "splits the string on \0 if there is only one string given" do
it "splits the string on \\0 if there is only one string given" do
Dir.send(@method, "file_o*\0file_t*").should ==
%w!file_one.ext file_two.ext!
end
Expand Down

0 comments on commit fd53047

Please sign in to comment.