Sha256: d628f23ac21531a0e2b959fda8e89834f7ef45cbed8f2afc2ecb8a85d2b07126

Contents?: true

Size: 1.41 KB

Versions: 8

Compression:

Stored size: 1.41 KB

Contents

require "spec_helper"

module EntityPathSpec
  class ExampleEntity < Shamu::Entities::Entity
    attribute :id
  end
end

describe Shamu::Entities::EntityPath do

  {
    "User[45]/Calendar[567]/Event[1]" => [
                                           [ "User", "45" ],
                                           [ "Calendar", "567" ],
                                           [ "Event", "1" ]
                                         ],
    "User[45]"                        => [ [ "User", "45" ] ],
    "EntityPathSpec::Example[91]"     => [ [ "EntityPathSpec::Example", "91" ] ]
  }.each do |path, entities|
    it "decompose #{ path } to #{ entities }" do
      expect( Shamu::Entities::EntityPath.decompose_entity_path( path ) ).to eq entities
    end
  end

  {
    "User[45]/Calendar[567]/Event[1]" => [
                                           [ "UserEntity", "45" ],
                                           [ "Calendar", "567" ],
                                           [ "Event", "1" ]
                                         ],
    "User[45]"                        => [ [ "User", "45" ] ],
    "User[37]"                        => [ "User[37]" ],
    "EntityPathSpec::Example[91]"     => [ EntityPathSpec::ExampleEntity.new( id: 91 ) ]
  }.each do |path, entities|
    it "composes #{ entities } to #{ path }" do
      expect( Shamu::Entities::EntityPath.compose_entity_path( entities ) ).to eq path
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
shamu-0.0.24 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.21 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.20 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.19 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.18 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.17 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.15 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.14 spec/lib/shamu/entities/entity_path_spec.rb