Sha256: 57e644820ab365895902a837718375ec629786a1a400166956c99946ffca4173

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe Spotlight::MDItemNative do
  before do
    @item = Spotlight::MDItemNative.new(__FILE__)
    @filename = File.basename(__FILE__)
  end

  context 'file not found' do
    it 'raises error' do
      filename = __FILE__ + 'aaa'

      expect {
        Spotlight::MDItemNative.new(filename)
      }.to(
        raise_error(
          ArgumentError,
          format(
            'no such file or directory: %<filename>s',
            filename: filename
          )
        )
      )
    end
  end

  it "should instanciate" do
    @item.should be_an_instance_of(Spotlight::MDItemNative)
  end

  it "should get attribute by name" do
    @item.get('kMDItemKind').should match('Ruby Source')
    @item.get(:kMDItemKind).should match('Ruby Source')
    @item.get(:kMDItemFSName).should eql(@filename)
    @item.get(:kMDItemFSCreationDate).should be_an_instance_of(Time)
    @item.get(:kMDItemFSOwnerUserID).should be_an_instance_of(Fixnum)
    @item.get(:kMDItemFSIsExtensionHidden).should be_an_instance_of(FalseClass)
  end

  it "should get nil if attribute is not found" do
    @item.get('kMDXXXXXX').should be_nil
  end

  it "should get attribute names" do
    attribute_names = @item.attribute_names
    attribute_names.should be_an_instance_of(Array)
    attribute_names.should be_include(:kMDItemKind)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
spotlight-0.0.8 spec/md_item_native_spec.rb
spotlight-0.0.7 spec/md_item_native_spec.rb