spec/path_spec.rb in ronin-support-0.1.0.pre2 vs spec/path_spec.rb in ronin-support-0.1.0.pre3
- old
+ new
@@ -14,41 +14,43 @@
path.should.class == Path
path.to_s.should == '/'
end
describe "up" do
+ subject { Path }
+
it "should be able to traverse up 0 directories" do
- Path.up(0).should == File::SEPARATOR
+ subject.up(0).should == File::SEPARATOR
end
it "should raise an ArgumentError when not passed an Integer or Enumerable" do
lambda {
- Path.up(1.5)
+ subject.up(1.5)
}.should raise_error(ArgumentError)
end
it "should raise an ArgumentError on negative number of directories" do
lambda {
- Path.up(-1)
+ subject.up(-1)
}.should raise_error(ArgumentError)
end
it "should create directory-escaping paths" do
- Path.up(n).to_s.should == (['..'] * n).join(File::SEPARATOR)
+ subject.up(n).to_s.should == (['..'] * n).join(File::SEPARATOR)
end
it "should create a range of directory-escaping paths" do
range = 7..10
- Path.up(range).should == range.map { |i| Path.up(i) }
+ subject.up(range).should == range.map { |i| Path.up(i) }
end
it "should allow using custom path separators" do
- Path.up(n,'\\').to_s.should == (['..'] * n).join("\\")
+ subject.up(n,'\\').to_s.should == (['..'] * n).join("\\")
end
end
- describe "join" do
+ describe "#join" do
let(:base_path) { Path.new('base') }
it "should join with sub-paths" do
sub_path = File.join('one','two')
expected = [base_path, sub_path].join(File::SEPARATOR)