aboutsummaryrefslogtreecommitdiffstats
path: root/spec/ruby/library/pathname/join_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/library/pathname/join_spec.rb')
-rw-r--r--spec/ruby/library/pathname/join_spec.rb40
1 files changed, 40 insertions, 0 deletions
diff --git a/spec/ruby/library/pathname/join_spec.rb b/spec/ruby/library/pathname/join_spec.rb
new file mode 100644
index 0000000000..8c77bb1f59
--- /dev/null
+++ b/spec/ruby/library/pathname/join_spec.rb
@@ -0,0 +1,40 @@
+require File.expand_path('../../../spec_helper', __FILE__)
+require 'pathname'
+
+describe "Pathname#join" do
+ it "without separators" do
+ Pathname.new('/usr').join(Pathname.new('foo')).should == Pathname.new('/usr/foo')
+ end
+
+ it "with separators" do
+ Pathname.new('/usr').join(Pathname.new('/foo')).should == Pathname.new('/foo')
+ end
+
+ it "with a string" do
+ Pathname.new('/usr').join('foo').should == Pathname.new('/usr/foo')
+ end
+
+ it "with root" do
+ Pathname.new('/usr').join(Pathname.new('/')).should == Pathname.new('/')
+ end
+
+ it "with a relative path" do
+ Pathname.new('/usr').join(Pathname.new('../foo')).should == Pathname.new('/foo')
+ end
+
+ it "a relative path with current" do
+ Pathname.new('.').join(Pathname.new('foo')).should == Pathname.new('foo')
+ end
+
+ it "an absolute path with current" do
+ Pathname.new('.').join(Pathname.new('/foo')).should == Pathname.new('/foo')
+ end
+
+ it "a prefixed relative path with current" do
+ Pathname.new('.').join(Pathname.new('./foo')).should == Pathname.new('foo')
+ end
+
+ it "multiple paths" do
+ Pathname.new('.').join(Pathname.new('./foo'), 'bar').should == Pathname.new('foo/bar')
+ end
+end