Sha256: c81f586caefc866ffa9827fcda3892698c7b925b98fd8602e6285c0777aea728
Contents?: true
Size: 845 Bytes
Versions: 1
Compression:
Stored size: 845 Bytes
Contents
require 'rails_helper' module Quizzes RSpec.describe GameQuestion, type: :model do it { should validate_presence_of(:game) } before(:each) do create_questions_in_sequence(20) @game_questions = GameQuestionFactory.new({ game: create(:game), questions: Question.all }).generate end it "does have only one correct answer among all choices" do number_of_right_answers = 0 game_question = @game_questions.first game_question.question.answers.each do |answer| number_of_right_answers = number_of_right_answers + 1 if answer.correct? end expect(number_of_right_answers).to eq(1) end it "is able to identify the correct answer" do expect( @game_questions.first.correct?(@game_questions.first.question.correct_answer.id) ).to be true end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
quizzes-0.1.0 | spec/models/quizzes/game_question_spec.rb |