Skip to content

Commit

Permalink
Added fixtures and tests to use the new Quiz model class and the asso…
Browse files Browse the repository at this point in the history
…ciation with MultipleChoiceQuestion
  • Loading branch information
sdflem committed Oct 22, 2018
1 parent 5e0f016 commit a17d7a5
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
2 changes: 2 additions & 0 deletions test/fixtures/multiple_choice_questions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ one:
distractor_2: Min
distractor_3: Moon
distractor_4: Mine
quiz: one

two:
question: What does the V in MVC stand for?
Expand All @@ -35,3 +36,4 @@ two:
distractor_2: Vice
distractor_3: Vast
distractor_4: Vehicle
quiz: one
8 changes: 4 additions & 4 deletions test/fixtures/quizzes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html

one:
title: MyString
description: MyText
title: Rails MVC
description: Rails MVC blah blah blah.

two:
title: MyString
description: MyText
title: Git and GitHub
description: Git and Github blah blah blah.
6 changes: 6 additions & 0 deletions test/models/multiple_choice_question_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,10 @@ class MultipleChoiceQuestionTest < ActiveSupport::TestCase
one.question = nil
assert_not one.valid?
end

test "multiple choice question must have parent quiz" do
one = multiple_choice_questions(:one)
one.quiz_id = nil
assert_not one.valid?
end
end
10 changes: 10 additions & 0 deletions test/models/quiz_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,14 @@ class QuizTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end

test "quiz should be valid" do
one = quizzes(:one)
assert one.valid?
end

test "quiz with no questions should be valid" do
two = quizzes(:two)
assert two.valid?
end
end

0 comments on commit a17d7a5

Please sign in to comment.