Sha256: be5dfc16c1009b197d254f5030d22bb8ab9b91608182b36e57abd55ac52e0a6b

Contents?: true

Size: 1.01 KB

Versions: 25

Compression:

Stored size: 1.01 KB

Contents

require_relative '../../test_helper'
module Qwester

  class QuestionTest < ActiveSupport::TestCase

    def setup
      @question = Question.find(2)
    end

    def test_setup
      assert_equal(0, @question.answers.count)
    end

    def test_build_standard_answers
      assert_no_difference 'Answer.count' do
        @question.build_standard_answers
        assert_question_has_standard_answers
      end
    end

    def test_create_standard_answers
      assert_difference 'Answer.count', Answer.standard_values.length do
        @question.create_standard_answers
        assert_question_has_standard_answers
      end
    end

    def test_destroy
      test_create_standard_answers
      assert_difference 'Question.count', -1 do
        assert_difference 'Answer.count', -(Answer.standard_values.length) do
          @question.destroy
        end
      end
    end

    private
    def assert_question_has_standard_answers
      assert_equal(Answer.standard_values, @question.answers.collect(&:value))
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
qwester-0.5.0 test/unit/qwester/question_test.rb
qwester-0.4.0 test/unit/qwester/question_test.rb
qwester-0.3.5 test/unit/qwester/question_test.rb
qwester-0.3.4 test/unit/qwester/question_test.rb
qwester-0.3.3 test/unit/qwester/question_test.rb
qwester-0.3.2 test/unit/qwester/question_test.rb
qwester-0.3.1 test/unit/qwester/question_test.rb
qwester-0.3.0 test/unit/qwester/question_test.rb
qwester-0.2.2 test/unit/qwester/question_test.rb
qwester-0.2.1 test/unit/qwester/question_test.rb
qwester-0.2.0 test/unit/qwester/question_test.rb
qwester-0.1.4 test/unit/qwester/question_test.rb
qwester-0.1.3 test/unit/qwester/question_test.rb
qwester-0.1.2 test/unit/qwester/question_test.rb
qwester-0.1.1 test/unit/qwester/question_test.rb
qwester-0.1.0 test/unit/qwester/question_test.rb
qwester-0.0.9 test/unit/qwester/question_test.rb
qwester-0.0.8 test/unit/qwester/question_test.rb
qwester-0.0.7 test/unit/qwester/question_test.rb
qwester-0.0.6 test/unit/qwester/question_test.rb