Sha256: 6723f67923525c7fe3f7314351a6eb71c8f7756c0d67ead8e4a2045053413cae

Contents?: true

Size: 768 Bytes

Versions: 3

Compression:

Stored size: 768 Bytes

Contents

require_relative 'test_helper'

class MachineWithDifferentColumnDefaultTest < BaseTestCase
  def setup
    @original_stderr, $stderr = $stderr, StringIO.new

    @model = new_model do
      field :status, :type => String, :default => 'idling'
    end
    @machine = StateMachines::Machine.new(@model, :status, :initial => :parked)
    @record = @model.new
  end

  def test_should_use_machine_default
    assert_equal 'parked', @record.status
  end

  def test_should_generate_a_warning
    assert_match(/Both MongoidTest::Foo and its :status machine have defined a different default for "status". Use only one or the other for defining defaults to avoid unexpected behaviors\./, $stderr.string)
  end

  def teardown
    $stderr = @original_stderr
    super
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
state_machines-mongoid-0.2.0 test/machine_with_different_column_default_test.rb
state_machines-mongoid-0.1.1 test/machine_with_different_column_default_test.rb
state_machines-mongoid-0.1.0 test/machine_with_different_column_default_test.rb