Skip to content

Commit

Permalink
Add a test on module name with front slash (#1818)
Browse files Browse the repository at this point in the history
* Add a test on module name with front slash

This test should fail on Appveyor (Windows)

* File.join should join parts using File::SEPARATOR

* Ruby is using forward slashes to join parts
  • Loading branch information
ggrossetie authored and iliabylich committed May 7, 2018
1 parent be4662e commit 11f93cf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions spec/lib/builder_spec.rb
Expand Up @@ -124,4 +124,10 @@
expect(builder.build('stringio', requirable: true).to_s).to include(%{Opal.modules["stringio"]})
end
end

describe ':requirable' do
it 'it uses front slash as module name' do
expect(builder.build('nodejs/open-uri', requirable: true).to_s).to include(%{Opal.modules["nodejs/open-uri"]})
end
end
end
2 changes: 1 addition & 1 deletion stdlib/nodejs/file.rb
Expand Up @@ -88,7 +88,7 @@ def self.realpath(pathname, dir_string = nil, cache = nil, &block)
end

def self.join(*paths)
`__path__.join.apply(__path__, #{paths})`
`__path__.posix.join.apply(__path__, #{paths})`
end

def self.directory?(path)
Expand Down
4 changes: 4 additions & 0 deletions test/nodejs/test_file.rb
Expand Up @@ -137,4 +137,8 @@ def test_windows_file_expand_path
assert_equal('c:/foo/bar.js', File.expand_path( '\\..\\bar.js', 'c:\\foo\\baz'))
assert_equal('c:/foo/bar.js', File.expand_path( '\\..\\bar.js', 'c:\\foo\\baz\\'))
end if windows_platform?

def test_join
assert_equal('usr/bin', File.join('usr', 'bin'))
end
end

0 comments on commit 11f93cf

Please sign in to comment.