Sha256: 3d5d60a79569f2ce28da1ca3b70bb5ac7695fe03cdcaa5d50b0a0adea8a7df49

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

# -*- coding: utf-8 -*-
require "sixarm_ruby_blob_test"

describe Blob do

  let(:dir){ FAB.dirname }
  let(:base){ FAB.basename }
  let(:blob){ Blob.new(dir: dir, base: base) }

  # We choose to use Unix-friendly file names: lowercase a-z and underscores,
  # always with "/" as a directory separator, typically with a dot extension,
  # never with non-ASCII characters.
  #
  let(:base_match){ /^[0-1a-z\_\.]+$/ }
  let(:dir_match){ /^[0-1a-z\_\/]+$/ }
  let(:path_match){ /^[0-1a-z\_\/\.]+$/ }

  describe "#base" do
    it "uses a good unix name" do
      blob.base.must_match base_match
    end
  end

  describe "#dir" do
    it "uses a good unix name" do
      blob.dir.must_match dir_match
    end
  end

  describe "#name" do
    it "concats the name" do
      blob.name.must_equal "#{dir}/#{base}"
    end
  end

  describe "#ext" do

    it "returns the file base name extension, if it exists" do
      blob.base = "foo.goo.hoo"
      blob.ext.must_equal "hoo"
    end

    it "returns nil, if there is no extension" do
      blob.base = "foogoohoo"
      blob.ext.must_be_nil
    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sixarm_ruby_blob-2.0.0 test/sixarm_ruby_blob_test/dir_test.rb
sixarm_ruby_blob-1.0.3 test/sixarm_ruby_blob_test/dir_test.rb