Sha256: 3aa8f9b0de77e293b9486b63f3dadd305e86bbd25647f0e4fcc948876ca8ba4f

Contents?: true

Size: 1.32 KB

Versions: 4

Compression:

Stored size: 1.32 KB

Contents

require 'spec_helper'
module Alf
  describe Keys, ".coerce" do

    subject{ Keys.coerce(arg) }

    let(:expected){ Keys.new [ AttrList[:id], AttrList[:name] ] }

    context 'on a Keys' do
      let(:arg){ expected }

      it{ should be(arg) }
    end

    context 'on an Array of AttrList coercables' do
      let(:arg){ [ [:id], [:name] ] }

      it{ should eq(expected) }
    end
  end
  describe Keys, "[]" do

    let(:expected){ Keys.new [ AttrList[:id], AttrList[:name] ] }

    context 'on a varargs with arrays of symbols' do
      subject{ Keys[ [:id], [:name] ] }

      it{ should eq(expected) }
    end

    context 'on [:a, :b]' do
      subject{ Keys[ [:a, :b] ] }

      it 'should have correct AttrList lists' do
        subject.to_a.should eq([ AttrList[:a, :b] ])
      end
    end

    context 'on empty' do
      subject{ Keys[] }

      it 'should have correct AttrList lists' do
        subject.to_a.should eq([])
      end
    end

    context 'on one empty list' do
      subject{ Keys[ [] ] }

      it 'should have correct AttrList lists' do
        subject.to_a.should eq([ AttrList[] ])
      end
    end

    context 'at least one empty list' do
      subject{ Keys[ [:a], [] ] }

      it 'should have correct AttrList lists' do
        subject.to_a.should eq([ AttrList[:a], AttrList[] ])
      end
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-types/keys/test_coerce.rb
alf-core-0.14.0 spec/unit/alf-types/keys/test_coerce.rb
alf-core-0.13.1 spec/unit/alf-types/keys/test_coerce.rb
alf-core-0.13.0 spec/unit/alf-types/keys/test_coerce.rb