4bbd93ded1
Adding the .ruby-verison file triggered previously un-run cops, specifically: This cop is designed to help upgrade to Ruby 3.0. It will add the comment `# frozen_string_literal: true` to the top of files to enable frozen string literals. Frozen string literals will be default in Ruby 3.0. The comment will be added below a shebang and encoding comment. The frozen string literal comment is only valid in Ruby 2.3+. More info on rubocop [Automatic-Corrections](https://github.com/bbatsov/rubocop/wiki/Automatic-Corrections)
52 lines
1.6 KiB
Ruby
52 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
require 'test_helper'
|
|
|
|
class CandidateQuizQuestionTest < ActiveSupport::TestCase
|
|
def setup
|
|
@row = { "candidate_id" => "12345", "quiz_id" => 9876, "question_id" => 5, "answer_id" => 6,
|
|
"input_type" => 'text', "question" => 'what now?',
|
|
"input_options" => %w(one two three).to_yaml,
|
|
"answer" => { test: 1, foo: 'bar', cheer: 'huzzah!' }.to_yaml,
|
|
"saved" => false, "submitted" => true,
|
|
"updated_at" => DateTime.parse('20160816') }
|
|
end
|
|
|
|
test "propper dot attributes work" do
|
|
question = CandidateQuizQuestion.new @row
|
|
|
|
assert_equal '12345', question.candidate_id
|
|
assert_equal 9876, question.quiz_id
|
|
assert_equal 5, question.question_id
|
|
assert_equal 6, question.answer_id
|
|
assert_equal 'what now?', question.question
|
|
assert_equal 'text', question.input_type
|
|
assert_equal false, question.saved
|
|
assert_equal true, question.submitted
|
|
assert_equal DateTime.parse('20160816'), question.updated_at
|
|
end
|
|
|
|
test 'should handle array of input options' do
|
|
question = CandidateQuizQuestion.new @row
|
|
|
|
assert_kind_of Array, question.input_options
|
|
end
|
|
|
|
test "should handle string answer" do
|
|
question = CandidateQuizQuestion.new("answer" => "this is a text answer".to_yaml)
|
|
|
|
assert_kind_of String, question.answer
|
|
end
|
|
|
|
test "should handle array answer" do
|
|
question = CandidateQuizQuestion.new("answer" => %w(one two three four).to_yaml)
|
|
|
|
assert_kind_of Array, question.answer
|
|
end
|
|
|
|
test "should handle hash answer" do
|
|
question = CandidateQuizQuestion.new @row
|
|
|
|
assert_kind_of Hash, question.answer
|
|
end
|
|
end
|