Sha256: 6176d341c0365cf8aec0b522aee5b3af917cf282bd1404d016914ef0371c4357

Contents?: true

Size: 975 Bytes

Versions: 1

Compression:

Stored size: 975 Bytes

Contents

require 'spec_helper'

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

  it 'has a name' do
    Finite::State.new(@name).name.should 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.0.0 spec/state_spec.rb