# frozen_string_literal: true
require 'test_helper'

class AnswerFormatValidatorTest < ActiveSupport::TestCase
  test "radio should pass with string" do
    obj = AnswerValidatable.new('radio')
    obj.answer = 'option-1'

    assert obj.valid?
    assert obj.errors.messages.empty?
  end

  test "radio should FAIL with nil" do
    obj = AnswerValidatable.new('radio')
    obj.answer = nil

    refute obj.valid?
    assert_match(/select.*answer/, obj.errors.messages[:answer][0])
  end

  test "radio should FAIL with empty string" do
    obj = AnswerValidatable.new('radio')
    obj.answer = ''

    refute obj.valid?
    assert_match(/select.*answer/, obj.errors.messages[:answer][0])
  end
end
