-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmake_rspec_tests_pass_task.rb
More file actions
35 lines (30 loc) · 1.03 KB
/
make_rspec_tests_pass_task.rb
File metadata and controls
35 lines (30 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
module Sublayer
module Tasks
class MakeRspecTestsPassTask < Base
def initialize(implementation_file_path:, test_command:)
@implementation_file_path = implementation_file_path
@test_command = test_command
end
def run
loop do
stdout, stderr, status = Sublayer::Actions::RunTestCommandAction.new(test_command: @test_command).call
puts stdout
puts stderr
if status.exitstatus == 0
puts "All tests pass!"
return
end
modified_implementation = Sublayer::Generators::ModifiedImplementationToPassTestsGenerator.new(
implementation_file_contents: File.read(@implementation_file_path),
test_file_contents: File.read(@test_command.split(" ")[1]),
test_output: stdout
).generate
Sublayer::Actions::WriteFileAction.new(
file_contents: modified_implementation,
file_path: @implementation_file_path
).call
end
end
end
end
end