class MachineDrawingTest

Public Class Methods

name() click to toggle source
# File test/unit/machine_test.rb, line 3138
def self.name; 'Vehicle'; end

Public Instance Methods

setup() click to toggle source
# File test/unit/machine_test.rb, line 3136
def setup
  @klass = Class.new do
    def self.name; 'Vehicle'; end
  end
  @machine = StateMachine::Machine.new(@klass, :initial => :parked)
  @machine.event :ignite do
    transition :parked => :idling
  end
end
teardown() click to toggle source
# File test/unit/machine_test.rb, line 3180
def teardown
  FileUtils.rm Dir["{.,#{File.dirname(__FILE__)}}/*.{png,jpg}"]
end
test_should_allow_base_name_to_be_customized() click to toggle source
# File test/unit/machine_test.rb, line 3155
def test_should_allow_base_name_to_be_customized
  graph = @machine.draw(:name => 'machine')
  assert File.exists?('./machine.png')
end
test_should_allow_format_to_be_customized() click to toggle source
# File test/unit/machine_test.rb, line 3160
def test_should_allow_format_to_be_customized
  graph = @machine.draw(:format => 'jpg')
  assert File.exists?('./Vehicle_state.jpg')
end
test_should_allow_orientation_to_be_landscape() click to toggle source
# File test/unit/machine_test.rb, line 3170
def test_should_allow_orientation_to_be_landscape
  graph = @machine.draw(:orientation => 'landscape')
  assert_equal 'LR', graph['rankdir'].to_s.gsub('"', '')
end
test_should_allow_orientation_to_be_portrait() click to toggle source
# File test/unit/machine_test.rb, line 3175
def test_should_allow_orientation_to_be_portrait
  graph = @machine.draw(:orientation => 'portrait')
  assert_equal 'TB', graph['rankdir'].to_s.gsub('"', '')
end
test_should_allow_path_to_be_customized() click to toggle source
# File test/unit/machine_test.rb, line 3165
def test_should_allow_path_to_be_customized
  graph = @machine.draw(:path => "#{File.dirname(__FILE__)}/")
  assert File.exists?("#{File.dirname(__FILE__)}/Vehicle_state.png")
end
test_should_raise_exception_if_invalid_option_specified() click to toggle source
# File test/unit/machine_test.rb, line 3146
def test_should_raise_exception_if_invalid_option_specified
  assert_raise(ArgumentError) {@machine.draw(:invalid => true)}
end
test_should_save_file_with_class_name_by_default() click to toggle source
# File test/unit/machine_test.rb, line 3150
def test_should_save_file_with_class_name_by_default
  graph = @machine.draw
  assert File.exists?('./Vehicle_state.png')
end