<commit_before>require 'rails_helper'

RSpec.describe "Gists", type: :request do
  describe "GET /gists" do
    it "redirects when unauthenticated" do
      get gists_path
      expect(response.status).to be(302)
    end
  end


  let(:rory) {User.create!(name: 'Rory', uid: "1")}
  let(:valid_attributes) { { description: "Test Gist", } }
  let(:valid_attributes_with_nested_gist_files) { { description: "Another Test", gist_files_attributes:
                                                        {
                                                          "0" => { file_type: 'ruby', body: 'puts "w00t"' },
                                                          "1" => { file_type: 'ruby', body: 'array.pop'}
                                                        }
  } }
  let(:invalid_attributes) { { description: nil, } }
  let(:valid_session) { { user_id: rory.id} }

  describe "GET index" do
    it "assigns all gists as @gists" do
      sign_in rory
      gist = Gist.create! valid_attributes
      get gists_path

      expect(response.body).to include("Test Gist")
    end
  end

  describe "GET show" do
    it "assigns the requested gist as @gist" do
      sign_in rory
      gist = Gist.create! valid_attributes
      get gist_path(gist)

      expect(response.body).to include("Test Gist")
    end
  end

  describe "GET new" do
    it "assigns a new gist as @gist" do
      sign_in rory
      get new_gist_path
      expect(response.body).to include("gist[gist_files_attributes][0][file_name]")
    end
  end

  describe "GET edit" do
    it "assigns the requested gist as @gist" do
      sign_in rory
      gist = Gist.create! valid_attributes
      get edit_gist_path(gist)
      expect(response.body).to include("Test Gist")
    end
  end

  describe "POST create" do
    describe "with valid params" do
      it "creates a new Gist" do
        sign_in rory
        expect {
          post gists_path, params: {gist: valid_attributes}
        }.to change(Gist, :count).by(1)
      end

      it "redirects to the created gist" do
        sign_in rory
        post gists_path, params: {gist: valid_attributes}
        expect(response).to redirect_to(Gist.last)
      end<commit_msg>Rename a few specs to better match what they test<commit_after>require 'rails_helper'

RSpec.describe "Gists", type: :request do
  describe "GET /gists" do
    it "redirects when unauthenticated" do
      get gists_path
      expect(response.status).to be(302)
    end
  end


  let(:rory) {User.create!(name: 'Rory', uid: "1")}
  let(:valid_attributes) { { description: "Test Gist", } }
  let(:valid_attributes_with_nested_gist_files) { { description: "Another Test", gist_files_attributes:
                                                        {
                                                          "0" => { file_type: 'ruby', body: 'puts "w00t"' },
                                                          "1" => { file_type: 'ruby', body: 'array.pop'}
                                                        }
  } }
  let(:invalid_attributes) { { description: nil, } }
  let(:valid_session) { { user_id: rory.id} }

  describe "GET index" do
    it "renders the gist description" do
      sign_in rory
      gist = Gist.create! valid_attributes
      get gists_path

      expect(response.body).to include("Test Gist")
    end
  end

  describe "GET show" do
    it "assigns the requested gist as @gist" do
      sign_in rory
      gist = Gist.create! valid_attributes
      get gist_path(gist)

      expect(response.body).to include("Test Gist")
    end
  end

  describe "GET new" do
    it "renders the gist description" do
      sign_in rory
      get new_gist_path
      expect(response.body).to include("gist[gist_files_attributes][0][file_name]")
    end
  end

  describe "GET edit" do
    it "assigns the requested gist as @gist" do
      sign_in rory
      gist = Gist.create! valid_attributes
      get edit_gist_path(gist)
      expect(response.body).to include("Test Gist")
    end
  end

  describe "POST create" do
    describe "with valid params" do
      it "creates a new Gist" do
        sign_in rory
        expect {
          post gists_path, params: {gist: valid_attributes}
        }.to change(Gist, :count).by(1)
      end

      it "redirects to the created gist" do
        sign_in rory
        post gists_path, params: {gist: valid_attributes}
        expect(response).to redirect_to(Gist.last)
      end
{'fraction_non_alphanumeric': 0.09662921348314607, 'fraction_numerical': 0.0044943820224719105, 'mean_word_length': 2.0094658553076403, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 16, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4105679', 'n_tokens_mistral': 1393, 'n_tokens_neox': 1349, 'n_words': 381}