Sha256: ef7f11131b2727c489c3e9b3209173df4e0f5d562c7f7e314dea67ecd1b1a075

Contents?: true

Size: 1.82 KB

Versions: 36

Compression:

Stored size: 1.82 KB

Contents

require 'spec_helper'

def struct(obj_in)
  OpenStruct.new(obj_in)
end

describe AssessmentFormPresenter do
  obj = {
          questions: [{id: nil, question: nil, answers: nil}],
          description: nil,
          course_path: nil,
          copyright: nil,
          submit_path: nil
        }

  subject { AssessmentFormPresenter.new(struct(obj)) }

  describe "#title" do
    it "should render correctly" do
      presenter = AssessmentFormPresenter.new struct(obj)

      presenter.title.should eq(I18n.t('woople_theme.assessment.name'))
    end
  end

  describe "#css_classes" do
    it "has the right classes" do
      presenter = AssessmentFormPresenter.new(struct(obj))
      presenter.css_classes.should be_nil
    end
  end

  describe "#questions" do
    it "should return a set of QuestionPresenters" do
      presenter = AssessmentFormPresenter.new(struct(obj))
      presenter.questions.first.is_a?(WoopleTheme::QuestionPresenter).should be_true
    end
  end

  describe "#render_result_status" do
    specify { expect { |b| subject.render_result_status(&b) }.not_to yield_control }
  end

  describe '#render_copyright' do
    describe 'when the copyright is not present' do
      obj[:copyright] = ''
      assessment_form = AssessmentFormPresenter.new struct(obj)

      specify { expect { |b| assessment_form.render_copyright(&b) }.not_to yield_control }
    end

    describe 'when the copyright is present' do
      obj[:copyright] = 'Copyright (c) 2012 Apple Inc. All rights reserved.'
      assessment_form = AssessmentFormPresenter.new( struct(obj) )

      specify { expect { |b| assessment_form.render_copyright(&b) }.to yield_control }
    end
  end

  describe "#footer_partial" do
    it "returns the correct partial name" do
      subject.footer_partial.should eq('woople-theme/assessment_form_submission')
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
woople-theme-0.10.0 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.9.0 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.19 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.18 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.17 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.16 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.15 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.14 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.13 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.12 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.11 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.10 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.9 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.8 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.7 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.6 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.5 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.4 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.3 spec/presenters/assessment_form_presenter_spec.rb
woople-theme-0.8.2 spec/presenters/assessment_form_presenter_spec.rb