Sha256: 374ed6c0ea3f70cbc6fe2db66cc765332c8815203629d00b555bc028a012c886

Contents?: true

Size: 799 Bytes

Versions: 2

Compression:

Stored size: 799 Bytes

Contents

require 'spec_helper'
module Alf
  describe Selector, "select" do

    subject{ selector.select(tuple) }

    let(:tuple){ {name: "foo", city: {name: "bar"}} }

    context 'on name' do
      let(:selector){ Selector.coerce("name") }

      it{ should eq("foo") }
    end

    context 'on city' do
      let(:selector){ Selector.coerce("city") }

      it{ should eq(name: "bar") }
    end

    context 'on unexisting' do
      let(:selector){ Selector.coerce("unexisting") }

      it{ should be_nil }
    end

    context 'on unexisting composite' do
      let(:selector){ Selector.coerce("city.unexisting") }

      it{ should be_nil }
    end

    context 'on unexisting composite II' do
      let(:selector){ Selector.coerce("cities.unexisting") }

      it{ should be_nil }
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
alf-core-0.15.0 spec/unit/alf-types/selector/test_select.rb
alf-core-0.14.0 spec/unit/alf-types/selector/test_select.rb