Sha256: eb4f1f7fc8f6df44c8f6c3491d260ae2cae00d22c507ef23e71c2ac65ccbe846

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require_relative '../spec_helper'

# Load the class under test
require_relative '../../lib/sequitur/digram'

module Sequitur # Re-open the module to get rid of qualified names
describe Digram do
  let(:two_symbols) { [:b, :c] }
  let(:production) { double('sample-production') }

  context 'Standard creation & initialization:' do
    it 'should be created with 3 arguments' do
      instance = Digram.new(:b, :c, production)
      
      expect(instance.symbols).to eq(two_symbols)
      expect(instance.production).to eq(production)
    end
    
    it 'should return the production that it refers to' do
      instance = Digram.new(:b, :c, production)
      expect(instance.production).to eq(production)
    end
    
    it 'should whether its symbols are the same' do
       instance1 = Digram.new(:a, :a, production)
       expect(instance1).to be_repeating
       
       instance1 = Digram.new(:a, :b, production)
       expect(instance1).not_to be_repeating       
    end
  end # context

  context 'Provided services:' do
    it 'should compare itself to another digram' do
      instance1 = Digram.new(:a, :b, production)
      same = Digram.new(:a, :b, production)
      different = Digram.new(:b, :c, production)
      
      expect(instance1).to eq(instance1)
      expect(instance1).to eq(same)
      expect(instance1).not_to eq(different)
      expect(same).not_to eq(different)       
    end
  end # context
end # describe
end # module

# End of file

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sequitur-0.1.18 spec/sequitur/digram_spec.rb