Sha256: dbdba232c4ae4126e460f60d534249e54d7eef13445336c87074aeeefe220cd8

Contents?: true

Size: 795 Bytes

Versions: 4

Compression:

Stored size: 795 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe FiniteMachine::Event, 'new' do
  let(:machine) { double(:machine) }
  let(:name)    { :green }
  let(:options) { {} }
  let(:object)  { described_class }

  subject(:event) { object.new(machine, options) }

  context "by default" do
    it "sets name to :none" do
      expect(event.name).to eql(:none)
    end

    it "sets silent to false"do
      expect(event.silent).to eql(false)
    end
  end

  context "with custom data" do
    let(:options) { {silent: true, name: name} }

    it "sets name to :green" do
      expect(event.name).to eql(name)
    end

    it "sets silent to true"do
      expect(event.silent).to eql(true)
    end
  end

  it "freezes object" do
    expect { event.name = :red }.to raise_error(RuntimeError)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
finite_machine-0.10.0 spec/unit/event/initialize_spec.rb
finite_machine-0.9.2 spec/unit/event/initialize_spec.rb
finite_machine-0.9.1 spec/unit/event/initialize_spec.rb
finite_machine-0.9.0 spec/unit/event/initialize_spec.rb