move Rscons.absolute_path?() to Util
This commit is contained in:
1 parent
cd2696dd0b
commit
dff80587ac
4 files changed
+45
-43
No files matched your search
@@ -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
|
||||
|
||||
+1
-27
@@ -1,31 +1,4 @@
|
||||
describe Rscons do
|
||||
describe ".absolute_path?" do
|
||||
context "on Windows" do
|
||||
it "returns whether a path is absolute" do
|
||||
stub_const("RUBY_PLATFORM", "mingw")
|
||||
expect(Rscons.absolute_path?("/foo")).to be_truthy
|
||||
expect(Rscons.absolute_path?("\\Windows")).to be_truthy
|
||||
expect(Rscons.absolute_path?("C:\\Windows")).to be_truthy
|
||||
expect(Rscons.absolute_path?("f:\\stuff")).to be_truthy
|
||||
expect(Rscons.absolute_path?("g:/projects")).to be_truthy
|
||||
expect(Rscons.absolute_path?("x:foo")).to be_falsey
|
||||
expect(Rscons.absolute_path?("file.txt")).to be_falsey
|
||||
end
|
||||
end
|
||||
|
||||
context "not on Windows" do
|
||||
it "returns whether a path is absolute" do
|
||||
stub_const("RUBY_PLATFORM", "linux")
|
||||
expect(Rscons.absolute_path?("/foo")).to be_truthy
|
||||
expect(Rscons.absolute_path?("\\Windows")).to be_falsey
|
||||
expect(Rscons.absolute_path?("C:\\Windows")).to be_falsey
|
||||
expect(Rscons.absolute_path?("f:\\stuff")).to be_falsey
|
||||
expect(Rscons.absolute_path?("g:/projects")).to be_falsey
|
||||
expect(Rscons.absolute_path?("x:foo")).to be_falsey
|
||||
expect(Rscons.absolute_path?("file.txt")).to be_falsey
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe ".set_suffix" do
|
||||
it "changes the suffix to the new one" do
|
||||
@@ -125,4 +98,5 @@ describe Rscons do
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
Reference in new issue
Block a user