Sha256: f810273d8274eadc1c537057f74e654be9a75c7aeefc4656d8696a49ecae861a

Contents?: true

Size: 1.54 KB

Versions: 1

Compression:

Stored size: 1.54 KB

Contents

require_relative '../spec_helper'

require 'wright/util/file_owner'

describe Wright::Util::FileOwner do
  before(:each) do
    @owner = Wright::Util::FileOwner.new
  end

  describe '#initialize' do
    it 'should accept user and group arguments' do
      owner = Wright::Util::FileOwner.new('user')
      owner.user.must_equal 'user'

      owner = Wright::Util::FileOwner.new('user', 'group')
      owner.user.must_equal 'user'
      owner.group.must_equal 'group'

      owner = Wright::Util::FileOwner.new('user:group')
      owner.user.must_equal 'user'
      owner.group.must_equal 'group'

      owner = Wright::Util::FileOwner.new('user:group1', 'group2')
      owner.user.must_equal 'user'
      owner.group.must_equal 'group2'
    end
  end

  describe '#user_and_group=' do
    it 'should set the user' do
      @owner.group = 'group'
      @owner.user_and_group = 'user'
      @owner.user.must_equal 'user'
      @owner.group.must_equal 'group'
    end

    it 'should set the user when given a uid' do
      @owner.user_and_group = 23
      @owner.user.must_equal 23
    end

    it 'should support user:group notation' do
      @owner.user_and_group = 'user:group'
      @owner.user.must_equal 'user'
      @owner.group.must_equal 'group'
    end

    it 'should reject user:group strings with invalid notation' do
      invalid_owner = 'user:group:something:else'
      invalid_call = -> { @owner.user_and_group = invalid_owner }
      e = invalid_call.must_raise ArgumentError
      e.message.must_equal "Invalid owner: '#{invalid_owner}'"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wright-0.5.0 spec/util/file_owner_spec.rb