Class: Tng::Services::DirectGeneration
- Inherits:
-
Object
- Object
- Tng::Services::DirectGeneration
- Includes:
- ExtractMethods
- Defined in:
- lib/tng/services/direct_generation.rb
Instance Method Summary collapse
-
#initialize(pastel, testng, http_client, params, show_post_generation_menu_proc) ⇒ DirectGeneration
constructor
A new instance of DirectGeneration.
- #run ⇒ Object
Methods included from ExtractMethods
#extract_controller_methods, #extract_model_methods, #extract_other_methods, #extract_service_methods
Constructor Details
#initialize(pastel, testng, http_client, params, show_post_generation_menu_proc) ⇒ DirectGeneration
11 12 13 14 15 16 17 |
# File 'lib/tng/services/direct_generation.rb', line 11 def initialize(pastel, testng, http_client, params, ) @pastel = pastel @testng = testng @http_client = http_client @params = params @show_post_generation_menu = end |
Instance Method Details
#run ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/tng/services/direct_generation.rb', line 19 def run file_path, method_name = @params[:file], @params[:method] unless file_path && method_name puts @pastel.red("❌ Both file and method parameters are required") puts @pastel.yellow("Usage: bundle exec tng app/controllers/users_controller.rb index") puts @pastel.yellow(" or: bundle exec tng --file=users_controller.rb --method=index") puts @pastel.yellow(" or: bundle exec tng f=users_controller.rb m=index") return end resolved_path = FileTypeDetector.resolve_file_path(file_path) unless resolved_path && File.exist?(resolved_path) puts @pastel.red("❌ File not found: #{file_path}") suggest_similar_files(file_path) return end type = FileTypeDetector.detect_type(resolved_path) generate_test_for_file(resolved_path, method_name, type) end |