spec/log_spec.rb in lookout-rack-utils-3.3.0.22 vs spec/log_spec.rb in lookout-rack-utils-3.3.0.24
- old
+ new
@@ -156,6 +156,33 @@
expect(formatter.format(event)).to eql("WARN: #{timestamp}: spec/log_spec.rb:9: #{data}\n")
end
end
end
+
+ describe "#common_basedir" do
+ subject(:common_basedir) { formatter.common_basedir(path) }
+
+ context "with no common path" do
+ let(:path) { "/impossible/path" }
+
+ it "should return basedir" do
+ expect(subject).to eq basedir
+ end
+ end
+
+ context "with a partially shared path" do
+ let(:path) { File.expand_path(File.join(basedir, "..", "tmp", "foo.rb")) }
+
+ it "should return shared path" do
+ expect(subject).to eq File.expand_path(File.join(basedir, ".."))
+ end
+ end
+
+ context "with a fully shared path" do
+ let(:path) { File.expand_path(File.join(basedir, "tmp.rb")) }
+ it "should return full path" do
+ expect(subject).to eq basedir
+ end
+ end
+ end
end