Sha256: 8251b618f98e879e1b8104eab680f750a0b26dec825d0378ed6a8721b413917a

Contents?: true

Size: 980 Bytes

Versions: 1

Compression:

Stored size: 980 Bytes

Contents

require 'spec_helper'

describe Finite::State do
  before(:each) do
    @name = :state_name
  end

  it 'has a name' do
    expect(Finite::State.new(@name).name).to eq(:state_name)
  end
  context 'equality' do
    it 'equals a symbol of the same name' do
      state = Finite::State.new(@name)
      expect(state).to eq(:state_name)
      expect(state).not_to eq(:different_name)
    end

    it 'equals a state with the same name' do
      state1 = Finite::State.new(@name)
      state2 = Finite::State.new(:different_name)
      state3 = Finite::State.new(@name)
      expect(state1).to eq(state3)
      expect(state1).not_to eq(state2)
    end

    it "doesn't equal objects that aren't states or symbols" do
      state = Finite::State.new(@name)
      expect(state).not_to eq('string')
    end
  end
  it 'has to_s and inspect methods' do
    state = Finite::State.new(@name)
    expect(state.to_s).to eq('state_name')
    expect(state.inspect).to eq(:state_name)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
finite-1.1.0 spec/state_spec.rb