Sha256: 2fb8bacd60355fb2e0213100ad74d63b249e96d33f0de13fffe3869e6963b451

Contents?: true

Size: 934 Bytes

Versions: 14

Compression:

Stored size: 934 Bytes

Contents

require_relative '../../test_helper'

class StateWithValidInheritedMethodCallForCurrentStateTest < StateMachinesTest
  def setup
    @superclass = Class.new do
      def speed(arg = nil)
        [arg]
      end
    end
    @klass = Class.new(@superclass)
    @machine = StateMachines::Machine.new(@klass, initial: :idling)
    @ancestors = @klass.ancestors
    @state = @machine.state(:idling)
    @state.context do
      def speed(arg = nil)
        [arg] + super(2)
      end
    end

    @object = @klass.new
  end

  def test_should_not_raise_an_exception
    @state.call(@object, :speed, method_missing: lambda { fail })
  end

  def test_should_be_able_to_call_super
    assert_equal [1, 2], @state.call(@object, :speed, 1)
  end

  def test_should_allow_redefinition
    @state.context do
      def speed(arg = nil)
        [arg] + super(3)
      end
    end

    assert_equal [1, 3], @state.call(@object, :speed, 1)
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

Version Path
state_machines-0.5.0 test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/state_machines-0.2.2/test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/state_machines-0.2.2/test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/state_machines-0.2.2/test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb
state_machines-0.4.0 test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb
state_machines-0.3.0 test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb
state_machines-0.2.2 test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb
state_machines-0.2.1 test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb
state_machines-0.2.0 test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb
state_machines-0.1.4 test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb
state_machines-0.1.3 test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb
state_machines-0.1.2 test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb
state_machines-0.1.1 test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb
state_machines-0.1.0 test/unit/state/state_with_valid_inherited_method_call_for_current_state_test.rb