Skip to content

Commit

Permalink
get the $CLASSPATH variable right and allow proper URL as well
Browse files Browse the repository at this point in the history
adjusted some specs to check for path expanded entries. #2216
  • Loading branch information
mkristian committed Dec 3, 2014
1 parent 76a514e commit 83044c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 5 additions & 2 deletions core/src/main/java/org/jruby/RubyClassPathVariable.java
Expand Up @@ -68,10 +68,13 @@ public IRubyObject append(ThreadContext context, IRubyObject obj) {

boolean is1_8 = context.getRuntime().is1_8();
for (IRubyObject path: paths) {
path = is1_8 ? RubyFile.expand_path(context, null, new IRubyObject[]{ path })
: RubyFile.expand_path19(context, null, new IRubyObject[]{ path });
try {
URL url = getURL(path.convertToString().toString());
if (url.getProtocol().equals("file")) {
path = is1_8 ? RubyFile.expand_path(context, null, new IRubyObject[]{ path })
: RubyFile.expand_path19(context, null, new IRubyObject[]{ path });
url = getURL(path.convertToString().toString());
}
getRuntime().getJRubyClassLoader().addURL(url);
} catch (MalformedURLException mue) {
throw getRuntime().newArgumentError(mue.getLocalizedMessage());
Expand Down
7 changes: 3 additions & 4 deletions spec/java_integration/globals/classpath_spec.rb
Expand Up @@ -4,15 +4,14 @@
describe "<<" do
it "accepts an object" do
$CLASSPATH << "file"
$CLASSPATH.to_a.include?("file:file").should == true
$CLASSPATH.to_a.include?("file:#{File.expand_path('file')}").should == true
end

it "accepts an array" do
Dir.chdir(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib')) do
$CLASSPATH << Dir.glob("*.jar")
($CLASSPATH.to_a.include?("file:jruby.jar") ||
$CLASSPATH.to_a.include?("file:jruby-complete.jar") ).should == true
($CLASSPATH.to_a.include?("file:#{File.expand_path('jruby.jar')}")).should == true
end
end
end
end
end

0 comments on commit 83044c2

Please sign in to comment.