Sha256: 9720079a99456ad80ace67d15e59191513b61cf1982307e7b7b70c4c27562ef7

Contents?: true

Size: 1.21 KB

Versions: 83

Compression:

Stored size: 1.21 KB

Contents

require 'spec_helper'

describe Tenon::CommentDecorator do
  let (:cd) { Tenon::CommentDecorator.new(comment) }

  describe '#email' do
    let(:comment) { double(author_email: 'test@test.com') }
    it 'should get the author email from the object' do
      expect(cd.email).to eq('test@test.com')
    end
  end

  describe '#author_url' do
    ['http://', 'https://'].each do |protocol|
      context "when the author has started their URL with #{protocol}" do
        let(:comment) { double(author_url: "#{protocol}test.com") }

        it 'should use the author_url from the object' do
          expect(cd.author_url).to eq(comment.author_url)
        end
      end
    end

    context 'when the author has not included a protocol' do
      let(:comment) { double(author_url: 'test.com') }

      it "should prepend 'http://' to the url" do
        expect(cd.author_url).to eq("http://#{comment.author_url}")
      end
    end
  end

  describe '#error_message' do
    let(:errors) { double(full_messages: ['It sucks', "It's boring"]) }
    let(:comment) { double(errors: errors) }

    it 'should output the errors' do
      errors.full_messages.each do |error|
        expect(cd.error_message).to match(error)
      end
    end
  end
end

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
tenon-1.1.8 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.1.7 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.1.6 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.1.5 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.1.4 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.1.3 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.1.2 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.1.1 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.0.76 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.0.75 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.0.74 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.0.73 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.0.72 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.0.71 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.0.70 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.0.69 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.0.68 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.0.67 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.0.66 spec/decorators/tenon/comment_decorator_spec.rb
tenon-1.0.65 spec/decorators/tenon/comment_decorator_spec.rb