Sha256: a44f956b2ff09b37a2b9154810ec07a6e5119584af057980652fcc54f8256102

Contents?: true

Size: 787 Bytes

Versions: 8

Compression:

Stored size: 787 Bytes

Contents

require 'spec_helper'

describe Acfs::Resource::Attributes::List do
  let(:model) { Class.new Acfs::Resource }
  subject { described_class.new }

  describe '.cast' do
    context 'with array' do
      let(:sample) { %w(abc cde efg) }

      it 'should return unmodified array' do
        expect(subject.cast(sample)).to be == %w(abc cde efg)
      end
    end

    context 'with not listable object' do
      let(:sample) { Object.new }

      it 'should raise a TypeError' do
        expect do
          subject.cast(sample)
        end.to raise_error TypeError
      end
    end

    context 'with listable object' do
      let(:sample) { 5..10 }

      it 'should cast object to array' do
        expect(subject.cast(sample)).to be == [5, 6, 7, 8, 9, 10]
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
acfs-0.45.0 spec/acfs/resource/attributes/list_spec.rb
acfs-0.44.0 spec/acfs/resource/attributes/list_spec.rb
acfs-0.43.2 spec/acfs/resource/attributes/list_spec.rb
acfs-0.43.1 spec/acfs/resource/attributes/list_spec.rb
acfs-0.43.0 spec/acfs/resource/attributes/list_spec.rb
acfs-1.0.0.dev.1.b305 spec/acfs/resource/attributes/list_spec.rb
acfs-1.0.0.dev.1.b298 spec/acfs/resource/attributes/list_spec.rb
acfs-1.0.0.dev.1.b297 spec/acfs/resource/attributes/list_spec.rb