Sha256: 248fbfdc28bb813ae718d10f2e45e280fd65e35231f8e2237bc1836573fa5bd2

Contents?: true

Size: 1.38 KB

Versions: 1

Compression:

Stored size: 1.38 KB

Contents

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

describe FSPath::Xattr do
  file = 'file'
  link = 'link'

  before do
    File.open(file, 'w'){ |io| io << 'some content' }
    File.symlink(file, link)
  end
  after do
    File.delete(file)
    File.delete(link)
  end

  describe "xattr" do
    [
      [file, :xattr],
      [link, :xattr],
      [file, :lxattr],
      [link, :lxattr],
    ].each do |path, method|
      describe "#{path}.#{method}" do
        it "should return instance of Xattr" do
          FSPath(path).send(method).should be_kind_of(Xattr)
        end

        it "should point to same path" do
          FSPath(path).send(method).instance_variable_get(:@path).should == path
        end

        it "should set xattr on path" do
          FSPath(file).lxattr['user.hello'].should be_nil
          FSPath(link).lxattr['user.hello'].should be_nil

          FSPath(path).send(method)['user.hello'] = 'world'
          FSPath(path).send(method)['user.hello'].should == 'world'

          if path == link && method == :lxattr
            FSPath(file).lxattr['user.hello'].should be_nil
            FSPath(link).lxattr['user.hello'].should == 'world'
          else
            FSPath(file).lxattr['user.hello'].should == 'world'
            FSPath(link).lxattr['user.hello'].should be_nil
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fspath-xattr-1.0.1 spec/fspath/xattr_spec.rb