Sha256: 5efdd3ffa471f6b58be503a223a774d094c1ca96120e5c0a3920e9333a6908e7

Contents?: true

Size: 764 Bytes

Versions: 2

Compression:

Stored size: 764 Bytes

Contents

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

    subject{ Selection.coerce(arg) }

    before do
      subject.should be_a(Selection)
    end

    let(:expected){
      Selection.new([ Selector.new(:name), Selector.new(:city) ])
    }

    context 'on an array of strings' do
      let(:arg){ ["name", "city"] }

      it { should eq(expected) }
    end

    context 'on an array of strings with composite selections' do
      let(:arg){ ["name", "city.name"] }

      let(:expected){
        Selection.new([ Selector.new(:name), Selector.new([:city, :name]) ])
      }

      it { should eq(expected) }
    end

    context 'on an array of symbols' do
      let(:arg){ [:name, :city] }

      it { should eq(expected) }
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-types/selection/test_coerce.rb
alf-core-0.14.0 spec/unit/alf-types/selection/test_coerce.rb