Sha256: 015604b521b62e18bd7fc98a1a3e89a3e3471b073f11a30884a0ab9b1d27f40c
Contents?: true
Size: 1.38 KB
Versions: 9
Compression:
Stored size: 1.38 KB
Contents
require 'spec_helper' require 'ronin/extensions/file' require 'tempfile' describe File do subject { File } it "should provide File.escape_path" do subject.should respond_to(:escape_path) end describe "each_line" do let(:lines) { %w[one two three] } before(:all) do @file = Tempfile.new('ronin-support') @file.puts(*lines) @file.close end it "should enumerate over each line in the file" do File.each_line(@file.path).to_a.should == lines end end describe "each_row" do let(:rows) do [ %w[one two three], %w[four five six] ] end let(:separator) { '|' } let(:newline) { "\r\n" } let(:lines) { rows.map { |row| row.join(separator) }.join(newline) } before(:all) do @file = Tempfile.new('ronin-support') @file.write(lines) @file.close end it "should enumerate over each row from each line" do File.each_row(@file.path,separator).to_a.should == rows end end describe "escape_path" do it "should remove null-bytes" do File.escape_path("hello\0world\0").should == "helloworld" end it "should escape home-dir expansions" do File.escape_path("hello/~world").should == "hello/\\~world" end it "should remove '.' and '..' directories" do File.escape_path("hello/./../world").should == "world" end end end
Version data entries
9 entries across 9 versions & 1 rubygems