tng 0.2.3 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 905722688ad1966dbe0fbc488425daaa15124c1181a136df59a6a92b99871751
4
- data.tar.gz: 61b791a6c204dbddeec4e6d936bcf294e5a334ad2e836dd715b042580bd55f23
3
+ metadata.gz: 98da639352758b3b24da35177573d67e7e51860b85121eb0037926601d141027
4
+ data.tar.gz: 7f289b904f527e8f055e0b4586dc0242d678f4b590112ad16b028ae50d793581
5
5
  SHA512:
6
- metadata.gz: ee626a2d20b0d20ce0b412ee564e83f72326f2434a0065e66848a6f44b6d89e1d98453a6c311bff01ff551aa8634c60afdf586e5a5b1f538cd09ad63a3ff28e1
7
- data.tar.gz: 1f7ae4397fd988a72e13642f2d5a5a824d5694e7a8991c5b33073962b33b03fdf48b2c976130ab14f03839265a8a683a4141b2288d7aeb2461692fbc061e27a0
6
+ metadata.gz: 5ddc1271b830f67a918c8998397df4afa28e7fb679192eae280a95d3d4aa47a724f013c7aacd08f7f143063e1fcafe0cac732d6b866c9308582057125bd15c21
7
+ data.tar.gz: ad5fb8e2a558f3b2f46cfe646c9abb1b8bf2861d8761ec2bf5c980fe7832068f45b53418e01c4f1bcdfc1ab91556a890d678405a10ade4e24d57c16dda09d59d
data/README.md CHANGED
@@ -315,6 +315,33 @@ TNG focuses on precise, method-level test generation:
315
315
 
316
316
  Use `bundle exec tng --help` for more options.
317
317
 
318
+ ### Direct Mode (for Developers)
319
+
320
+ For experienced developers who want quick, command-line test generation:
321
+
322
+ ```bash
323
+ # Generate test for specific method using file path
324
+ bundle exec tng app/controllers/users_controller.rb index
325
+
326
+ # Short form using shortcuts
327
+ bundle exec tng f=users_controller.rb m=show
328
+
329
+ # Full parameter names
330
+ bundle exec tng --file=app/models/user.rb --method=validate
331
+
332
+ # Works from subdirectories (auto-detection)
333
+ bundle exec tng users_controller.rb index
334
+
335
+ # Mixed parameter order
336
+ bundle exec tng m=index f=app/controllers/users_controller.rb
337
+ ```
338
+
339
+ **Direct Mode Features:**
340
+ - **Automatic file type detection** - No need to specify `-t controller/model/service`
341
+ - **Flexible file path resolution** - Works with full paths or just filenames
342
+ - **Multiple syntax formats** - Use `f=` shortcuts or `--file=` full parameters
343
+ - **Smart path finding** - Automatically searches Rails directories
344
+
318
345
  ### Debug Mode
319
346
 
320
347
  For troubleshooting configuration or generation issues:
@@ -324,7 +351,7 @@ For troubleshooting configuration or generation issues:
324
351
  DEBUG=1 bundle exec tng
325
352
 
326
353
  # Direct mode with debug
327
- DEBUG=1 bundle exec tng -t c -f ping
354
+ DEBUG=1 bundle exec tng app/controllers/users_controller.rb index
328
355
  ```
329
356
 
330
357
  ### Help and Options
@@ -400,7 +427,7 @@ bundle exec tng -h # Short help
400
427
  Enable debug mode to get detailed information:
401
428
 
402
429
  ```bash
