Sha256: 09093f9ff61be82c12df667c5bb798a14af5039fe559c0e607c2126c320ebb1c

Contents?: true

Size: 1.03 KB

Versions: 17

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'

describe Acfs::Resource::Attributes::UUID do
  let(:type) { Acfs::Resource::Attributes::UUID.new }

  describe '#cast' do
    subject { -> { type.cast(value) } }

    context 'with nil' do
      let(:value) { nil }
      it { expect(subject.call).to eq nil }
    end

    context 'with empty string' do
      let(:value) { '' }
      it { expect(subject.call).to eq nil }
    end

    context 'with blank string' do
      let(:value) { "  \t" }
      it { expect(subject.call).to eq nil }
    end

    context 'with string UUID' do
      let(:value) { '450b7a40-94ad-11e3-baa8-0800200c9a66' }
      it { expect(subject.call).to be_a String }
      it { expect(subject.call).to eq value }
    end

    context 'with invalid string' do
      let(:value) { 'invalid string' }
      it { is_expected.to raise_error TypeError, /invalid UUID/i }
    end

    context 'with invalid UUID' do
      let(:value) { 'xxxxxxxx-yyyy-11e3-baa8-0800200c9a66' }
      it { is_expected.to raise_error TypeError, /invalid UUID/i }
    end
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
acfs-1.3.2 spec/acfs/resource/attributes/uuid_spec.rb
acfs-1.3.1 spec/acfs/resource/attributes/uuid_spec.rb
acfs-1.3.0 spec/acfs/resource/attributes/uuid_spec.rb
acfs-1.2.1 spec/acfs/resource/attributes/uuid_spec.rb
acfs-0.50.0 spec/acfs/resource/attributes/uuid_spec.rb
acfs-1.2.0 spec/acfs/resource/attributes/uuid_spec.rb
acfs-0.49.1 spec/acfs/resource/attributes/uuid_spec.rb
acfs-1.1.1 spec/acfs/resource/attributes/uuid_spec.rb
acfs-0.49.0 spec/acfs/resource/attributes/uuid_spec.rb
acfs-1.1.0 spec/acfs/resource/attributes/uuid_spec.rb
acfs-0.48.2 spec/acfs/resource/attributes/uuid_spec.rb
acfs-1.0.1 spec/acfs/resource/attributes/uuid_spec.rb
acfs-0.48.1 spec/acfs/resource/attributes/uuid_spec.rb
acfs-1.0.0 spec/acfs/resource/attributes/uuid_spec.rb
acfs-0.48.0 spec/acfs/resource/attributes/uuid_spec.rb
acfs-0.47.0 spec/acfs/resource/attributes/uuid_spec.rb
acfs-0.46.0 spec/acfs/resource/attributes/uuid_spec.rb