Sha256: 138b33cef0f5925141045ab563f2b22a8a775166cb84d7b344d563adf4fb03c4

Contents?: true

Size: 1.54 KB

Versions: 3

Compression:

Stored size: 1.54 KB

Contents

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

module Troo
  describe CommentDecorator do
    let(:described_class) { CommentDecorator }
    let(:default) { true }

    before do
      @comment = Fabricate(:comment)
      @member  = Fabricate(:member)
    end

    after { database_cleanup }

    describe "#initialize" do
      subject { described_class.new(@comment) }

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

    describe "#as_view" do
      subject { described_class.new(@comment).as_view }

      it "returns the rendered comment" do
        subject.must_match /gavinlaking1/
        subject.must_match /My Test Comment/
        subject.must_match /Tue, Dec 17 at 22:01/
      end
    end

    describe "#member_username" do
      subject { described_class.new(@comment).member_username }

      it "returns the comment member username" do
        subject.must_equal(@comment.member.username + ":")
      end
    end

    describe "#text" do
      subject { described_class.new(@comment).text }

      it "returns the comment text" do
        subject.must_equal(@comment.text)
      end
    end

    describe "#date" do
      subject { described_class.new(@comment).date }

      it "returns the comment date" do
        subject.must_equal("Tue, Dec 17 at 22:01")
      end
    end

    describe "#id" do
      subject { described_class.new(@comment).id }

      it "returns the comment id" do
        subject.must_equal("(#{@comment.id})")
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
troo-0.0.4 test/lib/troo/display/comment_decorator_test.rb
troo-0.0.3 test/lib/troo/display/comment_decorator_test.rb
troo-0.0.2 test/lib/troo/display/comment_decorator_test.rb