File: machine_errors_test.rb

package info (click to toggle)
ruby-state-machines-activemodel 0.5.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 276 kB
  • sloc: ruby: 860; makefile: 5
file content (19 lines) | stat: -rw-r--r-- 613 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
require_relative 'test_helper'

class MachineErrorsTest < BaseTestCase
  def setup
    @model = new_model { include ActiveModel::Validations }
    @machine = StateMachines::Machine.new(@model)
    @record = @model.new
  end

  def test_should_be_able_to_describe_current_errors
    @record.errors.add(:id, 'cannot be blank')
    @record.errors.add(:state, 'is invalid')
    assert_equal ['Id cannot be blank', 'State is invalid'], @machine.errors_for(@record).split(', ').sort
  end

  def test_should_describe_as_halted_with_no_errors
    assert_equal 'Transition halted', @machine.errors_for(@record)
  end
end