Sha256: 7737a15a84ad9e8c54c955c8f565e1b4a5b52bf55453d47a72da0d727442a0e7

Contents?: true

Size: 1.75 KB

Versions: 2

Compression:

Stored size: 1.75 KB

Contents

require "spec_helper"

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

  describe '#questions' do
    subject(:questions) { quiz.questions }

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

        expect(questions).to eq [question]
      end
    end

    context 'when there are not question assets' do
      it { should be_empty }
    end
  end

  describe '#outcomes' do
    subject(:outcomes) { quiz.outcomes }

    context 'when there are outcome assets' do
      it 'returns an array of quiz outcomes' do
        outcome = double(:outcome, assetGuid: 123)
        allow(outcome).to receive(:category_is?).with('outcome') { true }
        not_outcome = double(:not_outcome, assetGuid: 234)
        allow(not_outcome).to receive(:category_is?).with('outcome') { false }
        components = [outcome, not_outcome]
        allow(quiz).to receive(:components) { components }
        allow(ACTV).to receive(:asset) { components }

        expect(outcomes).to eq [outcome]
      end
    end

    context 'when there are no outcome assets' do
      it { should be_empty }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
actv-2.1.1 spec/actv/quiz_spec.rb
actv-2.1.0 spec/actv/quiz_spec.rb