Sha256: fe97d1fbe54bfd33014ec6e8c35db9303d465c0d3cd3b099486ea122be858f39

Contents?: true

Size: 938 Bytes

Versions: 1

Compression:

Stored size: 938 Bytes

Contents

require 'spec_helper'

describe Rapidfire::Survey do
  include Rapidfire::QuestionSpecHelper

  describe "Validations" do
    it { is_expected.to validate_presence_of(:name) }
  end

  describe "Associations" do
    it { is_expected.to have_many(:questions) }
  end

  describe "factory" do
    let(:survey) { FactoryBot.create(:survey) }

    it "has a name" do
      expect(survey.name).to eql("Test Survey")
    end

    it "creates questions" do
      last_question = create_questions(survey)
      expect(last_question.survey).to eql(survey)
      expect(last_question.question_text).not_to be_nil
      expect(last_question.question_text).to eql("Sample Question")

      qs = survey.questions.to_a
      expect(qs).not_to be_empty
      final_question = qs[-1]
      expect(final_question).not_to be_nil
      expect(final_question).to eql(last_question)
      expect(final_question.question_text).not_to be_nil
    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rapidfire-8.0.0 spec/models/rapidfire/survey_spec.rb