<commit_before>require "spec_helper"

RSpec.describe(Jekyll::GitHubMetadata::MetadataDrop) do
  let(:overrides) { { "repository" => "jekyll/another-repo" } }
  let(:config) { Jekyll::Configuration.from(overrides) }
  let(:site) { Jekyll::Site.new config }
  subject { described_class.new(site) }

  context "in Liquid" do
    before(:each) do
      stub_all_api_requests
      site.config.delete("repository")
      site.config["github"] = subject
    end

    it "renders as-is in Liquid" do
      payload = site.site_payload
      expect(payload["site"]["github"]).to be_instance_of(described_class)
      template = Liquid::Template.parse("{{ site.github }}")
      result = template.render!(payload, :registers => { :site => site })
      expect(result).to eql(subject.to_s)
    end
  end

  context "with no repository set" do
    before(:each) do
      site.config.delete("repository")
      ENV["PAGES_REPO_NWO"] = nil
    end
<commit_msg>Test that it turns into healthy json<commit_after>require "spec_helper"

RSpec.describe(Jekyll::GitHubMetadata::MetadataDrop) do
  let(:overrides) { { "repository" => "jekyll/another-repo" } }
  let(:config) { Jekyll::Configuration.from(overrides) }
  let(:site) { Jekyll::Site.new config }
  subject { described_class.new(site) }

  context "in Liquid" do
    before(:each) do
      stub_all_api_requests
      site.config.delete("repository")
      site.config["github"] = subject
    end

    it "renders as a pretty JSON object in Liquid" do
      require "json"
      payload = site.site_payload
      expect(payload["site"]["github"]).to be_instance_of(described_class)
      expect(
        Liquid::Template.parse("{{ site.github }}").render!(
          payload, :registers => { :site => site }
        )
      ).to eql(JSON.pretty_generate(subject.to_h))
    end
  end

  context "with no repository set" do
    before(:each) do
      site.config.delete("repository")
      ENV["PAGES_REPO_NWO"] = nil
    end

{'fraction_non_alphanumeric': 0.13747454175152748, 'fraction_numerical': 0.0, 'mean_word_length': 3.4760820045558085, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, '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': '2943674', 'n_tokens_mistral': 648, 'n_tokens_neox': 628, 'n_words': 130}