Sha256: bbaf76fdc0fd47380c74360a0c983017b549d1ee0565626f4c13b07c25b2580e

Contents?: true

Size: 1.44 KB

Versions: 17

Compression:

Stored size: 1.44 KB

Contents

# frozen_string_literal: true

require_relative '..\..\spec_helper'
require_relative '..\..\..\lib\dendroid\syntax\grm_symbol'

describe Dendroid::Syntax::GrmSymbol do
  let(:sample_symbol_name) { 'INTEGER' }

  subject { described_class.new(sample_symbol_name) }

  context 'Initialization:' do
    it 'is initialized with a name as String' do
      expect { described_class.new(sample_symbol_name) }.not_to raise_error
    end

    it 'is initialized with a name as Symbol' do
      expect { described_class.new(:INTEGER) }.not_to raise_error
    end

    it 'raises an error if the symbol name is empty' do
      err_msg = 'A symbol name cannot be empty.'
      expect { described_class.new('') }.to raise_error(StandardError, err_msg)
    end
  end # context

  context 'Provided services:' do
    it 'knows its name as a Symbol' do
      expect(subject.name).to eq(sample_symbol_name.to_sym)
    end

    it 'renders a String representation of itself' do
      expect(subject.to_s).to eq(sample_symbol_name)
    end

    # rubocop: disable Lint/BinaryOperatorWithIdenticalOperands
    it 'can compare with another symbol' do
      expect(subject == subject).to be_truthy
      same = described_class.new(sample_symbol_name)
      expect(subject == same).to be_truthy
      different = described_class.new('NUMBER')
      expect(subject == different).to be_falsey
    end
    # rubocop: enable Lint/BinaryOperatorWithIdenticalOperands
  end # context
end # describe

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
dendroid-0.2.04 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.2.03 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.2.02 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.2.01 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.2.00 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.1.00 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.0.12 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.0.11 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.0.10 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.0.9 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.0.8 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.0.7 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.0.6 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.0.5 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.0.4 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.0.3 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.0.2 spec/dendroid/syntax/grm_symbol_spec.rb