Sha256: dfacc718503f776dcf7d8adaf3a3eecdc6650a57bcc4fbda865626e2497ad095

Contents?: true

Size: 1.49 KB

Versions: 4

Compression:

Stored size: 1.49 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
        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
        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

4 entries across 4 versions & 1 rubygems

Version Path
copy_tuner_client-0.5.1 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.5.0 spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.5.0.pre spec/copy_tuner_client/copyray_spec.rb
copy_tuner_client-0.4.12 spec/copy_tuner_client/copyray_spec.rb