403
- DEBUG=1 bundle exec tng -t c -f your_controller
430
+ DEBUG=1 bundle exec tng app/controllers/your_controller.rb method_name
404
431
  ```
405
432
 
406
433
  Debug output includes:
data/Rakefile CHANGED
@@ -19,6 +19,27 @@ RbSys::ExtensionTask.new("tng", GEMSPEC) do |ext|
19
19
  ext.lib_dir = "lib/tng"
20
20
  end
21
21
 
22
+ # Create a task for the binaries/tng.bundle file that rb_sys expects
23
+ file "binaries/tng.bundle" do
24
+ FileUtils.mkdir_p("binaries")
25
+ # Copy from lib/tng if it exists, otherwise create empty file to satisfy dependency
26
+ if File.exist?("lib/tng/tng.bundle")
27
+ FileUtils.cp("lib/tng/tng.bundle", "binaries/tng.bundle")
28
+ else
29
+ # Create a placeholder file that will be overwritten by redo task
30
+ FileUtils.touch("binaries/tng.bundle")
31
+ end
32
+ end
33
+
34
+ # Ensure staging directories exist before compilation
35
+ task :prepare_staging do
36
+ staging_dir = "tmp/arm64-darwin24/stage/binaries"
37
+ FileUtils.mkdir_p(staging_dir) unless Dir.exist?(staging_dir)
38
+ end
39
+
40
+ # Make compile depend on staging preparation
41
+ task compile: :prepare_staging
42
+
22
43
  task default: %i[compile test rubocop]
23
44
 
24
45
  desc "Recompile Rust code and copy the binary for packaging"
@@ -32,13 +53,26 @@ task :redo do
32
53
  source_file = File.join("lib", "tng", binary_name)
33
54
  destination_dir = "binaries"
34
55
 
35
- if File.exist?(source_file)
36
- FileUtils.mkdir_p(destination_dir)
37
- FileUtils.cp(source_file, File.join(destination_dir, binary_name))
38
- puts "✅ Copied #{binary_name} to #{destination_dir}/"
39
- else
40
- puts "❌ Error: Compiled binary not found at #{source_file}"
41
- puts "Make sure 'rake compile' ran successfully."
56
+ retries = 0
57
+ max_retries = 5
58
+
59
+ while retries < max_retries
60
+ if File.exist?(source_file)
61
+ FileUtils.mkdir_p(destination_dir)
62
+ FileUtils.cp(source_file, File.join(destination_dir, binary_name))
63
+ puts "✅ Copied #{binary_name} to #{destination_dir}/"
64
+ break
65
+ else
66
+ retries += 1
67
+ if retries < max_retries
68
+ puts "⏳ Waiting for compiled binary... (attempt #{retries}/#{max_retries})"
69
+ sleep(0.5)
70
+ else
71
+ puts "❌ Error: Compiled binary not found at #{source_file}"
72
+ puts "Make sure 'rake compile' ran successfully."
73
+ exit 1
74
+ end
75
+ end
42
76
  end
43
77
  end
44
78
 
data/bin/tng CHANGED
@@ -9,6 +9,7 @@ $LOAD_PATH.unshift(lib_path) unless $LOAD_PATH.include?(lib_path)
9
9
  require "tng"
10
10
  require "tng/services/direct_generation"
11
11
  require "tng/services/extract_methods"
12
+ require "tng/services/file_type_detector"
12
13
 
13
14
  require "tty-prompt"
14
15
  require "tty-spinner"
@@ -54,19 +55,17 @@ class CLI
54
55
  example " • Browse and search controllers/models/services", ""
55
56
  example " • Select specific methods from filtered lists", ""
56
57
  example " • Generate tests for individual methods", ""
57
- end
58
-
59
- option :type do
60
- short "-t"
61
- long "--type=TYPE"
62
- desc "Test type (controller, model, service, other)"
63
- permit %w[controller model service other c m mo s se o]
58
+ example ""
59
+ example "Direct mode (automatic file type detection):", ""
60
+ example " bundle exec tng app/controllers/users_controller.rb index", ""
61
+ example " bundle exec tng f=users_controller.rb m=show", ""
62
+ example " bundle exec tng --file=app/models/user.rb --method=validate", ""
64
63
  end
65
64
 
66
65
  option :file do
67
66
  short "-f"
68
67
  long "--file=FILE"
69
- desc "File name (without .rb extension)"
68
+ desc "File path (with or without .rb extension)"
70
69
  end
71
70
 
72
71
  option :method do
@@ -109,7 +108,7 @@ class CLI
109
108
 
110
109
  initialize_config_and_clients if rails_loaded
111
110
 
112
- if params[:type] && params[:file]
111
+ if params[:file]
113
112
  run_direct_generation
114
113
  else
115
114
  if find_rails_root && !rails_loaded && !defined?(Rails)
@@ -130,35 +129,56 @@ class CLI
130
129
 
131
130
  def preprocess_arguments(argv)
132
131
  normalized = []
133
-
134
- argv.each do |arg|
132
+ positional_args = []
133
+
134
+ argv.each_with_index do |arg, index|
135
135
  case arg
136
- when /^(type|t)=(.+)$/ # Handle type=value or t=value (without dash)
137
- normalized << "--type=#{::Regexp.last_match(2)}"
138
- when /^(file|f)=(.+)$/ # Handle file=value or f=value (without dash)
139
- normalized << "--file=#{::Regexp.last_match(2)}"
140
- when /^(method|m)=(.+)$/ # Handle method=value or m=value (without dash)
141
- normalized << "--method=#{::Regexp.last_match(2)}"
142
- when /^(help|h)=(.+)$/ # Handle help=value or h=value (without dash)
143
- normalized << "--help=#{::Regexp.last_match(2)}"
144
- when /^-([tf])=(.+)$/ # Handle -t=value or -f=value (convert to long form)
145
- key = ::Regexp.last_match(1) == "t" ? "type" : "file"
146
- normalized << "--#{key}=#{::Regexp.last_match(2)}"
147
- when /^-([mh])=(.+)$/ # Handle -m=value or -h=value
148
- key = ::Regexp.last_match(1) == "m" ? "method" : "help"
149
- normalized << "--#{key}=#{::Regexp.last_match(2)}"
150
- when /^--\w+=.+$/ # Handle --key=value (already correct)
136
+ when /^(?:--)?(file|f)=(.+)$/
137
+ normalized << "--file=#{$2}"
138
+ when /^(?:--)?(method|m)=(.+)$/
139
+ normalized << "--method=#{$2}"
140
+ when /^(help|h)=(.+)$/
141
+ normalized << "--help=#{$2}"
142
+ when /^--file$/, /^-f$/
151
143
  normalized << arg
152
- when /^-[tfmh]$/ # Handle single flags like -t, -f, -m, -h (keep as is)
144
+ when /^--method$/, /^-m$/
153
145
  normalized << arg
154
- when /^--\w+$/ # Handle long flags like --help (keep as is)
146
+ when /^--help$/, /^-h$/
155
147
  normalized << arg
156
- else
157
- # Regular arguments or values
148
+ when /^--\w+=.+$/
158
149
  normalized << arg
150
+ else
151
+ prev_arg = argv[index - 1] if index > 0
152
+ if prev_arg && (prev_arg.match?(/^(-f|--file)$/) || prev_arg.match?(/^(-m|--method)$/))
153
+ normalized << arg
154
+ else
155
+ positional_args << arg
156
+ end
159
157
  end
160
158
  end
161
-
159
+
160
+ if positional_args.length >= 2
161
+ has_file = normalized.any? { |a| a.match?(/^--file/) }
162
+ has_method = normalized.any? { |a| a.match?(/^--method/) }
163
+
164
+ unless has_file
165
+ normalized << "--file=#{positional_args[0]}"
166
+ end
167
+ unless has_method
168
+ normalized << "--method=#{positional_args[1]}"
169
+ end
170
+ elsif positional_args.length == 1
171
+ arg = positional_args[0]
172
+ has_file = normalized.any? { |a| a.match?(/^--file/) }
173
+ has_method = normalized.any? { |a| a.match?(/^--method/) }
174
+
175
+ if !has_file && (arg.end_with?('.rb') || arg.include?('/'))
176
+ normalized << "--file=#{arg}"
177
+ elsif !has_method && !arg.include?('/')
178
+ normalized << "--method=#{arg}"
179
+ end
180
+ end
181
+
162
182
  normalized
163
183
  end
164
184
 
@@ -452,7 +472,7 @@ class CLI
452
472
  # Show completion message with test count and timing
453
473
  if result && result[:test_count]
454
474
  count_msg = result[:test_count] == 1 ? "1 test" : "#{result[:test_count]} tests"
455
- time_msg = result[:generation_time] ? " in #{format_generation_time(result[:generation_time])}" : ""
475
+ time_msg = result[:generation_time] ? " in #{Tng::Utils.format_generation_time(result[:generation_time])}" : ""
456
476
  completion_msg = @pastel.decorate(
457
477
  "#{Tng::UI::Theme.icon(:success)} Generated #{count_msg} for controller method#{time_msg}!", Tng::UI::Theme.color(:success)
458
478
  )
@@ -548,7 +568,7 @@ class CLI
548
568
  # Show completion message with test count and timing
549
569
  if result && result[:test_count]
550
570
  count_msg = result[:test_count] == 1 ? "1 test" : "#{result[:test_count]} tests"
551
- time_msg = result[:generation_time] ? " in #{format_generation_time(result[:generation_time])}" : ""
571
+ time_msg = result[:generation_time] ? " in #{Tng::Utils.format_generation_time(result[:generation_time])}" : ""
552
572
  completion_msg = @pastel.decorate(
553
573
  "#{Tng::UI::Theme.icon(:success)} Generated #{count_msg} for model method#{time_msg}!", Tng::UI::Theme.color(:success)
554
574
  )
@@ -607,7 +627,7 @@ class CLI
607
627
  # Show completion message with test count and timing
608
628
  if result && result[:test_count]
609
629
  count_msg = result[:test_count] == 1 ? "1 test" : "#{result[:test_count]} tests"
610
- time_msg = result[:generation_time] ? " in #{format_generation_time(result[:generation_time])}" : ""
630
+ time_msg = result[:generation_time] ? " in #{Tng::Utils.format_generation_time(result[:generation_time])}" : ""
611
631
  completion_msg = @pastel.decorate(
612
632
  "#{Tng::UI::Theme.icon(:success)} Generated #{count_msg} for service method#{time_msg}!", Tng::UI::Theme.color(:success)
613
633
  )
@@ -710,7 +730,7 @@ class CLI
710
730
  # Show completion message with test count and timing
711
731
  if result && result[:test_count]
712
732
  count_msg = result[:test_count] == 1 ? "1 test" : "#{result[:test_count]} tests"
713
- time_msg = result[:generation_time] ? " in #{format_generation_time(result[:generation_time])}" : ""
733
+ time_msg = result[:generation_time] ? " in #{Tng::Utils.format_generation_time(result[:generation_time])}" : ""
714
734
  completion_msg = @pastel.decorate(
715
735
  "#{Tng::UI::Theme.icon(:success)} Generated #{count_msg} for other method#{time_msg}!", Tng::UI::Theme.color(:success)
716
736
  )
@@ -733,7 +753,7 @@ class CLI
733
753
  end
734
754
 
735
755
  def check_system_status
736
- unless params[:type] && params[:file]
756
+ unless params[:file]
737
757
  puts @pastel.decorate("#{Tng::UI::Theme.icon(:info)} Checking system status...",
738
758
  Tng::UI::Theme.color(:muted))
739
759
  end
@@ -801,7 +821,7 @@ class CLI
801
821
  end
802
822
 
803
823
  def show_post_generation_menu(result)
804
- is_direct_mode = params[:type] && params[:file]
824
+ is_direct_mode = params[:file]
805
825
 
806
826
  if is_direct_mode
807
827
  puts
@@ -820,6 +840,7 @@ class CLI
820
840
  return
821
841
  end
822
842
 
843
+ # Show menu regardless of test results
823
844
  loop do
824
845
  puts
825
846
  header = @pastel.decorate("#{Tng::UI::Theme.icon(:rocket)} Test Generated Successfully!", Tng::UI::Theme.color(:primary))
@@ -838,6 +859,8 @@ class CLI
838
859
  cycle: true,
839
860
  symbols: { marker: Tng::UI::Theme.icon(:marker) }
840
861
  ) do |menu|
862
+ menu.choice @pastel.decorate("#{Tng::UI::Theme.icon(:run)} Run tests", Tng::UI::Theme.color(:success)),
863
+ :run_tests
841
864
  menu.choice @pastel.decorate("#{Tng::UI::Theme.icon(:config)} Copy run command", Tng::UI::Theme.color(:warning)),
842
865
  :copy_command
843
866
  menu.choice @pastel.decorate("#{Tng::UI::Theme.icon(:back)} Back to main menu", Tng::UI::Theme.color(:info)),
@@ -845,6 +868,8 @@ class CLI
845
868
  end
846
869
 
847
870
  case choice
871
+ when :run_tests
872
+ run_and_show_test_results(result[:run_command])
848
873
  when :copy_command
849
874
  copy_to_clipboard(result[:run_command])
850
875
  when :back
@@ -853,6 +878,99 @@ class CLI
853
878
  end
854
879
  end
855
880
 
881
+ def run_and_show_test_results(command)
882
+ puts
883
+ header = @pastel.decorate("#{Tng::UI::Theme.icon(:run)} Running tests...", Tng::UI::Theme.color(:primary))
884
+ puts center_text(header)
885
+
886
+ begin
887
+ # Check if test file exists before running
888
+ test_file = extract_test_file_from_command(command)
889
+ unless test_file && File.exist?(test_file)
890
+ error_msg = @pastel.decorate("#{Tng::UI::Theme.icon(:error)} Test file not found!", Tng::UI::Theme.color(:error))
891
+ puts center_text(error_msg)
892
+
893
+ if test_file
894
+ file_msg = @pastel.decorate("File: #{test_file}", Tng::UI::Theme.color(:muted))
895
+ puts center_text(file_msg)
896
+ end
897
+
898
+ suggestion_msg = @pastel.decorate("The test file may have been moved or deleted.", Tng::UI::Theme.color(:warning))
899
+ puts center_text(suggestion_msg)
900
+
901
+ @prompt.keypress(center_text(@pastel.decorate("Press any key to continue...", Tng::UI::Theme.color(:muted))))
902
+ return
903
+ end
904
+
905
+ # Modify command to get cleaner output
906
+ if command.include?("rspec")
907
+ # Use JSON format for RSpec - much cleaner parsing
908
+ json_command = command.sub(/rspec/, "rspec --format json --out /dev/null")
909
+ output = `#{json_command} 2>&1`
910
+ exit_code = $?.exitstatus
911
+
912
+ # Check for common errors before parsing
913
+ return if handle_test_execution_errors(output, exit_code)
914
+
915
+ Tng::Utils.parse_rspec_json_results(output, exit_code, @pastel, @terminal_width)
916
+ else
917
+ # For Rails test, use current approach but with cleaner output
918
+ output = `#{command} 2>&1`
919
+ exit_code = $?.exitstatus
920
+
921
+ # Check for common errors before parsing
922
+ return if handle_test_execution_errors(output, exit_code)
923
+
924
+ Tng::Utils.parse_minitest_results(output, exit_code, @pastel, @terminal_width)
925
+ end
926
+ rescue StandardError => e
927
+ error_msg = @pastel.decorate("#{Tng::UI::Theme.icon(:error)} Error running tests!", Tng::UI::Theme.color(:error))
928
+ puts center_text(error_msg)
929
+
930
+ details_msg = @pastel.decorate("#{e.message}", Tng::UI::Theme.color(:muted))
931
+ puts center_text(details_msg)
932
+ end
933
+
934
+ @prompt.keypress(center_text(@pastel.decorate("Press any key to continue...", Tng::UI::Theme.color(:muted))))
935
+ end
936
+
937
+ def handle_test_execution_errors(output, exit_code)
938
+ # Return true if we handled an error (caller should return early)
939
+ # Return false if no error was handled (caller should continue)
940
+
941
+ # If tests failed to run (non-zero exit code or common error patterns)
942
+ if !exit_code.zero? || output.include?("LoadError") || output.include?("cannot load such file") ||
943
+ (output.include?("bundler") && output.include?("Could not find")) ||
944
+ (output.include?("bin/rails") && (output.include?("require") || output.include?("load")))
945
+
946
+ error_msg = @pastel.decorate("#{Tng::UI::Theme.icon(:error)} Tests failed to run", Tng::UI::Theme.color(:error))
947
+ puts center_text(error_msg)
948
+
949
+ @prompt.keypress(center_text(@pastel.decorate("Press any key to continue...", Tng::UI::Theme.color(:muted))))
950
+ return true
951
+ end
952
+
953
+ false
954
+ end
955
+
956
+ def extract_test_file_from_command(command)
957
+ # Extract test file path from commands like:
958
+ # "bundle exec rails test test/controllers/foo_test.rb"
959
+ # "bundle exec rspec spec/controllers/foo_spec.rb"
960
+
961
+ if command.include?("rails test")
962
+ # For Rails test commands
963
+ match = command.match(/rails test\s+(.+?)(?:\s|$)/)
964
+ match[1] if match
965
+ elsif command.include?("rspec")
966
+ # For RSpec commands
967
+ match = command.match(/rspec\s+(.+?)(?:\s|$)/)
968
+ match[1] if match
969
+ else
970
+ nil
971
+ end
972
+ end
973
+
856
974
  def initialize_config_and_clients
