Sha256: f8078a9ff5d0ba1bfe4601f7b08cfde7ca0eefa65b28b003c70022ef92da1aaf

Contents?: true

Size: 1.42 KB

Versions: 1

Compression:

Stored size: 1.42 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

describe Caramelize::RemoveTableTabLineEndings do
  subject(:run) { filter.run }

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

  describe '#run' do
    context 'table with tabs at unix line-endings' do
      let(:body) { "cell1\t|cell2\t|\t\t\n" }

      it 'removes tabs at end of line' do
        expect(run).to eq "cell1\t|cell2\t|\n"
      end
    end

    context 'with spaces on line ending' do
      let(:body) { "cell1\t|cell2\t|\t    \n" }

      it 'removes spaces at end of line' do
        expect(run).to eq "cell1\t|cell2\t|\n"
      end

      context 'replace in full file' do
        let(:body) do
          File.read(File.join(['spec', 'fixtures', 'markup', 'table-tab-line-endings-input.textile']))
        end

        it 'returns as expected' do
          output_text = File.read(File.join(['spec', 'fixtures', 'markup', 'table-tab-line-endings-output.textile']))
          expect(run).to eq output_text
        end
      end
    end

    context 'with table having tabs at windows line-endings' do
      let(:body) { "cell1\t|cell2\t|\t\t\r\n" }

      it 'removes tabs at end of line' do
        expect(run).to eq "cell1\t|cell2\t|\n"
      end
    end

    context 'with spaces and windows line-endings' do
      let(:body) { "cell1\t|cell2\t|\t    \r\n" }

      it 'removes spaces at end of line' do
        expect(run).to eq "cell1\t|cell2\t|\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/remove_table_tab_line_endings_spec.rb