Sha256: 22a32a91cc6e17e8b9ccdb4e00e0ce9297c97f75546592a60e0109b6161856c5

Contents?: true

Size: 1.39 KB

Versions: 9

Compression:

Stored size: 1.39 KB

Contents

require "spec_helper"

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

describe Shamu::Entities::EntityPath do
  include Shamu::Entities::EntityPath

  {
    "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( 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( compose_entity_path( entities ) ).to eq path
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
shamu-0.0.13 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.11 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.9 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.8 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.7 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.5 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.4 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.3 spec/lib/shamu/entities/entity_path_spec.rb
shamu-0.0.2 spec/lib/shamu/entities/entity_path_spec.rb