Sha256: 0c40615525aa5951c9868690527fb8317142295905492f05e4fda775d08aed9c

Contents?: true

Size: 619 Bytes

Versions: 2

Compression:

Stored size: 619 Bytes

Contents

require 'helper'

class Bus
  include Transitions

  state_machine do
    state :parking
  end
end

class TestStatePredicateMethod < Test::Unit::TestCase
  def setup
    @bus = Bus.new
  end

  test 'should generate predicate methods for states' do
    assert_true @bus.respond_to?(:parking?)
    assert_true @bus.send(:parking?)
  end

  test 'should raise `InvalidMethodOverride` if we try to overwrite existing methods' do
    assert_raise(Transitions::InvalidMethodOverride) do
      Class.new do
        include Transitions

        state_machine do
          state :frozen
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
transitions-1.0.0 test/state/test_state_predicate_method.rb
transitions-0.2.1 test/state/test_state_predicate_method.rb