From 46d1e486e0a7ae562ec3d4750e21595d7f4d0fb5 Mon Sep 17 00:00:00 2001 From: Kenneth Teh Date: Tue, 25 Oct 2022 14:43:26 +0800 Subject: [PATCH 1/2] Watch more folders to support Hanami --- README.md | 5 ++--- lib/rspec_preloader/file_selector.rb | 2 +- rspec_preloader.gemspec | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 8504901..fccac83 100644 --- a/README.md +++ b/README.md @@ -51,7 +51,7 @@ Restart your server each time you commit (see the How it works session to find o rspec-preloader will pass your input to rspec as is, so you can use any input rspec would accept, including specific line numbers or formatting options. -Only files from `app/` and `lib/` will be reloaded. If you modify spec helpers or spec support files, you should probably restart the preloader. +Only files from `app/`, `lib/`, `apps/` and `config/` will be reloaded. If you modify spec helpers or spec support files, you should probably restart the preloader. How it works --- @@ -60,7 +60,7 @@ This is what happens under the hood : - fork a process and run the tests in that process - wait for the next command - fork -- find which ruby files in `app/` and `lib/` have been modified using git +- find which ruby files in `app/`, `lib/`, `apps/` and `config/` have been modified using git - load them - run rspec in the forked process with the given input - start over @@ -78,4 +78,3 @@ Contributing Contributions welcome! Just fork it and send a pull request. This gem is under the MIT license by the way. - diff --git a/lib/rspec_preloader/file_selector.rb b/lib/rspec_preloader/file_selector.rb index 232abc9..578acd8 100644 --- a/lib/rspec_preloader/file_selector.rb +++ b/lib/rspec_preloader/file_selector.rb @@ -5,7 +5,7 @@ def self.updated_source_files def updated_source_files all_updated_files.select do |filename| - filename.start_with?('app/') || filename.start_with?('lib/') + filename.start_with?('app/', 'lib/', 'apps/', 'config/') end.select do |filename| filename.end_with?('.rb') end diff --git a/rspec_preloader.gemspec b/rspec_preloader.gemspec index 89d3af3..0a91f84 100644 --- a/rspec_preloader.gemspec +++ b/rspec_preloader.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |gem| gem.name = 'rspec-preloader' - gem.version = '1.1.0' + gem.version = '1.2.0' gem.licenses = ['MIT'] gem.summary = "Start Rspec instantly" gem.description = "Life is too short to be waiting for your tests to load." From 426b2e137c929fcaf9437f829764c02b9caa9efc Mon Sep 17 00:00:00 2001 From: Kenneth Teh Date: Wed, 9 Nov 2022 12:25:28 +0800 Subject: [PATCH 2/2] feat/handle subsequent invocations with spec runners --- CHANGELOG.md | 5 +++++ lib/rspec_preloader/spec_runner.rb | 2 ++ rspec_preloader.gemspec | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) create mode 100644 CHANGELOG.md diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..d6e62de --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,5 @@ +# Change Log + +## 1.3.0 + +- Add hack to handle subsequent invocations using spec runners by stripping strings 'bundle', 'exec', 'rspec-preloader', 'rspec' diff --git a/lib/rspec_preloader/spec_runner.rb b/lib/rspec_preloader/spec_runner.rb index 8e71a28..850c92e 100644 --- a/lib/rspec_preloader/spec_runner.rb +++ b/lib/rspec_preloader/spec_runner.rb @@ -31,6 +31,8 @@ def load_updated_files end def run_specs(arguments_array) + # NOTE: Hack to allow subsequent spec runner invocations to work + arguments_array.reject! { |arg| ['bundle', 'exec', 'rspec-preloader', 'rspec'].include?(arg) } RSpec::Core::Runner.run(arguments_array, @std_err, @std_out) end diff --git a/rspec_preloader.gemspec b/rspec_preloader.gemspec index 0a91f84..1c7a52e 100644 --- a/rspec_preloader.gemspec +++ b/rspec_preloader.gemspec @@ -1,6 +1,6 @@ Gem::Specification.new do |gem| gem.name = 'rspec-preloader' - gem.version = '1.2.0' + gem.version = '1.3.0' gem.licenses = ['MIT'] gem.summary = "Start Rspec instantly" gem.description = "Life is too short to be waiting for your tests to load."