Sha256: 99d3b9274e992701a3652cf7400a283339380d6a6082da40f9a501f1a0e3dc40

Contents?: true

Size: 1.98 KB

Versions: 4

Compression:

Stored size: 1.98 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Caramelize::Page do
  subject(:page) do
    described_class.new(title:,
                        message:,
                        time: Time.parse('2015-02-12'),
                        body: 'Dinosaurs are awesome and have feathers!',
                        author:)
  end

  let(:message) { 'Dinosaurs really had feathers, do not forget!' }
  let(:author) { { name: 'Jeff Goldblum', email: 'jeff.g@example.com' } }
  let(:title) { 'Feathered Dinosaurs' }

  describe '#author' do
    context 'without author' do
      let(:author) { nil }

      it 'fills with Caramelize user name' do
        expect(page.author.fetch(:name)).to eql('Caramelize')
      end

      it 'fills with dummy email' do
        expect(page.author.fetch(:email)).to eql('mail@example.com')
      end
    end

    context 'with author' do
      it 'fills with author name' do
        expect(page.author.fetch(:name)).to eql(author[:name])
      end

      it 'fills with author email' do
        expect(page.author.fetch(:email)).to eql(author[:email])
      end
    end
  end

  describe '#path' do
    context "when title is 'Home'" do
      let(:title) { 'Home' }

      it { expect(page.path).to eq 'Home' }
    end

    context "when title is 'Feathered Dinosaurs'" do
      it { expect(page.path).to eq 'Feathered Dinosaurs' }
    end

    context "when title is 'Space/Feathered Dinosaurs'" do
      let(:title) { 'Space/Feathered Dinosaurs' }

      it { expect(page.path).to eq 'Space/feathered dinosaurs' }
    end
  end

  describe '#commit_message' do
    context 'with page having message' do
      it 'uses page.title' do
        expect(page.commit_message).to eq 'Dinosaurs really had feathers, do not forget!'
      end
    end

    context 'with page having no message' do
      let(:message) { '' }

      it 'creates message "Edit in page Feathered Dinosaurs"' do
        expect(page.commit_message).to eq 'Edit in page Feathered Dinosaurs'
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
caramelize-1.3.1 spec/lib/caramelize/page_spec.rb
caramelize-1.3.0 spec/lib/caramelize/page_spec.rb
caramelize-1.2.1 spec/lib/caramelize/page_spec.rb
caramelize-1.2.0 spec/lib/caramelize/page_spec.rb