<commit_before>require 'rails_helper'

RSpec.describe TimeRoundingService do

  describe "#closest_fifteen" do

    context "given an event" do

      it "rounds times to the closest quarter hour" do
        @event = build_stubbed(:event)
        @event.start_time = @event.start_time.change(:hour => 9, :min => 1,
                                                     :sec => 35, :usec => 231)
        @event.end_time = @event.end_time.change(:hour => 9, :min => 14,
                                                     :sec => 35, :usec => 231)

        @rounded_event = TimeRoundingService.new(@event).closest_fifteen

        expect(@rounded_event.start_time.strftime("%H:%M:%S:%L")).to eq("09:15:00:000")
        expect(@rounded_event.end_time.strftime("%H:%M:%S:%L")).to eq("09:00:00:000")
      end
<commit_msg>refactors test to use let for memoized event<commit_after>require 'rails_helper'

RSpec.describe TimeRoundingService do

  describe "#closest_fifteen" do

  let(:event){ build_stubbed(:event) }

    context "given an event" do

      it "rounds times in the first quarter of an hour correctly" do
        event.start_time = event.start_time.change(:hour => 9, :min => 1,
                                                     :sec => 35, :usec => 231)
        event.end_time = event.end_time.change(:hour => 9, :min => 14,
                                                     :sec => 35, :usec => 231)

        @rounded_event = TimeRoundingService.new(event).closest_fifteen

        expect(@rounded_event.start_time.strftime("%H:%M:%S:%L")).to eq("09:15:00:000")
        expect(@rounded_event.end_time.strftime("%H:%M:%S:%L")).to eq("09:00:00:000")
      end

{'fraction_non_alphanumeric': 0.1408955223880597, 'fraction_numerical': 0.03940298507462687, 'mean_word_length': 2.2607003891050583, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4219001', 'n_tokens_mistral': 577, 'n_tokens_neox': 498, 'n_words': 108}