Sha256: aaade93ee54f67e33e36314cf575f610ceccf626764d23e7634cf6bc3e30c1d7

Contents?: true

Size: 1.93 KB

Versions: 84

Compression:

Stored size: 1.93 KB

Contents

require_relative '../spec_helper'
require 'flydata-core/fluent/config_helper'

module FlydataCore::Fluent
  describe ConfigHelper do
    describe '.escape_conf' do

      let(:input) { "" }
      let(:output) { "" }
      subject { ConfigHelper.escape_conf(input) }

      shared_examples 'escape conf expectedly' do
        it { is_expected.to eq(output) }
      end

      context 'when input contains escape characters' do
        let(:input) { %Q|aa\nbb\r\ncc\tdd"ee\\ff| }
        let(:output) { %Q|aa\\nbb\\r\\ncc\\tdd\\"ee\\\\ff| }

        it_behaves_like 'escape conf expectedly'
      end

      context 'when input does not contain escape characters' do
        let(:input) { %Q|aabbccddeeff| }
        let(:output) { %Q|aabbccddeeff| }

        it_behaves_like 'escape conf expectedly'
      end

      context 'when input is nil' do
        let(:input) { nil }
        it { is_expected.to eq("") }
      end

      context 'when input is empty' do
        let(:input) { "" }
        it { is_expected.to eq("") }
      end
    end

    describe '.unescape_conf' do

      let(:input) { "" }
      let(:output) { "" }
      subject { ConfigHelper.unescape_conf(input) }

      shared_examples 'unescape conf expectedly' do
        it { is_expected.to eq(output) }
      end

      context 'when input contains escaped characters' do
        let(:input) { %Q|aa\\nbb\\r\\ncc\\tdd\\"ee\\\\ff| }
        let(:output) { %Q|aa\nbb\r\ncc\tdd"ee\\ff| }

        it_behaves_like 'unescape conf expectedly'
      end

      context 'when input does not contain escape characters' do
        let(:input) { %Q|aabbccddeeff| }
        let(:output) { %Q|aabbccddeeff| }

        it_behaves_like 'unescape conf expectedly'
      end

      context 'when input is nil' do
        let(:input) { nil }
        it { is_expected.to eq("") }
      end

      context 'when input is empty' do
        let(:input) { "" }
        it { is_expected.to eq("") }
      end
    end
  end
end


Version data entries

84 entries across 84 versions & 1 rubygems

Version Path
flydata-0.8.10.2 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.8.10.1 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.8.9.11 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.8.10 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.8.9 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.8.8 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.8.7 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.8.6 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.8.5 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.8.4 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.8.3 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.8.2 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.8.1 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.8.0 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.7.19 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.7.18 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.7.17 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.7.16 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.7.15 flydata-core/spec/fluent/config_helper_spec.rb
flydata-0.7.14 flydata-core/spec/fluent/config_helper_spec.rb