<commit_before>require 'rails_helper'

RSpec.describe Nomis::OffenderRestrictions do
  subject { described_class.new(args) }

  describe '#restrictions' do
    let(:unparsed_restriction) do
      {
        'type' => { 'code' => 'BAN', 'desc' => 'Banned' },
        'effective_date' => '11-07-2017',
        'expiry_date' => '20-07-2017'
      }
    end

    let(:args) do
      { 'restrictions' => [unparsed_restriction] }
    end

    let(:expected_restriction) { Nomis::Restriction.new(unparsed_restriction) }

    it 'parses the attributes to an array of restrictions' do
      expect(subject.restrictions).to have(1).item
      restriction = subject.restrictions.first

      expect(restriction.type).to eq(expected_restriction.type)
      expect(restriction.effective_date).to eq(expected_restriction.effective_date)
      expect(restriction.expiry_date).to eq(expected_restriction.expiry_date)
    end
  end

  describe '#api_call_successful?' do
    let(:args) { {} }

    before do
      subject.api_call_successful = false
    end<commit_msg>Fix restriction spec<commit_after>require 'rails_helper'

RSpec.describe Nomis::OffenderRestrictions do
  subject { described_class.new(args) }

  describe '#restrictions' do
    let(:unparsed_restriction) do
      {
        'type' => { 'code' => 'BAN', 'desc' => 'Banned' },
        'effective_date' => '11-07-2017',
        'expiry_date' => '20-07-2017'
      }
    end

    let(:args) do
      { 'restrictions' => [unparsed_restriction] }
    end

    let(:expected_restriction) { Nomis::Restriction.new(unparsed_restriction) }

    it 'parses the attributes to an array of restrictions' do
      expect(subject.restrictions).to have(1).item
      restriction = subject.restrictions.first

      expect(restriction.type.code).to      eq(expected_restriction.type.code)
      expect(restriction.type.desc).to      eq(expected_restriction.type.desc)
      expect(restriction.effective_date).to eq(expected_restriction.effective_date)
      expect(restriction.expiry_date).to    eq(expected_restriction.expiry_date)
    end
  end

  describe '#api_call_successful?' do
    let(:args) { {} }

    before do
      subject.api_call_successful = false
    end
{'fraction_non_alphanumeric': 0.11831368993653672, 'fraction_numerical': 0.015412511332728921, 'mean_word_length': 3.3876739562624256, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 15, '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': '6607394', 'n_tokens_mistral': 763, 'n_tokens_neox': 706, 'n_words': 123}