Sha256: 3f7bb455e9587590475b7c7af3818a802153157b15a8b3acdee239f23be6bc83
Contents?: true
Size: 1.06 KB
Versions: 6
Compression:
Stored size: 1.06 KB
Contents
module Retest class Command def self.for(test_command) if test_command.include? '<test>' VariableCommand else HardcodedCommand end.new test_command end class VariableCommand attr_reader :command, :repository, :cached_test_file def initialize(command, repository: nil) @repository = repository || Repository.new @command = command end def ==(obj) command == obj.command end def run(file_changed) if @cached_test_file = test_file(file_changed) puts "Test File Selected: #{cached_test_file}" system command.gsub('<test>', cached_test_file) else puts <<~ERROR 404 - Test File Not Found Retest could not find a matching test file to run. ERROR end end def test_file(file_changed) repository.find_test(file_changed) || cached_test_file end end HardcodedCommand = Struct.new(:command) do def run(_) system command end end end end
Version data entries
6 entries across 6 versions & 1 rubygems