<commit_before>require 'rails_helper'

RSpec.describe DonutShopsController,  :type => :controller do
  render_views


  describe "GET #index" do

    it "renders the index page" do 
      get :index
      expect(response).to render_template(:index)
    end
  end
  
  describe "Get #show" do   

  let(:shop) { DonutShop.create!(name: Faker::Lorem.word, description: Faker::Lorem.sentence, address: Faker::Address, phone: Faker::PhoneNumber.phone_number, website: Faker::Internet.url, donut_id: 1 ) }

    it "renders the show page" do 
      get :show, { :id => shop.to_param }
      expect(response.status).to eq(200)
    end
  end

  

  # The test below need work. 

  describe 'POST #create' do
    context 'with valid attributes' do
  #     it 'creates a new donut shop' do
  #       post :create, donut_shop: attributes_for(:donut_shop)
  #       expect(DonutShop.count).to eq(1)
  #     end

      it "increases the donut shop count" do

        donut_shop_attributes = { name: Faker::Lorem.word, description: Faker::Lorem.sentence, address: Faker::Address, phone: "333-333-3983", website: Faker::Internet.url, donut_id: 1}

        expect { 
          post :create, donut_shop: donut_shop_attributes
          }.to change { DonutShop.count }.from(0).to 1
      end
    end
  end
end
 
<commit_msg>add test for donut shop create with invalid params<commit_after>require 'rails_helper'

RSpec.describe DonutShopsController,  :type => :controller do
  render_views


  describe "GET #index" do

    it "renders the index page" do 
      get :index
      expect(response).to render_template(:index)
    end
  end
  
  describe "Get #show" do   
  
    it "renders the show page" do 
     shop = DonutShop.create(name: Faker::Lorem.word, description: Faker::Lorem.sentence, address: Faker::Address, phone: Faker::PhoneNumber.phone_number, website: Faker::Internet.url, donut_id: 1)
      get :show, { :id => shop.to_param }
      expect(response.status).to eq(200)
    end
  end


  # The test below need work. 

  describe 'POST #create' do
    context 'with valid attributes' do

      it "increases the donut shop count" do
        donut_shop_attributes = { name: Faker::Lorem.word, description: Faker::Lorem.sentence, address: Faker::Address, phone: "333-333-3983", website: Faker::Internet.url, donut_id: 1}

        expect { 
          post :create, donut_shop: donut_shop_attributes
          }.to change { DonutShop.count }.from(0).to 1
      end
    end
    context 'with non-valid params' do 
      donut_shop_attributes = { name: Faker::Lorem.word, description: Faker::Lorem.sentence, address: Faker::Address, website: Faker::Internet.url }

      it "renders a new donut shop form" do  
          post :create, donut_shop: donut_shop_attributes
          expect(response).to render_template(:new)
      end

    end
  end
end
 

{'fraction_non_alphanumeric': 0.10618846694796062, 'fraction_numerical': 0.01230661040787623, 'mean_word_length': 3.0759312320916905, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5609873', 'n_tokens_mistral': 979, 'n_tokens_neox': 905, 'n_words': 258}