Sha256: 7818756c07722646aea8eee1ac4f0976b84ee34139c09f8c5b22dd82ae92eef1

Contents?: true

Size: 896 Bytes

Versions: 11

Compression:

Stored size: 896 Bytes

Contents

require "spec_helper"

module Refinery
  describe HtmlTruncationHelper, :type => :helper do

    describe "#truncate" do
      it "returns nil if text is not present" do
        expect(helper.truncate("")).to be_nil
      end

      context "when preserve_html_tags option is present" do
        it "preserve html tags when truncating text" do
          expect(
            helper.truncate(
              "<p>Turducken frankfurter ham hock bacon</p>",
              preserve_html_tags: true
            )
          ).to eq("<p>Turducken frankfurter ham...</p>")
        end
      end

      context "when preserve_html_tags option is not present" do
        it "falls back to original truncate method" do
          expect(TruncateHtml::HtmlTruncator).not_to receive(:new)
          helper.truncate("<p>Turducken frankfurter ham hock bacon</p>").html_safe
        end
      end
    end

  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
refinerycms-core-4.0.3 spec/helpers/refinery/html_truncation_helper_spec.rb
refinerycms-core-4.0.2 spec/helpers/refinery/html_truncation_helper_spec.rb
refinerycms-core-4.0.1 spec/helpers/refinery/html_truncation_helper_spec.rb
refinerycms-core-3.0.6 spec/helpers/refinery/html_truncation_helper_spec.rb
refinerycms-core-4.0.0 spec/helpers/refinery/html_truncation_helper_spec.rb
refinerycms-core-3.0.5 spec/helpers/refinery/html_truncation_helper_spec.rb
refinerycms-core-3.0.4 spec/helpers/refinery/html_truncation_helper_spec.rb
refinerycms-core-3.0.3 spec/helpers/refinery/html_truncation_helper_spec.rb
refinerycms-core-3.0.2 spec/helpers/refinery/html_truncation_helper_spec.rb
refinerycms-core-3.0.1 spec/helpers/refinery/html_truncation_helper_spec.rb
refinerycms-core-3.0.0 spec/helpers/refinery/html_truncation_helper_spec.rb