Sha256: ea684dc867528148c912002354cfa7eed67db480760164d2a067f5775ccba67d

Contents?: true

Size: 962 Bytes

Versions: 20

Compression:

Stored size: 962 Bytes

Contents

module Ddr
  RSpec.describe Utils do
    describe "sanitize filename" do
      it "should return nil if not given an argument" do
        expect(Ddr::Utils.sanitize_filename(nil)).to be_nil
      end
      it "should raise an exception if given a non-String argument" do
        expect { Ddr::Utils.sanitize_filename(File.new) }.to raise_error(ArgumentError)
      end
      it "should raise an exception if given a string with a path separator" do
        expect { Ddr::Utils.sanitize_filename(File.join('my', 'file.txt')) }.to raise_error(ArgumentError)
      end
      it "should return the unaltered file name if given a sanitary file name" do
        expect(Ddr::Utils.sanitize_filename(File.join('my-file01.txt'))).to eq('my-file01.txt')
      end
      it "should a sanitized file name if given an unsanitary file name" do
        expect(Ddr::Utils.sanitize_filename(File.join('my##file01$.txt%%'))).to eq('my__file01_.txt__')
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
ddr-models-2.11.0 spec/utils_spec.rb
ddr-models-2.10.2 spec/utils_spec.rb
ddr-models-2.10.1 spec/utils_spec.rb
ddr-models-2.10.0 spec/utils_spec.rb
ddr-models-2.10.0.rc2 spec/utils_spec.rb
ddr-models-2.10.0.rc1 spec/utils_spec.rb
ddr-models-2.9.2 spec/utils_spec.rb
ddr-models-2.9.1 spec/utils_spec.rb
ddr-models-2.9.0 spec/utils_spec.rb
ddr-models-2.9.0.rc1 spec/utils_spec.rb
ddr-models-2.8.0 spec/utils_spec.rb
ddr-models-2.8.0.rc1 spec/utils_spec.rb
ddr-models-2.7.6 spec/utils_spec.rb
ddr-models-2.7.5 spec/utils_spec.rb
ddr-models-2.7.4 spec/utils_spec.rb
ddr-models-2.7.3 spec/utils_spec.rb
ddr-models-2.7.2 spec/utils_spec.rb
ddr-models-2.7.1 spec/utils_spec.rb
ddr-models-2.7.0 spec/utils_spec.rb
ddr-models-2.7.0.rc1 spec/utils_spec.rb