Sha256: e1b5c098cce167777785c41f8e967de95607c23ef9b4bdb568aff10b160cbad0

Contents?: true

Size: 1.33 KB

Versions: 2

Compression:

Stored size: 1.33 KB

Contents

require 'spec_helper'

describe Caramelize::SwapWikiLinks do
  describe '#run' do
    let(:filter) { described_class.new(body) }
    subject { filter.run }

    context 'wiki link with title' do
      let(:body) { '[[statistics|Driver & Team Statistics]]' }

      it 'swaps title and target' do
        is_expected.to eq '[[Driver & Team Statistics|statistics]]'
      end
    end

    context 'wiki title with spaces' do
      let(:body) { '[[Release 1 0]]' }

      it 'replaces space with dashes' do
        is_expected.to eq '[[Release 1 0|release_1_0]]'
      end
    end

    context 'wiki title with dashes' do
      let(:body) { '[[Release-1.0]]' }

      it 'removes dots' do
        is_expected.to eq '[[Release-1.0|release-10]]'
      end
    end

    context 'wiki link with spaces and without title' do
      let(:body) { '[[Intra wiki link]]' }

      it 'simples link to hyperlink' do
        is_expected.to eq '[[Intra wiki link|intra_wiki_link]]'
      end

      context 'replace in full file' do
        let(:body) { File.open(File.join(['spec', 'fixtures', 'markup', 'swap-links-input.textile']), 'r').read }

        it 'returns as expected' do
          output_text = File.open(File.join(['spec', 'fixtures', 'markup', 'swap-links-output.textile']), 'r').read
          is_expected.to eq output_text
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
caramelize-1.1.1 spec/lib/caramelize/filters/swap_wiki_links_spec.rb
caramelize-1.1.0 spec/lib/caramelize/filters/swap_wiki_links_spec.rb