File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
33RSpec . describe AiGitCommit ::CLI do
4- # class CLI < Thor
5- # HOOK_PATH = ".git/hooks/prepare-commit-msg"
6- # SCRIPT = <<~SCRIPT
7- # #{"#!/bin/bash" unless File.exist?(HOOK_PATH)}
8- # ruby -r './lib/ai_git_commit.rb' -e 'puts AiGitCommit::Generator.commit_message' >> .git/COMMIT_EDITMSG
9- # SCRIPT
10- #
11- # # Installs the prepare-commit-msg hook.
12- # # If the hook already exists, appends the script; otherwise, creates a new hook file.
13- # # Makes the hook executable and prints a confirmation message.
14- # desc "install", "Set up prepare-commit-msg hook"
15- # def install
16- # if File.exist?(HOOK_PATH)
17- # File.open(HOOK_PATH, "a") { _1.puts SCRIPT }
18- # else
19- # File.write(HOOK_PATH, SCRIPT)
20- # end
21- #
22- # FileUtils.chmod("+x", HOOK_PATH)
23- # puts "AI Git Commit prepare-commit-msg hook set up."
24- # end
25- # end
26-
274 it 'inherits from Thor' do
285 expect ( described_class . superclass ) . to eq ( Thor )
296 end
3613 end
3714 end
3815
39- # spec/lib/cli_spec.rb
40-
4116 describe '#install' do
4217 let ( :cli ) { described_class . new }
4318 let ( :script_content ) { 'script content' }
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ RSpec . describe AiGitCommit ::Config do
4+ describe 'initialize' do
5+ let ( :default_values ) do
6+ {
7+ openai_api_key : ENV [ "OPENAI_API_KEY" ] ,
8+ model : "gpt-3.5-turbo" ,
9+ program_language :,
10+ max_tokens : 300 ,
11+ temperature : 0.7 ,
12+ system_role_message :
13+ }
14+ end
15+ let ( :program_language ) { "Ruby" }
16+ let ( :system_role_message ) do
17+ <<~MESSAGE
18+ You are a senior #{ program_language } developer. Your task is to write a concise, clear commit
19+ message and a detailed description based on the provided code changes. The message
20+ should be in the imperative mood. The body should be wrapped at 72 characters.
21+ MESSAGE
22+ end
23+
24+ subject { described_class . new }
25+
26+ it 'defines default configuration values' do
27+ is_expected . to have_attributes ( default_values )
28+ end
29+ end
30+
31+ describe '.config' do
32+ subject { AiGitCommit . config }
33+
34+ it 'returns a Config instance' do
35+ is_expected . to be_a ( AiGitCommit ::Config )
36+ end
37+ end
38+
39+ describe '.configure' do
40+ let ( :new_model ) { "gpt-4" }
41+
42+ subject do
43+ AiGitCommit . configure do |config |
44+ config . model = new_model
45+ end
46+ end
47+
48+ it 'yields config block' do
49+ expect { subject } . to change { AiGitCommit . config . model } . to ( new_model )
50+ end
51+ end
52+ end
You can’t perform that action at this time.
0 commit comments