<commit_before># == Schema Information
#
# Table name: rounds
#
#  id         :integer          not null, primary key
#  name       :string(255)
#  indoor     :boolean
#  metric     :boolean
#  created_at :datetime         not null
#  updated_at :datetime         not null
#

require 'rails_helper'

RSpec.describe Round do
  let(:round) { described_class.new }
  let(:round_distances) do
    [
      instance_double(RoundDistance, distance: 30, total_arrows: 12, as_json: {}),
      instance_double(RoundDistance, distance: 50, total_arrows: 36, as_json: {}),
      instance_double(RoundDistance, distance: 70, total_arrows: 18, as_json: {})
    ]
  end

  before(:each) do
    allow(round).to receive(:round_distances).and_return(round_distances)
  end

  describe '#distances' do
    it 'returns the distances as an array of integers' do
      expect(round.distances).to contain_exactly(30, 50, 70)
    end
  end

  describe '#total_arrows' do
    it 'returns the total number of arrows across all rounds' do
      expect(round.total_arrows).to eql(66)
    end
  end

  describe '#max_score' do
    it 'returns the highest possible score for the round' do
      expect(round.max_score).to eql(660)
    end
  end

  describe '#as_json' do
    subject { round.as_json }
    it { is_expected.to include(round_distances: round_distances.as_json) }
    it { is_expected.to include(total_arrows: 66) }
    it { is_expected.to include(max_score: 660) }
  end
end<commit_msg>Use real RoundDistance objects in Round spec<commit_after># == Schema Information
#
# Table name: rounds
#
#  id         :integer          not null, primary key
#  name       :string(255)
#  indoor     :boolean
#  metric     :boolean
#  created_at :datetime         not null
#  updated_at :datetime         not null
#

require 'rails_helper'

RSpec.describe Round do
  let(:round) { described_class.new(round_distances: round_distances) }
  let(:round_distances) do
    [
      RoundDistance.new(distance: 30, arrows_per_end: 3, ends: 1),
      RoundDistance.new(distance: 50, arrows_per_end: 6, ends: 2),
      RoundDistance.new(distance: 70, arrows_per_end: 6, ends: 3)
    ]
  end

  describe '#distances' do
    it 'returns the distances as an array of integers' do
      expect(round.distances).to contain_exactly(30, 50, 70)
    end
  end

  describe '#total_arrows' do
    it 'returns the total number of arrows across all rounds' do
      expect(round.total_arrows).to eql(33)
    end
  end

  describe '#max_score' do
    context 'with a metric round' do
      it 'uses 10 zone scoring' do
        expect(round.max_score).to eql(330)
      end
    end

    context 'with an imperial round' do
      it 'uses 5 zone scoring' do
        expect(round.max_score).to eql(330)
      end
    end
  end

  describe '#as_json' do
    subject { round.as_json }
    it { is_expected.to include(round_distances: round_distances.as_json) }
    it { is_expected.to include(total_arrows: 33) }
    it { is_expected.to include(max_score: 330) }
  end
end
{'fraction_non_alphanumeric': 0.09446470003314551, 'fraction_numerical': 0.022538945972820683, 'mean_word_length': 3.03475935828877, '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': '5077858', 'n_tokens_mistral': 1049, 'n_tokens_neox': 962, 'n_words': 284}