Class: RailsProof::AiTestExecutor

Inherits:
Object
  • Object
show all
Defined in:
lib/rails_proof/ai_test_executor.rb

Defined Under Namespace

Classes: Result

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(root:, test_file_path:, test_class_name:, superclass:, concerns:, target_path: nil, runner_class: RailsProof::TestRunner, review_store: nil) ⇒ AiTestExecutor

Returns a new instance of AiTestExecutor.



46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/rails_proof/ai_test_executor.rb', line 46

def initialize(
  root:,
  test_file_path:,
  test_class_name:,
  superclass:,
  concerns:,
  target_path: nil,
  runner_class: RailsProof::TestRunner,
  review_store: nil
)
  @root = Pathname.new(root)
  @target_path = target_path
  @test_file_path = test_file_path
  @test_class_name = test_class_name
  @superclass = superclass
  @concerns = concerns
  @runner_class = runner_class
  @review_store = review_store ||
    RailsProof::ReviewStore.new(root: @root)
end

Instance Attribute Details

#concerns ⇒ Object (readonly)

Returns the value of attribute concerns.



37
38
39
# File 'lib/rails_proof/ai_test_executor.rb', line 37

def concerns
  @concerns
end

#review_store ⇒ Object (readonly)

Returns the value of attribute review_store.



37
38
39
# File 'lib/rails_proof/ai_test_executor.rb', line 37

def review_store
  @review_store
end

#root ⇒ Object (readonly)

Returns the value of attribute root.



37
38
39
# File 'lib/rails_proof/ai_test_executor.rb', line 37

def root
  @root
end

#runner_class ⇒ Object (readonly)

Returns the value of attribute runner_class.



37
38
39
# File 'lib/rails_proof/ai_test_executor.rb', line 37

def runner_class
  @runner_class
end

#superclass ⇒ Object (readonly)

Returns the value of attribute superclass.



37
38
39
# File 'lib/rails_proof/ai_test_executor.rb', line 37

def superclass
  @superclass
end

#target_path ⇒ Object (readonly)

Returns the value of attribute target_path.



37
38
39
# File 'lib/rails_proof/ai_test_executor.rb', line 37

def target_path
  @target_path
end

#test_class_name ⇒ Object (readonly)

Returns the value of attribute test_class_name.



37
38
39
# File 'lib/rails_proof/ai_test_executor.rb', line 37

def test_class_name
  @test_class_name
end

#test_file_path ⇒ Object (readonly)

Returns the value of attribute test_file_path.



37
38
39
# File 'lib/rails_proof/ai_test_executor.rb', line 37

def test_file_path
  @test_file_path
end

Instance Method Details

#execute ⇒ Object



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/rails_proof/ai_test_executor.rb', line 67

def execute
  filter = RailsProof::AiConcernFilter.new(
    concerns: concerns,
    existing_tests: existing_test_source,
    review_findings: outstanding_review_findings
  )

  results = filter.concerns.map do |concern|
    execute_concern(concern)
  end

  results.concat(
    filter.skipped.map do |skipped|
      skipped_result(skipped)
    end
  )

  results
end