Sha256: b8ea063aea12173e491af1e4db5b2035f7cf0f3429dfafe58ddc624dacef5d13

Contents?: true

Size: 1.5 KB

Versions: 3

Compression:

Stored size: 1.5 KB

Contents

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

module Troo
  describe CreateCard do
    let(:described_class) { CreateCard }
    let(:list_id)  { "526d8e130a14a9d846001d97" }
    let(:card_name) { "My New Card" }
    let(:description) { "A description to get us started." }

    before do
      @list = Fabricate(:list)
      @card = Fabricate(:card, name: card_name, desc: description)

      CardPersistence.stubs(:for).returns(@card)
    end

    after { database_cleanup }

    describe ".initialize" do
      subject { described_class.new(@list, card_name, description) }

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

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

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

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

      subject { described_class.for(@list, card_name, description) }

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

      context "when the card was not created" do
        before { Trello::Card.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.7 test/lib/troo/actions/create_card_test.rb
troo-0.0.6 test/lib/troo/actions/create_card_test.rb
troo-0.0.5 test/lib/troo/actions/create_card_test.rb