Sha256: be33214d91eba4c3357e185fb14f0ac55edd1983d03c50fcb30d73523ba40067

Contents?: true

Size: 652 Bytes

Versions: 2

Compression:

Stored size: 652 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

2 entries across 2 versions & 1 rubygems

Version Path
transitions-1.0.0 test/event/test_event_arguments.rb
transitions-0.2.1 test/event/test_event_arguments.rb