Sha256: a414b9b56bdbedb9a013c1c1e4192d83be84f110aa7d46e1fbb93cb8c70d8d36

Contents?: true

Size: 1.92 KB

Versions: 2

Compression:

Stored size: 1.92 KB

Contents

describe BrowseEverything::FileEntry do
  let(:mtime) { Time.now }
  describe 'regular file' do
    subject do
      BrowseEverything::FileEntry.new(
        'file_id_01234', 'my_provider:/location/pa/th/file.m4v',
        'file.m4v', '1.2 GB', mtime, false
      )
    end

    it 'should be a BrowseEverything::FileEntry' do
      expect(subject).to be_a BrowseEverything::FileEntry
    end

    it '#id' do
      expect(subject.id).to eq('file_id_01234')
    end

    it '#location' do
      expect(subject.location).to eq('my_provider:/location/pa/th/file.m4v')
    end

    it '#name' do
      expect(subject.name).to eq('file.m4v')
    end

    it '#size' do
      expect(subject.size).to eq('1.2 GB')
    end

    it '#mtime' do
      expect(subject.mtime).to eq(mtime)
    end

    it '#type' do
      expect(subject.type).to eq('video/mp4')
    end

    it '#container?' do
      expect(subject.container?).to be false
    end

    it '#relative_parent_path?' do
      expect(subject.relative_parent_path?).to be false
    end
  end

  describe 'directory' do
    subject do
      BrowseEverything::FileEntry.new(
        'directory_id_1234', 'my_provider:/location/pa/th',
        'th', '', mtime, true
      )
    end

    it '#type' do
      expect(subject.type).to eq('application/x-directory')
    end

    it '#container?' do
      expect(subject.container?).to be true
    end

    it '#relative_parent_path?' do
      expect(subject.relative_parent_path?).to be false
    end
  end

  describe 'parent path' do
    subject do
      BrowseEverything::FileEntry.new(
        'directory_id_1234', 'my_provider:/location/pa/th',
        '..', '', mtime, true
      )
    end

    it '#type' do
      expect(subject.type).to eq('application/x-directory')
    end

    it '#container?' do
      expect(subject.container?).to be true
    end

    it '#relative_parent_path?' do
      expect(subject.relative_parent_path?).to be true
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
browse-everything-0.11.1 spec/unit/file_entry_spec.rb
browse-everything-0.11.0 spec/unit/file_entry_spec.rb