Sha256: 7153d035e90c07c84a2f1883e6d267b4b7109d59b5acd00accbb2330e4aee341

Contents?: true

Size: 1.13 KB

Versions: 26

Compression:

Stored size: 1.13 KB

Contents

require "spec_helper"

describe ACTV::QuizQuestion do
  let(:asset_categories) { [ { category: { categoryName: "Question", categoryTaxonomy: "Creative Work:Quiz:Question" } } ] }
  let(:response) { { body: { assetGuid: 1, assetCategories: asset_categories } } }
  subject(:question) { ACTV::Asset.from_response response }

  describe '#answers' do
    subject(:answers) { question.answers }
    context 'when there are answer assets' do
      it 'returns an array of quiz answers' do
        answer = double(:answer, assetGuid: 123)
        allow(answer).to receive(:category_is?).with('answer') { true }
        not_answer = double(:not_answer, assetGuid: 234)
        allow(not_answer).to receive(:category_is?).with('answer') { false }
        components = [answer, not_answer]
        allow(question).to receive(:components) { components }
        allow(ACTV).to receive(:asset) { components }

        expect(answers).to eq [answer]
      end
    end

    context 'when there are not answer assets' do
      it 'should be empty' do
        allow(question).to receive(:components) { [] }
        expect(answers).to eq []
      end
    end
  end
end

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
actv-2.10.9 spec/actv/quiz_question_spec.rb
actv-2.10.8 spec/actv/quiz_question_spec.rb
actv-2.10.7 spec/actv/quiz_question_spec.rb
actv-2.10.6 spec/actv/quiz_question_spec.rb
actv-2.10.5 spec/actv/quiz_question_spec.rb
actv-2.10.4 spec/actv/quiz_question_spec.rb
actv-2.10.3 spec/actv/quiz_question_spec.rb
actv-2.10.2 spec/actv/quiz_question_spec.rb
actv-2.10.1 spec/actv/quiz_question_spec.rb
actv-2.10.0 spec/actv/quiz_question_spec.rb
actv-2.9.2 spec/actv/quiz_question_spec.rb
actv-2.9.1 spec/actv/quiz_question_spec.rb
actv-2.9.0 spec/actv/quiz_question_spec.rb
actv-2.8.2 spec/actv/quiz_question_spec.rb
actv-2.8.1 spec/actv/quiz_question_spec.rb
actv-2.7.0 spec/actv/quiz_question_spec.rb
actv-2.6.0 spec/actv/quiz_question_spec.rb
actv-2.5.2 spec/actv/quiz_question_spec.rb
actv-2.5.1 spec/actv/quiz_question_spec.rb
actv-2.5.0 spec/actv/quiz_question_spec.rb