Sha256: 5de30778f2fc40050866b7210e0096b9fe3c8d43de276793f46be18a86b21a89

Contents?: true

Size: 684 Bytes

Versions: 2

Compression:

Stored size: 684 Bytes

Contents

# frozen_string_literal: true

RSpec.describe FiniteMachine, '#respond_to' do

  subject(:fsm) {
    stub_const("Car", Class.new do
      def engine_on?
        true
      end
    end)

    FiniteMachine.new target: Car.new do
      initial :green

      event :slow,  :green  => :yellow
    end
  }

  it "knows about event name" do
    expect(fsm).to respond_to(:slow)
  end

  it "doesn't know about not implemented call" do
    expect(fsm).not_to respond_to(:not_implemented)
  end

  it "knows about event callback" do
    expect(fsm).to respond_to(:on_enter_slow)
  end

  it "doesn't know about target class methods" do
    expect(fsm).not_to respond_to(:engine_on?)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finite_machine-0.12.1 spec/unit/respond_to_spec.rb
finite_machine-0.12.0 spec/unit/respond_to_spec.rb