Sha256: 362fcbf4d05511020112daf852c5af318765af70fda7b94151ae99c77d3a677f

Contents?: true

Size: 801 Bytes

Versions: 1

Compression:

Stored size: 801 Bytes

Contents

# frozen_string_literal: true

require 'spec_helper'

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

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

    context 'with nil' do
      let(:value) { nil }

      it { expect(cast.call).to eq nil }
    end

    context 'with empty string' do
      let(:value) { '' }

      it { expect(cast.call).to eq 0 }
    end

    context 'with blank string' do
      let(:value) { "  \t" }

      it { expect(cast.call).to eq 0 }
    end

    context 'with string' do
      let(:value) { '123' }

      it { expect(cast.call).to eq 123 }
    end

    context 'with invalid string' do
      let(:value) { '123a' }

      it { is_expected.to raise_error ArgumentError }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
acfs-1.7.0 spec/acfs/resource/attributes/integer_spec.rb