Sha256: f87a0e4e43f8fd19486d4927c1a5e044debc97094d452d02070297cf6486a92d

Contents?: true

Size: 1.47 KB

Versions: 36

Compression:

Stored size: 1.47 KB

Contents

require 'spec_helper'

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

describe WoopleTheme::SubmittedAnswerPresenter do
  obj = {
    index: nil,
    text: nil,
    correct?: false,
    incorrect?: false,
    checked?: false
  }

  subject { WoopleTheme::SubmittedAnswerPresenter.new(struct(obj)) }

  describe "#correct_badge" do
    it "renders correctly when answer is correct" do
      subject.stub(:correct?) { true }

      html = Capybara::Node::Simple.new(subject.correct_badge)
      html.should have_content(I18n.t('woople_theme.assessment.correct'))
      html.should have_css(".badge.badge-success")
    end

    it "renders nothing when answer is not correct" do
      subject.correct_badge.should be_nil
    end
  end

  describe "#incorrect_badge" do
    it "renders correctly when answer is incorrect" do
      subject.stub(:incorrect?) { true }

      html = Capybara::Node::Simple.new(subject.incorrect_badge)
      html.should have_content(I18n.t('woople_theme.assessment.incorrect'))
      html.should have_css(".badge.badge-important")
    end

    it "renders nothing when presenter is not incorrect" do
      subject.incorrect_badge.should be_nil
    end
  end

  describe "#radio_disabled" do
    it "renders correctly" do
      subject.radio_disabled.should eq('disabled="disabled"')
    end
  end

  describe "#radio_checked" do
    it "renders correctly" do
      subject.stub(:checked?) { true }

      subject.radio_checked.should eq('checked="checked"')
    end
  end
end

Version data entries

36 entries across 36 versions & 1 rubygems

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