Sha256: 04b5b2e6d71a1cc0f8baa63d835ecd35ebf7baa1a70a2fa7b093e0a6be8ad746

Contents?: true

Size: 1.08 KB

Versions: 3

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

RSpec.describe Yardcheck::Typedef::Parser do
  def parse(*types)
    described_class.new('TestApp::Namespace', types).parse
  end

  it 'resolves one normal constant' do
    expect(parse('Integer')).to eql(Yardcheck::Typedef.new([
      Yardcheck::Typedef::Literal.new(Yardcheck::Const.new(Integer))
    ]))
  end

  it 'resolves multiple constants' do
    expect(parse('Integer', 'String')).to eql(Yardcheck::Typedef.new([
      Yardcheck::Typedef::Literal.new(Yardcheck::Const.new(Integer)),
      Yardcheck::Typedef::Literal.new(Yardcheck::Const.new(String))
    ]))
  end

  it 'resolves child of namespace' do
    expect(parse('Child')).to eql(Yardcheck::Typedef.new([
      Yardcheck::Typedef::Literal.new(Yardcheck::Const.new(TestApp::Namespace::Child))
    ]))
  end

  it 'handles array of items' do
    expect(parse('Array<String>')).to eql(
      Yardcheck::Typedef.new([
        Yardcheck::Typedef::Collection.new(
          Yardcheck::Const.new(Array),
          [Yardcheck::Typedef::Literal.new(Yardcheck::Const.new(String))]
        )
      ])
    )
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
yardcheck-0.0.3 spec/unit/yardcheck/typedef/parser_spec.rb
yardcheck-0.0.2 spec/unit/yardcheck/typedef/parser_spec.rb
yardcheck-0.0.1 spec/unit/yardcheck/typedef/parser_spec.rb