Skip to content

Commit

Permalink
Adding unit test for questions
Browse files Browse the repository at this point in the history
  • Loading branch information
nxvipin committed Apr 3, 2013
1 parent 39afee6 commit 73a7114
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions test/unit/question_test.rb
@@ -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

0 comments on commit 73a7114

Please sign in to comment.