<commit_before>require 'rails_helper'

RSpec.describe WestfieldSwagger::ApiSpecification do
  let(:version) { '1' }
  custom_api_host = 'my-custom-api-host'

  let(:request) {
    double(:request,
      host_with_port: 'some-service.hostname.com',
      port: 0)
  }

  subject { WestfieldSwagger::ApiSpecification.new(version, nil, request) }

  describe '#read' do
    context 'info block' do
      context 'when only a single file is used for the generated swagger' do
        it 'should return the last modified date of the single file in the swagger' do
          swagger_doc = JSON.parse(subject.read)
          expect(swagger_doc["info"]["x-last_modified_at"]).to eql('2015-09-15T20:39:23Z')
        end

        it 'should return the correct name value in the info block' do
          swagger_doc = JSON.parse(subject.read)
          expect(swagger_doc["info"]["contact"]["name"]).to eql('Westfield Support')
        end
      end

      context 'when multiple files are used for the generated swagger' do
        let(:version) { '3' }

        it 'should return the last modified date of the most recent file in the swagger' do
          time = Time.parse('2001-01-01T10:10:10Z')
          Dir.glob('spec/dummy/lib/swagger/3/*.yml').each do |file|
            FileUtils.touch(file, mtime: time += 1.hour)
          end

          swagger_doc = JSON.parse(subject.read)

          expect(swagger_doc["info"]["x-last_modified_at"]).to eql(time.utc.iso8601)
        end

        it 'should deeply sort the combined swagger document' do
          swagger_doc = JSON.parse(subject.read)

          expect(swagger_doc.keys)
            .to eql(["basePath", "consumes", "definitions", "info", "paths",
                     "produces", "schemes", "swagger", "tags", "host"])

          expect(swagger_doc["definitions"].keys)
            .to eql(["b", "c", "d", "emptyObject", "genericLink"])
        end
      end
    end

    context 'doodoo' do<commit_msg>Fix broken test<commit_after>require 'rails_helper'

RSpec.describe WestfieldSwagger::ApiSpecification do
  let(:version) { '1' }
  custom_api_host = 'my-custom-api-host'

  let(:request) {
    double(:request,
      host_with_port: 'some-service.hostname.com',
      port: 0)
  }

  subject { WestfieldSwagger::ApiSpecification.new(version, nil, request) }

  describe '#read' do
    context 'info block' do
      time = Time.parse('2001-01-01T10:10:10Z')

      context 'when only a single file is used for the generated swagger' do
        it 'should return the last modified date of the single file in the swagger' do
          FileUtils.touch('spec/dummy/lib/swagger/1.yml', mtime: time)
          swagger_doc = JSON.parse(subject.read)
          expect(swagger_doc["info"]["x-last_modified_at"]).to eql(time.utc.iso8601)
        end

        it 'should return the correct name value in the info block' do
          swagger_doc = JSON.parse(subject.read)
          expect(swagger_doc["info"]["contact"]["name"]).to eql('Westfield Support')
        end
      end

      context 'when multiple files are used for the generated swagger' do
        let(:version) { '3' }

        it 'should return the last modified date of the most recent file in the swagger' do
          Dir.glob('spec/dummy/lib/swagger/3/*.yml').each do |file|
            FileUtils.touch(file, mtime: time += 1.hour)
          end

          swagger_doc = JSON.parse(subject.read)

          expect(swagger_doc["info"]["x-last_modified_at"]).to eql(time.utc.iso8601)
        end

        it 'should deeply sort the combined swagger document' do
          swagger_doc = JSON.parse(subject.read)

          expect(swagger_doc.keys)
            .to eql(["basePath", "consumes", "definitions", "info", "paths",
                     "produces", "schemes", "swagger", "tags", "host"])

          expect(swagger_doc["definitions"].keys)
            .to eql(["b", "c", "d", "emptyObject", "genericLink"])
        end
      end
    end

    context 'doodoo' do
{'fraction_non_alphanumeric': 0.12449799196787148, 'fraction_numerical': 0.01631526104417671, 'mean_word_length': 2.6260236578707916, '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': '1687268', 'n_tokens_mistral': 1280, 'n_tokens_neox': 1229, 'n_words': 320}