Sha256: 18cceef12be174bdfa61b226fe5d57e9bf336d58c4a3cedf945dfeb96639f1fa

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

# rubocop:todo RSpec/SpecFilePathFormat
describe Caramelize::CamelCaseToWikiLinks do # rubocop:todo RSpec/FilePath, RSpec/SpecFilePathFormat
  # rubocop:enable RSpec/SpecFilePathFormat
  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

3 entries across 3 versions & 1 rubygems

Version Path
caramelize-1.3.1 spec/lib/caramelize/filters/camel_case_to_wiki_links_spec.rb
caramelize-1.3.0 spec/lib/caramelize/filters/camel_case_to_wiki_links_spec.rb
caramelize-1.2.1 spec/lib/caramelize/filters/camel_case_to_wiki_links_spec.rb