Sha256: 7c44cc912ab213281f83c86a60b410f195225d55fda3ccffd4662ea9b73ab361

Contents?: true

Size: 984 Bytes

Versions: 1

Compression:

Stored size: 984 Bytes

Contents

# encoding: UTF-8

require 'spec_helper'

include Rosette::Core

describe SerializerId do
  module SerializersNoNaming
    module Foo
      class Bar; end
    end
  end

  module SerializersOneLevel
    module Foo
      class BarSerializer; end
    end
  end

  module SerializersTwoLevels
    module FooSerializer
      class BarSerializer; end
    end
  end

  let(:id) { SerializerId }

  describe '#resolve' do
    it 'resolves constants with no modified naming' do
      expect(id.resolve('foo/bar', SerializersNoNaming)).to(
        be(SerializersNoNaming::Foo::Bar)
      )
    end

    it 'resolves constants with one level of naming' do
      expect(id.resolve('foo/bar', SerializersOneLevel)).to(
        be(SerializersOneLevel::Foo::BarSerializer)
      )
    end

    it 'resolves constants with two levels of naming' do
      expect(id.resolve('foo/bar', SerializersTwoLevels)).to(
        be(SerializersTwoLevels::FooSerializer::BarSerializer)
      )
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rosette-core-1.0.1 spec/core/resolvers/serializer_id_spec.rb