class StateContextProxyWithMultipleIfConditionsTest

Public Instance Methods

setup() click to toggle source
# File test/unit/state_context_test.rb, line 258
def setup
  @klass = Class.new(Validateable)
  machine = StateMachine::Machine.new(@klass, :initial => :parked)
  state = machine.state :parked
  
  @state_context = StateMachine::StateContext.new(state)
  @object = @klass.new
  
  @first_condition_result = nil
  @second_condition_result = nil
  @options = @state_context.validate(:if => [lambda {@first_condition_result}, lambda {@second_condition_result}])[0]
end
test_should_be_false_if_any_condition_is_false() click to toggle source
# File test/unit/state_context_test.rb, line 277
def test_should_be_false_if_any_condition_is_false
  @first_condition_result = true
  @second_condition_result = false
  assert !@options[:if].call(@object)
  
  @first_condition_result = false
  @second_condition_result = true
  assert !@options[:if].call(@object)
end
test_should_be_true_if_all_conditions_are_true() click to toggle source
# File test/unit/state_context_test.rb, line 271
def test_should_be_true_if_all_conditions_are_true
  @first_condition_result = true
  @second_condition_result = true
  assert @options[:if].call(@object)
end