Sha256: be963dabe73f24bf537f9dbceb9414c486b6e5643ef7fff97466cc7c7bb49455

Contents?: true

Size: 1.59 KB

Versions: 29

Compression:

Stored size: 1.59 KB

Contents

require 'spec_helper'
require 'copy_tuner_client/copyray'

describe CopyTunerClient::Copyray do
  describe '.augment_template' do
    subject { CopyTunerClient::Copyray.augment_template(source, key) }

    let(:key) { 'en.test.key' }

    shared_examples 'Not escaped' do
      it { is_expected.to be_html_safe }
      it { is_expected.to eq "<!--COPYRAY #{key}--><b>Hello</b>" }
    end

    context 'html_escape option is false' do
      before do
        CopyTunerClient.configure do |configuration|
          configuration.html_escape = false
          configuration.client = FakeClient.new
        end
      end

      context 'string not marked as html safe' do
        let(:source) { FakeHtmlSafeString.new('<b>Hello</b>') }

        it_behaves_like 'Not escaped'
      end

      context 'string marked as html safe' do
        let(:source) { FakeHtmlSafeString.new('<b>Hello</b>').html_safe }

        it_behaves_like 'Not escaped'
      end
    end

    context 'html_escape option is true' do
      before do
        CopyTunerClient.configure do |configuration|
          configuration.html_escape = true
          configuration.client = FakeClient.new
        end
      end

      context 'string not marked as html safe' do
        let(:source) { FakeHtmlSafeString.new('<b>Hello</b>') }

        it { is_expected.to be_html_safe }
        it { is_expected.to eq "<!--COPYRAY #{key}-->&lt;b&gt;Hello&lt;/b&gt;" }
      end

      context 'string marked as html safe' do
        let(:source) { FakeHtmlSafeString.new('<b>Hello</b>').html_safe }

        it_behaves_like 'Not escaped'
      end
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
copy_tuner_client-0.19.0 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.18.0 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.17.1 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.16.3 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.16.2 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.16.1 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.16.0 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.15.1 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.15.0 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.14.2 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.14.1 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.14.0 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.13.6 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.13.5 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.13.3 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.13.2 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.13.1 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.13.0 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.12.0 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.11.0 spec/copy_tuner_client/copyray_spec.rb