Sha256: bdf38fbca1fce8d1e29cab4be94b38a51ef910f5d92f020f75b2aca00b451cb1

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Caramelize::CamelCaseToWikiLinks do
  describe '#run' do
    subject(:run) { filter.run }

    let(:filter) { described_class.new(body) }

    context 'with camel case text' do
      let(:body) { 'Hier ein CamelCaseExample, bitte [[DankeDanke]]' }

      it 'does wiki link' do
        expect(run).to eq 'Hier ein [[CamelCaseExample]], bitte [[DankeDanke]]'
      end
    end

    context 'with camel case text downcased' do
      let(:body) { 'Hier ein camelCaseExample, bitte [[DankeDanke]]' }

      it 'does not to wiki link' do
        expect(run).to eq 'Hier ein camelCaseExample, bitte [[DankeDanke]]'
      end
    end

    context 'with camel case text at document end' do
      let(:body) { 'Hier ein CamelCaseExample' }

      # NOTE: this is sortof expected behavior - a wiki page should end on a newline in which case this does not happen
      it 'cuts last character' do
        expect(run).to eq 'Hier ein [[CamelCaseExampl]]e'
      end
    end

    context 'with camel case text at document end with newline' do
      let(:body) { "Hier ein CamelCaseExample\n" }

      it 'does wiki link' do
        expect(run).to eq "Hier ein [[CamelCaseExample]]\n"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caramelize-1.2.0 spec/lib/caramelize/filters/camel_case_to_wiki_links_spec.rb