Sha256: 59d1cfdfceaada9858a2bdacefb80d86a40d4b2b5c666cf0cb3e56942a769aa9

Contents?: true

Size: 816 Bytes

Versions: 22

Compression:

Stored size: 816 Bytes

Contents

require 'spec_helper'

describe Acfs::Model::Attributes::List do
  let(:model) { Class.new.tap { |c| c.send :include, Acfs::Model }}
  subject { Acfs::Model::Attributes::List }

  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 {
          subject.cast(sample)
        }.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

22 entries across 22 versions & 1 rubygems

Version Path
acfs-0.22.2.b193 spec/acfs/model/attributes/list_spec.rb
acfs-0.22.2 spec/acfs/model/attributes/list_spec.rb
acfs-0.22.1.b192 spec/acfs/model/attributes/list_spec.rb
acfs-0.22.1 spec/acfs/model/attributes/list_spec.rb
acfs-0.22.0.b191 spec/acfs/model/attributes/list_spec.rb
acfs-0.22.0.b190 spec/acfs/model/attributes/list_spec.rb
acfs-0.22.0 spec/acfs/model/attributes/list_spec.rb
acfs-0.21.1.b189 spec/acfs/model/attributes/list_spec.rb
acfs-0.21.1.rc1.b188 spec/acfs/model/attributes/list_spec.rb
acfs-0.21.1 spec/acfs/model/attributes/list_spec.rb
acfs-0.21.0.rc1.b187 spec/acfs/model/attributes/list_spec.rb
acfs-0.21.1.rc1 spec/acfs/model/attributes/list_spec.rb
acfs-0.21.0.rc1 spec/acfs/model/attributes/list_spec.rb
acfs-0.22.0.rc1.b186 spec/acfs/model/attributes/list_spec.rb
acfs-0.21.0.b185 spec/acfs/model/attributes/list_spec.rb
acfs-0.20.0.dev.b184 spec/acfs/model/attributes/list_spec.rb
acfs-0.21.0 spec/acfs/model/attributes/list_spec.rb
acfs-0.20.0.dev.b183 spec/acfs/model/attributes/list_spec.rb
acfs-0.20.0.dev.b182 spec/acfs/model/attributes/list_spec.rb
acfs-0.20.0.dev.b181 spec/acfs/model/attributes/list_spec.rb