Sha256: 70ca6fe07764dcc5171f0e406ddd95833f7d2f6545ac4bf10653ef465f718d6b

Contents?: true

Size: 456 Bytes

Versions: 2

Compression:

Stored size: 456 Bytes

Contents

# frozen_string_literal: true

RSpec.describe FiniteMachine::Hooks, '#register' do
  it "adds and removes a single hook" do
    hooks = FiniteMachine::Hooks.new
    expect(hooks).to be_empty

    event_type = FiniteMachine::HookEvent::Before
    hook = -> { }

    hooks.register(event_type, :foo, hook)
    expect(hooks[event_type][:foo]).to eq([hook])

    hooks.unregister(event_type, :foo, hook)
    expect(hooks[event_type][:foo]).to eq([])
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

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