Sha256: 37f89f21712306aa4f46c575a1c0caed21ed81522f7a8bec226d454e37679db4

Contents?: true

Size: 1.97 KB

Versions: 3

Compression:

Stored size: 1.97 KB

Contents

require_relative "../../../test_helper"

module Troo
  describe BoardPresenter do
    let(:described_class) { BoardPresenter }
    let(:options) { { } }

    before do
      @board = Fabricate(:board)
      @list  = Fabricate(:list)
      @card  = Fabricate(:card)
    end

    after { database_cleanup }

    describe "#initialize" do
      subject { described_class.new(@board, options) }

      it "assigns the board to an instance variable" do
        subject.instance_variable_get("@board").must_equal(@board)
      end

      it "assigns the options to an instance variable" do
        subject.instance_variable_get("@options").must_equal(options)
      end
    end

    describe "#render_all" do
      subject { capture_io { described_class.new(@board, options).render_all }.join }

      context "when the board has lists" do
        it "renders the view" do
          subject.must_match /My Test Board/
          subject.must_match /My Test List/
        end
      end

      context "when the board has no lists" do
        before { @list.delete }

        it "returns a polite message" do
          subject.must_match /No lists were found./
        end
      end
    end

    describe "#show" do
      subject { capture_io { described_class.show(@board, options) }.join }

      context "when the board has lists" do
        context "and the list has cards" do
          it "renders the view" do
            subject.must_match /My Test Board/
            subject.must_match /My Test List/
            subject.must_match /My Test Card/
          end
        end

        context "and the list has no cards" do
          before { @card.delete }

          it "returns a polite message" do
            subject.must_match /No cards were found./
          end
        end
      end

      context "when the board has no lists" do
        before { @board.stubs(:lists).returns([]) }

        it "returns a polite message" do
          subject.must_match /No lists were found./
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
troo-0.0.7 test/lib/troo/display/board_presenter_test.rb
troo-0.0.6 test/lib/troo/display/board_presenter_test.rb
troo-0.0.5 test/lib/troo/display/board_presenter_test.rb