Sha256: d636811678f1e5dd16bf9231e3088bebb443d6b35284d5bbf5283241d12ac8e8

Contents?: true

Size: 704 Bytes

Versions: 2

Compression:

Stored size: 704 Bytes

Contents

# frozen_string_literal: true

RSpec.describe FiniteMachine::Hooks, '#inspect' do
  it "displays name and transitions" do
    hooks = FiniteMachine::Hooks.new
    hook = -> { }
    event = FiniteMachine::HookEvent::Enter
    hooks_map = {event => {yellow: [hook]}}

    hooks.register(event, :yellow, hook)

    expect(hooks.inspect).to eql("<#FiniteMachine::Hooks:0x#{hooks.object_id.to_s(16)} @hooks_map=#{hooks_map}>")
  end

  it "displays hooks content" do
    hooks = FiniteMachine::Hooks.new
    hook = -> { }
    event = FiniteMachine::HookEvent::Enter
    hooks_map = {event => {yellow: [hook]}}

    hooks.register(event, :yellow, hook)

    expect(hooks.to_s).to eql(hooks_map.to_s)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finite_machine-0.12.1 spec/unit/hooks/inspect_spec.rb
finite_machine-0.12.0 spec/unit/hooks/inspect_spec.rb