Sha256: 2fef8c7af6d4519777f36e7b24c8a68ec54d7c542d32e0f741918d7d6dd0ffc2

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

require 'spec_helper'

describe GroupDocs::Api::Helpers::AccessRights do
  subject do
    GroupDocs::User.new
  end

  describe '#convert_access_rights_to_byte' do
    let(:rights) { %w(view annotate download export all) }

    it 'raises error if rights is not an array' do
      lambda { subject.send(:convert_access_rights_to_byte, :export) }.should raise_error(ArgumentError)
    end

    it 'raises error if right is unknown' do
      lambda { subject.send(:convert_access_rights_to_byte, %w(unknown)) }.should raise_error(ArgumentError)
    end

    it 'converts each right to Symbol' do
      rights.each do |right|
        symbol = right.to_sym
        right.should_receive(:to_sym).and_return(symbol)
      end
      subject.send(:convert_access_rights_to_byte, rights)
    end

    it 'returns correct byte flag' do
      subject.send(:convert_access_rights_to_byte, rights).should == 46
    end
  end

  describe '#convert_byte_to_access_rights' do
    let(:rights) { %w(download export view) }

    it 'raises error if rights is not an integer' do
      lambda { subject.send(:convert_byte_to_access_rights, :export) }.should raise_error(ArgumentError)
    end

    it 'returns correct rights array flag' do
      subject.send(:convert_byte_to_access_rights, 13).should =~ rights.map(&:to_sym)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
groupdocs-2.2.0 spec/groupdocs/api/helpers/access_rights_helper_spec.rb
groupdocs-2.1.0 spec/groupdocs/api/helpers/access_rights_helper_spec.rb
groupdocs-2.0.0 spec/groupdocs/api/helpers/access_rights_helper_spec.rb