<commit_before>require "rails_helper"

RSpec.describe DefenceRequestsHelper, type: :helper do

  describe "formatting not given field" do
    context "when address is not given" do
      it "returns 'Not given'" do
        request = create(:defence_request)
        expect(helper.not_given_formatter(request, :detainee_address)).to eq("Not Given")
      end
    end

    context "when address present" do
      it "returns address as single line" do
        request = create(:defence_request, :with_detainee_address)
        expected = "House on the Hill, Letsby Avenue, Right up my street, London, Greater London, XX1 1XX"
        expect(helper.not_given_formatter(request, :detainee_address)).to eq(expected)
      end
    end
  end

  describe "formatting not given date" do
    context "when date is not given" do
      it "returns 'Not given'" do
        request = create(:defence_request)
        request.update(date_of_birth: nil)
        expect(helper.date_not_given_formatter(request, :date_of_birth)).to eq("Not Given")
      end
    end

    context "when address present" do
      it "returns date as correctly formatted" do
        request = create(:defence_request)
        expect(helper.date_not_given_formatter(request, :date_of_birth)).to eq("20 May 1994")
      end
    end
  end

  describe "interview_at" do
    context "when interview time blank" do
      it "renders correctly" do
        request = create(:defence_request)
        expected = %[<dl class="time-at"><dt>Interview time</dt> <dd>pending</dd></dl>]
        expect(helper.interview_at(request)).to eq(expected)
      end
    end
    context "when interview time set" do
      context "interview time is today" do
        it "renders just the time" do
          time = Time.zone.now
          request = create(:defence_request, interview_start_time: time)
          expected = %[<dl class="time-at"><dt>Interview at</dt> <dd>#{time.to_s(:time)}</dd></dl>]
          expect(helper.interview_at(request)).to eq(expected)
        end
      end

      context "interview time is not today" do
        it "renders the date and the time" do
          time = Time.zone.now + 1.day
          request = create(:defence_request, interview_start_time: time)
          expected = %[<dl class="time-at"><dt>Interview at</dt> <dd>#{time.to_s(:short)}</dd></dl>]
          expect(helper.interview_at(request)).to eq(expected)<commit_msg>Fix failing test<commit_after>require "rails_helper"

RSpec.describe DefenceRequestsHelper, type: :helper do

  describe "formatting not given field" do
    context "when address is not given" do
      it "returns 'Not given'" do
        request = create(:defence_request)
        expect(helper.not_given_formatter(request, :detainee_address)).to eq("Not Given")
      end
    end

    context "when address present" do
      it "returns address as single line" do
        request = create(:defence_request, :with_detainee_address)
        expected = "House on the Hill, Letsby Avenue, Right up my street, London, Greater London, XX1 1XX"
        expect(helper.not_given_formatter(request, :detainee_address)).to eq(expected)
      end
    end
  end

  describe "formatting not given date" do
    context "when date is not given" do
      it "returns 'Not given'" do
        request = create(:defence_request)
        request.update(date_of_birth: nil)
        expect(helper.date_not_given_formatter(request, :date_of_birth)).to eq("Not Given")
      end
    end

    context "when address present" do
      it "returns date as correctly formatted" do
        request = create(:defence_request, date_of_birth: Date.parse("1994-05-20"))
        expect(helper.date_not_given_formatter(request, :date_of_birth)).to eq("20 May 1994")
      end
    end
  end

  describe "interview_at" do
    context "when interview time blank" do
      it "renders correctly" do
        request = create(:defence_request)
        expected = %[<dl class="time-at"><dt>Interview time</dt> <dd>pending</dd></dl>]
        expect(helper.interview_at(request)).to eq(expected)
      end
    end
    context "when interview time set" do
      context "interview time is today" do
        it "renders just the time" do
          time = Time.zone.now
          request = create(:defence_request, interview_start_time: time)
          expected = %[<dl class="time-at"><dt>Interview at</dt> <dd>#{time.to_s(:time)}</dd></dl>]
          expect(helper.interview_at(request)).to eq(expected)
        end
      end

      context "interview time is not today" do
        it "renders the date and the time" do
          time = Time.zone.now + 1.day
          request = create(:defence_request, interview_start_time: time)
          expected = %[<dl class="time-at"><dt>Interview at</dt> <dd>#{time.to_s(:short)}</dd></dl>]
          expect(helper.interview_at(request)).to eq(expected)
{'fraction_non_alphanumeric': 0.1073341573959621, 'fraction_numerical': 0.005356407086938607, 'mean_word_length': 3.012396694214876, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 39, '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': '7579717', 'n_tokens_mistral': 1493, 'n_tokens_neox': 1431, 'n_words': 415}