Module: Filewatcher::SpecHelper::WatchRun
- Extended by:
- ModuleMethods::Extension
- Includes:
- Filewatcher::SpecHelper
- Included in:
- RubyWatchRun
- Defined in:
- lib/filewatcher/spec_helper/watch_run.rb
Overview
Base module for Filewatcher runners in specs
Defined Under Namespace
Modules: ClassMethods
Constant Summary collapse
- TMP_DIR =
'spec/tmp'
- TMP_FILES_DIR =
It’s requried to split modifying files from result files like CLI dumpers
"#{TMP_DIR}/files"
Constants included from Filewatcher::SpecHelper
ENVIRONMENT_SPECS_COEFFICIENTS
Instance Attribute Summary collapse
-
#initial_files ⇒ Object
readonly
Returns the value of attribute initial_files.
Instance Method Summary collapse
- #initialize(initial_files:, changes:) ⇒ Object
- #run(make_changes_times: 1) ⇒ Object
- #start ⇒ Object
- #stop ⇒ Object
Methods included from Filewatcher::SpecHelper
#debug, #environment_specs_coefficients, #logger, #system_stat, #system_stat_windows, #wait, #wait_with_block, #wait_without_block
Instance Attribute Details
#initial_files ⇒ Object (readonly)
Returns the value of attribute initial_files.
17 18 19 |
# File 'lib/filewatcher/spec_helper/watch_run.rb', line 17 def initial_files @initial_files end |
Instance Method Details
#initialize(initial_files:, changes:) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/filewatcher/spec_helper/watch_run.rb', line 32 def initialize(initial_files:, changes:) @initial_files = initial_files.transform_keys { |key| self.class.transform_spec_files(key) } @changes = changes debug "changes = #{@changes}" end |
#run(make_changes_times: 1) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/filewatcher/spec_helper/watch_run.rb', line 57 def run(make_changes_times: 1) start make_changes_times.times do make_changes wait seconds: 2 end stop end |
#start ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/filewatcher/spec_helper/watch_run.rb', line 40 def start debug 'start' FileUtils.mkdir_p self.class::TMP_FILES_DIR initial_files.each do |initial_file_path, initial_file_data| File.write( File.(initial_file_path), initial_file_data.fetch(:content, 'content1') ) end debug "start initial_files = #{initial_files}" wait seconds: 1 end |
#stop ⇒ Object
69 70 71 72 |
# File 'lib/filewatcher/spec_helper/watch_run.rb', line 69 def stop debug 'stop' FileUtils.rm_r(self.class::TMP_FILES_DIR) if File.exist?(self.class::TMP_FILES_DIR) end |