Sha256: dbdc8d7cead1326fdc17824dc51b4a62b8dd45d40472c67664ac562c15a69f43

Contents?: true

Size: 662 Bytes

Versions: 25

Compression:

Stored size: 662 Bytes

Contents

require "helper"

class ArgumentsTestSubject
  include Transitions
  attr_accessor :date

  state_machine do
    state :initial
    state :opened

    event :open do
      transitions :from => :initial, :to => :opened, :on_transition => :update_date
    end
  end

  def update_date(date = Date.today)
    self.date = date
  end
end

class StateMachineMachineTest < Test::Unit::TestCase
  test "pass arguments to transition method" do
    subject = ArgumentsTestSubject.new
    assert_equal :initial, subject.current_state
    subject.open!(Date.yesterday)
    assert_equal :opened, subject.current_state
    assert_equal Date.yesterday, subject.date
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
transitions-0.0.12 test/test_event_arguments.rb
transitions-0.0.11 test/test_event_arguments.rb
transitions-0.0.10 test/test_event_arguments.rb
transitions-0.0.9 test/test_event_arguments.rb
transitions-0.0.5 test/test_event_arguments.rb