Sha256: 017ce197dfc274f3b3a359d625688abfa4f9dbc58b4f41ff51258f8e0624fb0c
Contents?: true
Size: 1.64 KB
Versions: 3
Compression:
Stored size: 1.64 KB
Contents
module Retest class Runner def self.for(test_command) if test_command.include? '<test>' VariableRunner else HardcodedRunner end.new test_command end class VariableRunner attr_reader :command def initialize(command) @command = command @cached_test_file = nil end def ==(obj) command == obj.command && obj.class == self.class end def cached_test_file @cached_test_file end def cached_test_file=(value) @cached_test_file = value || @cached_test_file end def run(test_file = nil) self.cached_test_file = test_file if cached_test_file 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 remove(purged) return if purged.empty? if purged.is_a? Array purge_cache if purged.include? cached_test_file elsif purged.is_a? String purge_cache if purged == cached_test_file end end def unmatching? !matching? end def matching? true end private def purge_cache @cached_test_file = nil end end HardcodedRunner = Struct.new(:command) do def run(_ = nil) system command end def remove(_ = nil); end def unmatching? !matching? end def matching? false end end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
retest-1.4.0 | lib/retest/runner.rb |
retest-1.3.0 | lib/retest/runner.rb |
retest-1.3.0.pre | lib/retest/runner.rb |