Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

44 lines (33 sloc) 1.527 kb
require 'language_sniffer/pathname'
require 'test/unit'
class TestPathname < Test::Unit::TestCase
include LanguageSniffer
def test_to_s
assert_equal "file.rb", Pathname.new("file.rb").to_s
end
def test_basename
assert_equal 'file.rb', Pathname.new("file.rb").basename
assert_equal 'file.rb', Pathname.new("./file.rb").basename
assert_equal 'file.rb', Pathname.new("sub/dir/file.rb").basename
assert_equal '.profile', Pathname.new(".profile").basename
end
def test_extname
assert_equal '.rb', Pathname.new("file.rb").extname
assert_equal '.rb', Pathname.new("./file.rb").extname
assert_equal '.rb', Pathname.new("sub/dir/file.rb").extname
assert_equal '', Pathname.new(".profile").extname
end
def test_language
assert_nil Pathname.new(".rb").language
assert_equal Language['Ruby'], Pathname.new("file.rb").language
assert_equal Language['Ruby'], Pathname.new("./file.rb").language
assert_equal Language['Ruby'], Pathname.new("sub/dir/file.rb").language
assert_equal Language['Ruby'], Pathname.new("Rakefile").language
assert_equal Language['Ruby'], Pathname.new("vendor/Rakefile").language
assert_equal Language['Ruby'], Pathname.new("./Rakefile").language
assert_equal Language['Gentoo Ebuild'], Pathname.new("file.ebuild").language
assert_equal Language['Python'], Pathname.new("itty.py").language
assert_equal Language['Nu'], Pathname.new("itty.nu").language
assert_nil Pathname.new("defu.nkt").language
end
end
Jump to Line
Something went wrong with that request. Please try again.