-
-
Notifications
You must be signed in to change notification settings - Fork 921
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5211 from jruby/ji-path
[ji] coercing Ruby File/Dir to Java File/Path
- Loading branch information
Showing
6 changed files
with
95 additions
and
45 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
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,20 @@ | ||
require File.dirname(__FILE__) + "/../spec_helper" | ||
|
||
describe "Ruby Dir" do | ||
|
||
it "is coercible to java.io.File" do | ||
dir = Dir.new('..') | ||
expect(java.io.File).to be === dir.to_java('java.io.File') | ||
file = dir.to_java(java.io.File) | ||
expect(file.getPath).to eql '..' | ||
dir.close | ||
end | ||
|
||
it "is coercible to (java) Path" do | ||
Dir.open('.') do |dir| | ||
java_file= dir.to_java java.nio.file.Path | ||
expect(java_file).to eql java.io.File.new('.').toPath | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
require File.dirname(__FILE__) + "/../spec_helper" | ||
|
||
describe "Ruby File" do | ||
|
||
before(:all) { require 'tempfile' } | ||
|
||
it "is coercible to java.io.File" do | ||
file = Tempfile.new("io_spec").to_java 'java.io.File' | ||
expect(java.io.File).to be === file | ||
file = File.open(__FILE__).to_java java.io.File | ||
expect(java.io.File).to be === file | ||
expect(file.getPath).to eql __FILE__ | ||
end | ||
|
||
it "is coercible to (java) Path" do | ||
File.open('.') do |file| | ||
java_file= file.to_java java.nio.file.Path | ||
expect(java_file).to eql java.io.File.new('.').toPath | ||
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