<commit_before>require 'rails_helper'

RSpec.describe UsersController, type: :controller do

end<commit_msg>Add spec for new and create<commit_after>require 'rails_helper'

RSpec.describe UsersController, type: :controller do
  let(:sample_user) {FactoryGirl.build(:user)}

  it '#new' do
    get :new
    expect(assigns(:user)).to be_a_kind_of(User)
  end

  context '#create' do
    it 'creates a new user with valid params' do
      expect{
        post :create, user: FactoryGirl.attributes_for(:user)
      }.to change(User, :count).by(1)
    end

    it 'does not create a user with invalid params' do
      expect{
        post :create, user: {username: "sdf"}
      }.to_not change(User, :count)
    end

    it 'redirects to the root_path when the user is created' do
      expect(
        post :create, user: FactoryGirl.attributes_for(:user)
      ).to redirect_to root_path
    end

    it 'render new when user fails to create' do
      expect(
        post :create, user: {username: "sdf"}
      ).to render_template(:new)
    end
  end

end
{'fraction_non_alphanumeric': 0.1004739336492891, 'fraction_numerical': 0.0009478672985781991, 'mean_word_length': 3.0615384615384613, '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': '5313032', 'n_tokens_mistral': 342, 'n_tokens_neox': 327, 'n_words': 110}