Sha256: 3161b3a44fb2f1409856c31876a56e7ffd5d809be066bfed0d82cf250693592d

Contents?: true

Size: 901 Bytes

Versions: 22

Compression:

Stored size: 901 Bytes

Contents

describe Nanoc::Helpers::HTMLEscape, helper: true do
  describe '#html_escape' do
    subject { helper.html_escape(string) }

    context 'given strings to escape' do
      let(:string) { '< > & "' }
      it { is_expected.to eql('&lt; &gt; &amp; &quot;') }
    end

    context 'given a block' do
      let!(:_erbout) { 'moo' }

      it 'adds escaped content to _erbout' do
        helper.html_escape { _erbout << '<h1>Stuff!</h1>' }
        expect(_erbout).to eql('moo&lt;h1&gt;Stuff!&lt;/h1&gt;')
      end
    end

    context 'given no argument nor block' do
      subject { helper.html_escape }

      it 'raises' do
        expect { subject }.to raise_error(RuntimeError)
      end
    end

    context 'given argument that is not a string' do
      let(:string) { 1 }

      it 'raises an ArgumentError' do
        expect { subject }.to raise_error(ArgumentError)
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
nanoc-4.7.9 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.7.8 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.7.7 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.7.6 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.7.5 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.7.4 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.7.3 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.7.2 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.7.1 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.7.0 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.6.4 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.6.3 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.6.2 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.6.1 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.6.0 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.5.4 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.5.3 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.5.2 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.5.1 spec/nanoc/helpers/html_escape_spec.rb
nanoc-4.5.0 spec/nanoc/helpers/html_escape_spec.rb