Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
26 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,30 @@ | ||
require 'test_helper' | ||
|
||
class QuestionTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
|
||
test "Question should be added" do | ||
question = questions(:question_valid) | ||
assert question.valid? | ||
end | ||
|
||
test "Question attributes must not be empty" do | ||
question = Question.new | ||
assert question.invalid? | ||
assert question.errors[:question].any? | ||
assert question.errors[:question_type].any? | ||
assert question.errors[:question_options].any? | ||
assert question.errors[:survey_id].any? | ||
end | ||
|
||
test "survey_id of the question must exist" do | ||
question = questions(:question_invalid_survey_id) | ||
assert question.invalid? | ||
assert question.errors[:survey_id], "does not exist" | ||
end | ||
|
||
test "question type must be either 'numeric' or 'essay' or 'date'" do | ||
question = questions(:question_invalid_type) | ||
assert question.invalid? | ||
end | ||
|
||
end |