move Rscons.absolute_path?() to Util

This commit is contained in:
josh committed 2018-11-25 21:31:48 -05:00
1 parent cd2696dd0b
commit dff80587ac
4 files changed
+45 -43

No files matched your search

+30 -2
View File
@@ -1,6 +1,34 @@
module Rscons
describe Util do
describe ".absolute_path?" do
context "on Windows" do
it "returns whether a path is absolute" do
stub_const("RUBY_PLATFORM", "mingw")
expect(Util.absolute_path?("/foo")).to be_truthy
expect(Util.absolute_path?("\\Windows")).to be_truthy
expect(Util.absolute_path?("C:\\Windows")).to be_truthy
expect(Util.absolute_path?("f:\\stuff")).to be_truthy
expect(Util.absolute_path?("g:/projects")).to be_truthy
expect(Util.absolute_path?("x:foo")).to be_falsey
expect(Util.absolute_path?("file.txt")).to be_falsey
end
end
context "on non-Windows" do
it "returns whether a path is absolute" do
stub_const("RUBY_PLATFORM", "linux")
expect(Util.absolute_path?("/foo")).to be_truthy
expect(Util.absolute_path?("\\Windows")).to be_falsey
expect(Util.absolute_path?("C:\\Windows")).to be_falsey
expect(Util.absolute_path?("f:\\stuff")).to be_falsey
expect(Util.absolute_path?("g:/projects")).to be_falsey
expect(Util.absolute_path?("x:foo")).to be_falsey
expect(Util.absolute_path?("file.txt")).to be_falsey
end
end
end
describe ".make_relative_path" do
context "when passed a relative path" do
it "returns the path itself" do
@@ -10,7 +38,7 @@ module Rscons
context "when passed an absolute path" do
before(:each) do
expect(Rscons).to receive(:absolute_path?).and_return(true)
expect(Util).to receive(:absolute_path?).and_return(true)
end
context "on Windows" do
@@ -19,7 +47,7 @@ module Rscons
end
end
context "on POSIX" do
context "on non-Windows" do
it "returns a relative path corresponding to an absolute one" do
expect(Util.make_relative_path("/foo/bar")).to eq "_/foo/bar"
end