<commit_before>require 'spec_helper'

describe ApplicationHelper, type: :helper do
  describe '#govspeak' do
    context 'string without HTML code' do
      let(:string) { '**hello**' }

      it 'renders string in Markdown as HTML' do
        expect(
          helper.govspeak(string).strip
        ).to eq '<p><strong>hello</strong></p>'
      end
    end

    context 'string contains Javascript code' do
      let(:string) { "<script type='text/javascript'>alert('hello');</script>" }

      it '<script> tags are filtered' do
        expect(
          helper.govspeak(string).strip
        ).to eq "alert('hello');"
      end
    end
  end
end<commit_msg>Adding specs for new functionality<commit_after>require 'spec_helper'

describe ApplicationHelper, type: :helper do
  describe '#govspeak' do
    context 'string without HTML code' do
      let(:string) { '**hello**' }

      it 'renders string in Markdown as HTML' do
        expect(
          helper.govspeak(string).strip
        ).to eq '<p><strong>hello</strong></p>'
      end
    end

    context 'string contains Javascript code' do
      let(:string) { "<script type='text/javascript'>alert('hello');</script>" }

      it '<script> tags are filtered' do
        expect(
          helper.govspeak(string).strip
        ).to eq "alert('hello');"
      end
    end

    context 'HashWithIndifferentAccess is passed as argument' do
      let(:hash) {
        {"content"=>"* 1\\. This chapter does not cover:"}.with_indifferent_access
      }

      it 'fetches :content from the hash' do
        expect(
          helper.govspeak(hash)
        ).to eq <<~FOO
        <ul>
          <li>1. This chapter does not cover:</li>
        </ul>
        FOO
      end
    end

    context 'HashWithIndifferentAccess is passed as argument with no applicable content' do
      let(:na_hash) {
        {"foo"=>"bar"}.with_indifferent_access
      }

      it 'returns an empty string' do
        expect(
          helper.govspeak(na_hash)
        ).to eq ''
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.11917606669936243, 'fraction_numerical': 0.000980872976949485, 'mean_word_length': 2.295638126009693, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1872121', 'n_tokens_mistral': 608, 'n_tokens_neox': 586, 'n_words': 180}