Sha256: f996364d591dd4e0849748b56b6d8cc2ad080a686b27f53afa7b93f2143eda41

Contents?: true

Size: 1006 Bytes

Versions: 14

Compression:

Stored size: 1006 Bytes

Contents

require_relative '../../test_helper'

class StateContextProxyWithMultipleUnlessConditionsTest < StateMachinesTest
  def setup
    @klass = Class.new(Validateable)
    machine = StateMachines::Machine.new(@klass, initial: :parked)
    state = machine.state :parked

    @state_context = StateMachines::StateContext.new(state)
    @object = @klass.new

    @first_condition_result = nil
    @second_condition_result = nil
    @options = @state_context.validate(unless: [-> { @first_condition_result }, lambda { @second_condition_result }])[0]
  end

  def test_should_be_true_if_all_conditions_are_false
    @first_condition_result = false
    @second_condition_result = false
    assert @options[:if].call(@object)
  end

  def test_should_be_false_if_any_condition_is_true
    @first_condition_result = true
    @second_condition_result = false
    refute @options[:if].call(@object)

    @first_condition_result = false
    @second_condition_result = true
    refute @options[:if].call(@object)
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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