Sha256: 7ef6bde6f88af1ac3c39afd9976bfc5dbad22f59a50ee54e6aa9a5aba6c34971

Contents?: true

Size: 1.35 KB

Versions: 2

Compression:

Stored size: 1.35 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

    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
  end # context
end # describe

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
dendroid-0.0.1 spec/dendroid/syntax/grm_symbol_spec.rb
dendroid-0.0.0 spec/dendroid/syntax/grm_symbol_spec.rb