From cd2696dd0b04b1ffb8e791b18a07ceec4ad6f171 Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Sun, 25 Nov 2018 21:22:37 -0500 Subject: [PATCH] add Util specs --- spec/rscons/util_spec.rb | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 spec/rscons/util_spec.rb diff --git a/spec/rscons/util_spec.rb b/spec/rscons/util_spec.rb new file mode 100644 index 0000000..dc1190b --- /dev/null +++ b/spec/rscons/util_spec.rb @@ -0,0 +1,31 @@ +module Rscons + describe Util do + + describe ".make_relative_path" do + context "when passed a relative path" do + it "returns the path itself" do + expect(Util.make_relative_path("foo/bar")).to eq "foo/bar" + end + end + + context "when passed an absolute path" do + before(:each) do + expect(Rscons).to receive(:absolute_path?).and_return(true) + end + + context "on Windows" do + it "returns a relative path corresponding to an absolute one" do + expect(Util.make_relative_path("D:/foo/bar")).to eq "_D/foo/bar" + end + end + + context "on POSIX" do + it "returns a relative path corresponding to an absolute one" do + expect(Util.make_relative_path("/foo/bar")).to eq "_/foo/bar" + end + end + end + end + + end +end