Sha256: 17df17e10abece0293e954934515c69425a47ac2484e16cff7f12da8dbcce3b7

Contents?: true

Size: 1.27 KB

Versions: 3

Compression:

Stored size: 1.27 KB

Contents

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

module Troo
  describe CreateList do
    let(:described_class) { CreateList }
    let(:board_id)  { "526d8e130a14a9d846001d96" }
    let(:list_name) { "My New List" }

    before do
      @board = Fabricate(:board)
      @list = Fabricate(:list, name: list_name)

      Troo::ListPersistence.stubs(:for).returns(@list)
    end

    after { database_cleanup }

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

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

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

    describe ".for" do
      before { VCR.insert_cassette(:create_list, decode_compressed_response: true) }
      after  { VCR.eject_cassette }

      subject { described_class.for(@board, list_name) }

      context "when the list was created" do
        it "returns the new list" do
          subject.must_equal(@list)
        end
      end

      context "when the list was not created" do
        before { Trello::List.stubs(:create).raises(Trello::Error) }

        it { subject.must_equal false }
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
troo-0.0.4 test/lib/troo/actions/create_list_test.rb
troo-0.0.3 test/lib/troo/actions/create_list_test.rb
troo-0.0.2 test/lib/troo/actions/create_list_test.rb