857
975
  @config_initialized = true
858
976
 
@@ -868,20 +986,6 @@ class CLI
868
986
  )
869
987
  @testng = Services::Testng.new(@http_client)
870
988
  end
871
-
872
- private
873
-
874
- def format_generation_time(seconds)
875
- if seconds < 1
876
- "#{(seconds * 1000).round}ms"
877
- elsif seconds < 60
878
- "#{seconds.round(1)}s"
879
- else
880
- minutes = (seconds / 60).floor
881
- remaining_seconds = (seconds % 60).round
882
- "#{minutes}m #{remaining_seconds}s"
883
- end
884
- end
885
989
  end
886
990
 
887
991
  cli = CLI.new
@@ -48,37 +48,6 @@ module Tng
48
48
  Tng::Analyzer::Controller.model_info_for_controller(file_path)
49
49
  end
50
50
 
51
- def self.find_test_file_for_controller(controller_path)
52
- controller_name = File.basename(controller_path, ".rb")
53
- testing_framework = Tng.testing_framework
54
- return [] if testing_framework.nil?
55
-
56
- paths = if testing_framework.downcase == "rspec"
57
- [
58
- "spec/controllers/#{controller_name}_spec.rb",
59
- "spec/requests/#{controller_name}_spec.rb"
60
- ]
61
- else
62
- [
63
- "test/controllers/#{controller_name}_test.rb",
64
- "test/functional/#{controller_name}_test.rb"
65
- ]
66
- end
67
-
68
- paths.select { |path| File.exist?(path) }
69
- end
70
-
71
- def self.read_test_file_for_controller(controller_path)
72
- files = find_test_file_for_controller(controller_path)
73
-
74
- files.map do |file_path|
75
- {
76
- path: file_path,
77
- content: File.read(file_path)
78
- }
79
- end
80
- end
81
-
82
51
  def self.methods_for_controller(controller_name)
