Sha256: 20f96eac4006cca74531831234fc5c86d65d84d9a2bf518a1b7f4f714a66bdbe

Contents?: true

Size: 748 Bytes

Versions: 14

Compression:

Stored size: 748 Bytes

Contents

require_relative '../test_helper'
require_relative '../files/models/vehicle'

class VehicleWithEventAttributesTest < MiniTest::Test
  def setup
    @vehicle = Vehicle.new
    @vehicle.state_event = 'ignite'
  end

  def test_should_fail_if_event_is_invalid
    @vehicle.state_event = 'invalid'
    refute @vehicle.save
    assert_equal 'parked', @vehicle.state
  end

  def test_should_fail_if_event_has_no_transition
    @vehicle.state_event = 'park'
    refute @vehicle.save
    assert_equal 'parked', @vehicle.state
  end

  def test_should_return_original_action_value_on_success
    assert_equal @vehicle, @vehicle.save
  end

  def test_should_transition_state_on_success
    @vehicle.save
    assert_equal 'idling', @vehicle.state
  end
end

Version data entries

14 entries across 14 versions & 2 rubygems

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