Sha256: 4afb083eed974f9f378e54cbfdf3c207b8646a03808f28cd404ac110d39f4944

Contents?: true

Size: 985 Bytes

Versions: 106

Compression:

Stored size: 985 Bytes

Contents

require 'spec_helper'

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

106 entries across 106 versions & 1 rubygems

Version Path
ddr-models-2.6.2 spec/utils_spec.rb
ddr-models-2.6.1 spec/utils_spec.rb
ddr-models-2.6.0 spec/utils_spec.rb
ddr-models-2.6.0.rc4 spec/utils_spec.rb
ddr-models-2.6.0.rc3 spec/utils_spec.rb
ddr-models-2.6.0.rc2 spec/utils_spec.rb
ddr-models-2.6.0.rc1 spec/utils_spec.rb
ddr-models-2.5.3 spec/utils_spec.rb
ddr-models-2.5.2 spec/utils_spec.rb
ddr-models-2.5.1 spec/utils_spec.rb
ddr-models-2.5.0 spec/utils_spec.rb
ddr-models-2.5.0.rc1 spec/utils_spec.rb
ddr-models-2.4.16 spec/utils_spec.rb
ddr-models-2.4.15 spec/utils_spec.rb
ddr-models-2.4.14 spec/utils_spec.rb
ddr-models-2.4.13 spec/utils_spec.rb
ddr-models-2.4.12 spec/utils_spec.rb
ddr-models-2.4.11 spec/utils_spec.rb
ddr-models-3.0.8 spec/utils_spec.rb
ddr-models-3.0.7 spec/utils_spec.rb