<commit_before>require 'spec_helper'
require 'transition/import/site_yaml_file'

describe Transition::Import::SiteYamlFile do
  context 'A redirector YAML file' do
    subject(:redirector_yaml_file) do
      Transition::Import::SiteYamlFile.load('spec/fixtures/sites/someyaml/ago.yml')
    end

    its(:abbr)           { should eql 'ago' }
    its(:whitehall_slug) { should eql 'attorney-generals-office' }
    it 'is not managed by transition - it doesn\'t have transition-sites in path' do
      redirector_yaml_file.should_not be_managed_by_transition
    end

    describe '#import!' do
      let(:ago) { build :organisation, whitehall_slug: 'attorney-generals-office' }

      before do
        Organisation.stub(:find_by_whitehall_slug).and_return(ago)
        redirector_yaml_file.import!
      end

      subject(:site) { Site.find_by_abbr('ago') }

      its(:launch_date)           { should eql(Date.new(2012, 12, 13)) }
      its(:tna_timestamp)         { should be_a(Time) }
      its(:homepage)              { should eql('https://www.gov.uk/government/organisations/attorney-generals-office') }
      its(:managed_by_transition) { should eql(false) }
      its(:organisation)          { should eql(ago)}
      it 'should get hosts including aka hosts' do
        hosts = %w{
          www.attorneygeneral.gov.uk
          aka.attorneygeneral.gov.uk
          www.attorney-general.gov.uk
          aka.attorney-general.gov.uk
          www.ago.gov.uk
          aka.ago.gov.uk
          www.lslo.gov.uk
          aka.lslo.gov.uk
        }
        site.hosts.pluck(:hostname).should eql(hosts)
      end

      describe 'updates' do
        before do
          redirector_yaml_file.import!
          Transition::Import::SiteYamlFile.load('spec/fixtures/sites/updates/ago.yml').import!
        end

        its(:launch_date)           { should eql(Date.new(2014, 12, 13)) }
        its(:tna_timestamp)         { should be_a(Time) }
        its(:homepage)              { should eql('https://www.gov.uk/government/organisations/attorney-update-office') }
      end
    end
  end
<commit_msg>Make spec deterministic in the face of array order<commit_after>require 'spec_helper'
require 'transition/import/site_yaml_file'

describe Transition::Import::SiteYamlFile do
  context 'A redirector YAML file' do
    subject(:redirector_yaml_file) do
      Transition::Import::SiteYamlFile.load('spec/fixtures/sites/someyaml/ago.yml')
    end

    its(:abbr)           { should eql 'ago' }
    its(:whitehall_slug) { should eql 'attorney-generals-office' }
    it 'is not managed by transition - it doesn\'t have transition-sites in path' do
      redirector_yaml_file.should_not be_managed_by_transition
    end

    describe '#import!' do
      let(:ago) { build :organisation, whitehall_slug: 'attorney-generals-office' }

      before do
        Organisation.stub(:find_by_whitehall_slug).and_return(ago)
        redirector_yaml_file.import!
      end

      subject(:site) { Site.find_by_abbr('ago') }

      its(:launch_date)           { should eql(Date.new(2012, 12, 13)) }
      its(:tna_timestamp)         { should be_a(Time) }
      its(:homepage)              { should eql('https://www.gov.uk/government/organisations/attorney-generals-office') }
      its(:managed_by_transition) { should eql(false) }
      its(:organisation)          { should eql(ago)}
      it 'should get hosts including aka hosts' do
        hosts = %w{
          www.attorneygeneral.gov.uk
          aka.attorneygeneral.gov.uk
          www.attorney-general.gov.uk
          aka.attorney-general.gov.uk
          www.ago.gov.uk
          aka.ago.gov.uk
          www.lslo.gov.uk
          aka.lslo.gov.uk
        }
        site.hosts.pluck(:hostname).sort.should eql(hosts.sort)
      end

      describe 'updates' do
        before do
          redirector_yaml_file.import!
          Transition::Import::SiteYamlFile.load('spec/fixtures/sites/updates/ago.yml').import!
        end

        its(:launch_date)           { should eql(Date.new(2014, 12, 13)) }
        its(:tna_timestamp)         { should be_a(Time) }
        its(:homepage)              { should eql('https://www.gov.uk/government/organisations/attorney-update-office') }
      end
    end
  end

{'fraction_non_alphanumeric': 0.11354534746760896, 'fraction_numerical': 0.007538280329799764, 'mean_word_length': 2.426957223567393, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, 'lorem ipsum': 0, 'www.': 12, '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': '3428107', 'n_tokens_mistral': 1410, 'n_tokens_neox': 1322, 'n_words': 240}