83
52
  raise "controller_name is required" if controller_name.nil?
84
53
 
@@ -14,37 +14,6 @@ module Tng
14
14
  Tng::Analyzer::Model.parse_model_file(file_path)
15
15
  end
16
16
 
17
- def self.read_test_file_for_model(model_path)
18
- files = find_test_file_for_model(model_path)
19
-
20
- files.map do |file_path|
21
- {
22
- path: file_path,
23
- content: File.read(file_path)
24
- }
25
- end
26
- end
27
-
28
- def self.find_test_file_for_model(model_path)
29
- model_name = File.basename(model_path, ".rb")
30
- testing_framework = Tng.testing_framework
31
- return [] if testing_framework.nil?
32
-
33
- paths = if testing_framework.downcase == "rspec"
34
- [
35
- "spec/models/#{model_name}_spec.rb",
36
- "spec/requests/#{model_name}_spec.rb"
37
- ]
38
- else
39
- [
40
- "test/models/#{model_name}_test.rb",
41
- "test/functional/#{model_name}_test.rb"
42
- ]
43
- end
44
-
45
- paths.select { |path| File.exist?(path) }
46
- end
47
-
48
17
  def self.model_connections(model)
49
18
  raise "model is required" if model.nil?
50
19
 
@@ -50,33 +50,6 @@ module Tng
50
50
  Tng::Analyzer::Service.parse_service_file(file_path)
