Sha256: 5bb2dfc4ea1a90c5f67152dce7ee0354454d7f734fcd6e375583c8e97e77fb12

Contents?: true

Size: 1.07 KB

Versions: 6

Compression:

Stored size: 1.07 KB

Contents

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

module Troo
  describe CommentRetrieval do
    let(:described_class) { CommentRetrieval }

    before { @comment = Fabricate(:comment) }
    after  { database_cleanup }

    describe ".all" do
      subject { described_class.all }

      it "retrieves all locally stored comments" do
        subject.size.must_equal 1
      end
    end

    describe ".retrieve" do
      subject { described_class.retrieve(id) }

      context "local retrieval by database ID" do
        let(:id) { @comment.id }

        it "returns the correct comment" do
          subject.text.must_equal("My Test Comment")
        end
      end

      context "local retrieval by external ID" do
        let(:id) { "51f9277b2822b8654f0023af" }

        it "returns the correct comment" do
          subject.text.must_equal("My Test Comment")
        end
      end

      context "when the ID cannot be found" do
        let(:id) { "not_found_id" }

        before { External::Comment.stubs(:fetch).returns([]) }

        it { subject.must_equal(nil) }
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
troo-0.0.7 test/lib/troo/models/comment_retrieval_test.rb
troo-0.0.6 test/lib/troo/models/comment_retrieval_test.rb
troo-0.0.5 test/lib/troo/models/comment_retrieval_test.rb
troo-0.0.4 test/lib/troo/models/comment_retrieval_test.rb
troo-0.0.3 test/lib/troo/models/comment_retrieval_test.rb
troo-0.0.2 test/lib/troo/models/comment_retrieval_test.rb