<commit_before>require "../spec_helper"

module Franklin
  class ConsoleReportLet
    property subject : ConsoleReport
    property result : String
    property availability_description : AvailabilityDescription
    property search_terms : String
    property item : Item

    def initialize(@search_terms = "crime and punishment")
      @item = Item.random_fixture
      availability = Availability.random_fixture
      collated_results = {item => [availability]}
      io = IO::Memory.new

      @subject = ConsoleReport.new(search_terms, collated_results)
      @result = subject.to_s(io).to_s
      @availability_description = AvailabilityDescription.new(availability, item)
    end
  end

  describe ConsoleReport do
    describe ".to_s" do
      it "includes search_term" do
        let = ConsoleReportLet.new
        let.result.should match(/#{let.search_terms}/)
      end

      it "includes item information" do
        let = ConsoleReportLet.new
        result = let.result
        item = let.item

        result.should match(/^#{item.title}/m)
        result.should match(/^By #{item.author}/m)
        result.should match(/^Format: #{item.format}/m)
      end

      it "includes availability information" do
        let = ConsoleReportLet.new
        result = let.result
        availability_description = let.availability_description

        result.should match(/^Availability:/m)
        result.should match(/^  #{availability_description.to_s}/m)
        result.should match(/^    #{availability_description.url}/m)
      end
    end
  end
end<commit_msg>Revert "Expriment with a Let class to hold setup"<commit_after>require "../spec_helper"

module Franklin
  describe ConsoleReport do
    subject { ConsoleReport.new(search_terms, collated_results) }
    let(:search_terms) { "crime and punishment" }
    let(:collated_results) { {item => [availability]} }
    let(:result) { subject.to_s(io).to_s }
    let(:io) { IO::Memory.new }
    let(:item) { Item.random_fixture }
    let(:availability) { Availability.random_fixture }
    let(:availability_description) { AvailabilityDescription.new(availability, item) }

    describe ".to_s" do
      it "includes search_term" do
        expect(result).to match(/#{search_terms}/)
      end

      it "includes item information" do
        expect(result).to match(/^#{item.title}/m)
        expect(result).to match(/^By #{item.author}/m)
        expect(result).to match(/^Format: #{item.format}/m)
      end

      it "includes availability information" do
        expect(result).to match(/^Availability:/m)
        expect(result).to match(/^  #{availability_description.to_s}/m)
        expect(result).to match(/^    #{availability_description.url}/m)
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.1111111111111111, 'fraction_numerical': 0.0, 'mean_word_length': 2.979710144927536, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '5508912', 'n_tokens_mistral': 795, 'n_tokens_neox': 767, 'n_words': 179}