<commit_before># frozen_string_literal: true
require 'rails_helper'

describe LetterOpenerWeb::LettersController do
  routes { LetterOpenerWeb::Engine.routes }

  after(:each) { LetterOpenerWeb.reset! }

  describe 'GET index' do
    before do
      allow(LetterOpenerWeb::Letter).to receive(:search)
      get :index
    end

    it 'searches for all letters' do
      expect(LetterOpenerWeb::Letter).to have_received(:search)
    end

    it 'returns an HTML 200 response' do
      expect(response.status).to eq(200)
      expect(response.content_type).to eq('text/html')
    end
  end

  describe 'GET show' do
    let(:id)         { 'an-id' }
    let(:rich_text)  { 'rich text href="plain.html"' }
    let(:plain_text) { 'plain text href="rich.html"' }
    let(:letter)     { double(:letter, rich_text: rich_text, plain_text: plain_text, id: id) }

    shared_examples 'found letter examples' do |letter_style|
      before(:each) do
        expect(LetterOpenerWeb::Letter).to receive(:find).with(id).and_return(letter)
        expect(letter).to receive(:exists?).and_return(true)
        get :show, id: id, style: letter_style
      end

      it 'renders an plain 200 response' do
        expect(response.status).to eq(200)
        expect(response.content_type).to eq('text/plain')
      end
    end
<commit_msg>Update to test for html response<commit_after># frozen_string_literal: true
require 'rails_helper'

describe LetterOpenerWeb::LettersController do
  routes { LetterOpenerWeb::Engine.routes }

  after(:each) { LetterOpenerWeb.reset! }

  describe 'GET index' do
    before do
      allow(LetterOpenerWeb::Letter).to receive(:search)
      get :index
    end

    it 'searches for all letters' do
      expect(LetterOpenerWeb::Letter).to have_received(:search)
    end

    it 'returns an HTML 200 response' do
      expect(response.status).to eq(200)
      expect(response.content_type).to eq('text/html')
    end
  end

  describe 'GET show' do
    let(:id)         { 'an-id' }
    let(:rich_text)  { 'rich text href="plain.html"' }
    let(:plain_text) { 'plain text href="rich.html"' }
    let(:letter)     { double(:letter, rich_text: rich_text, plain_text: plain_text, id: id) }

    shared_examples 'found letter examples' do |letter_style|
      before(:each) do
        expect(LetterOpenerWeb::Letter).to receive(:find).with(id).and_return(letter)
        expect(letter).to receive(:exists?).and_return(true)
        get :show, id: id, style: letter_style
      end

      it 'renders an HTML 200 response' do
        expect(response.status).to eq(200)
        expect(response.content_type).to eq('text/html')
      end
    end

{'fraction_non_alphanumeric': 0.11911044101017716, 'fraction_numerical': 0.009046362608367886, 'mean_word_length': 3.294498381877023, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3631713', 'n_tokens_mistral': 878, 'n_tokens_neox': 821, 'n_words': 203}