51
51
  end
52
52
 
53
- def self.read_test_file_for_other(other_path)
54
- files = find_test_file_for_other(other_path)
55
-
56
- files.map do |file_path|
57
- {
58
- path: file_path,
59
- content: File.read(file_path)
60
- }
61
- end
62
- end
63
-
64
- def self.find_test_file_for_other(other_path)
65
- # Extract the file type and name for test file discovery
66
- file_type = determine_file_type(other_path)
67
- file_name = File.basename(other_path, ".rb")
68
- testing_framework = Tng.testing_framework
69
- return [] if testing_framework.nil?
70
-
71
- paths = if testing_framework.downcase == "rspec"
72
- build_rspec_test_paths(file_type, file_name)
73
- else
74
- build_minitest_test_paths(file_type, file_name)
75
- end
76
-
77
- paths.select { |path| File.exist?(path) }
78
- end
79
-
80
53
  def self.methods_for_other(other_name, file_path)
81
54
  raise "other_name is required" if other_name.nil?
82
55
  raise "file_path is required" if file_path.nil?
@@ -24,37 +24,6 @@ module Tng
24
24
  Tng::Analyzer::Service.parse_service_file(file_path)
25
25
  end
26
26
 
27
- def self.read_test_file_for_service(service_path)
28
- files = find_test_file_for_service(service_path)
29
-
30
- files.map do |file_path|
31
- {
32
- path: file_path,
33
- content: File.read(file_path)
34
- }
35
- end
36
- end
37
-
38
- def self.find_test_file_for_service(service_path)
39
- service_name = File.basename(service_path, ".rb")
40
- testing_framework = Tng.testing_framework
41
- return [] if testing_framework.nil?
42
-
43
- paths = if testing_framework.downcase == "rspec"
44
- [
45
- "spec/services/#{service_name}_spec.rb",
46
- "spec/service/#{service_name}_spec.rb"
47
- ]
48
- else
49
- [
50
- "test/services/#{service_name}_test.rb",
51
- "test/service/#{service_name}_test.rb"
52
- ]
53
- end
54
-
55
- paths.select { |path| File.exist?(path) }
56
- end
57
-
58
27
  def self.methods_for_service(service_name)
59
28
  raise "service_name is required" if service_name.nil?
60
29