Sha256: 7a693ed6cd642273b653fab8b6a20d2d8a892d06429c8c12f11545104e5f971c

Contents?: true

Size: 939 Bytes

Versions: 3

Compression:

Stored size: 939 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) { FactoryGirl.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

3 entries across 3 versions & 1 rubygems

Version Path
rapidfire-5.0.0 spec/models/rapidfire/survey_spec.rb
rapidfire-4.0.0 spec/models/rapidfire/survey_spec.rb
rapidfire-3.1.0 spec/models/rapidfire/survey_spec.rb