Skip to content

Commit 644820c

Browse files
committed
Dir#to_path should have the specs and #path be the alias for consistency
1 parent 82ca639 commit 644820c

2 files changed

Lines changed: 34 additions & 34 deletions

File tree

core/dir/path_spec.rb

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,7 @@
11
require_relative '../../spec_helper'
2-
require_relative 'fixtures/common'
32

43
describe "Dir#path" do
5-
before :all do
6-
DirSpecs.create_mock_dirs
7-
end
8-
9-
after :all do
10-
DirSpecs.delete_mock_dirs
11-
end
12-
13-
it "returns the path that was supplied to .new or .open" do
14-
dir = Dir.open DirSpecs.mock_dir
15-
begin
16-
dir.path.should == DirSpecs.mock_dir
17-
ensure
18-
dir.close rescue nil
19-
end
20-
end
21-
22-
it "returns the path even when called on a closed Dir instance" do
23-
dir = Dir.open DirSpecs.mock_dir
24-
dir.close
25-
dir.path.should == DirSpecs.mock_dir
26-
end
27-
28-
it "returns a String with the same encoding as the argument to .open" do
29-
path = DirSpecs.mock_dir.force_encoding Encoding::IBM866
30-
dir = Dir.open path
31-
begin
32-
dir.path.encoding.should.equal?(Encoding::IBM866)
33-
ensure
34-
dir.close
35-
end
4+
it "is an alias of Dir#to_path" do
5+
Dir.instance_method(:path).should == Dir.instance_method(:to_path)
366
end
377
end

core/dir/to_path_spec.rb

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,37 @@
11
require_relative '../../spec_helper'
2+
require_relative 'fixtures/common'
23

34
describe "Dir#to_path" do
4-
it "is an alias of Dir#path" do
5-
Dir.instance_method(:to_path).should == Dir.instance_method(:path)
5+
before :all do
6+
DirSpecs.create_mock_dirs
7+
end
8+
9+
after :all do
10+
DirSpecs.delete_mock_dirs
11+
end
12+
13+
it "returns the to_path that was supplied to .new or .open" do
14+
dir = Dir.open DirSpecs.mock_dir
15+
begin
16+
dir.to_path.should == DirSpecs.mock_dir
17+
ensure
18+
dir.close rescue nil
19+
end
20+
end
21+
22+
it "returns the to_path even when called on a closed Dir instance" do
23+
dir = Dir.open DirSpecs.mock_dir
24+
dir.close
25+
dir.to_path.should == DirSpecs.mock_dir
26+
end
27+
28+
it "returns a String with the same encoding as the argument to .open" do
29+
to_path = DirSpecs.mock_dir.force_encoding Encoding::IBM866
30+
dir = Dir.open to_path
31+
begin
32+
dir.to_path.encoding.should.equal?(Encoding::IBM866)
33+
ensure
34+
dir.close
35+
end
636
end
737
end

0 commit comments

Comments
 (0)