diff --git a/.gitignore b/.gitignore index 7403f78..488916a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,3 @@ *.gem .guard-jruby-spec -Gemfile.lock \ No newline at end of file +Gemfile.lock diff --git a/lib/guard/jruby-rspec.rb b/lib/guard/jruby-rspec.rb index 676eff6..b5eecb7 100644 --- a/lib/guard/jruby-rspec.rb +++ b/lib/guard/jruby-rspec.rb @@ -17,7 +17,8 @@ def initialize(watchers = [], options = {}) :spec_file_suffix => "_spec.rb", :run_all => {}, :monitor_file => ".guard-jruby-rspec", - :custom_reloaders => [] + :custom_reloaders => [], + :custom_reloaders_for_run_all => [] }.merge(options) @last_failed = false @failed_paths = [] @@ -43,7 +44,8 @@ def initialize(watchers = [], options = {}) @inspector = Inspector.new(@options) @runner = Runner.new(@options) - @reloaders = set_up_reloaders(@options) + @reloaders = set_up_reloaders(@options[:custom_reloaders], [:reload_rails, :reload_paths, :reload_factory_girl]) + @runall_reloaders = set_up_reloaders(@options[:custom_reloaders_for_run_all]) end # Call once when guard starts @@ -54,6 +56,7 @@ def start def run_all unload_previous_examples + @runall_reloaders.reload super end @@ -114,11 +117,10 @@ def reload_paths(paths) private - def set_up_reloaders(options) + def set_up_reloaders(custom_reloaders, reloader_methods=[]) reloaders = Reloaders.new - reloader_methods = [:reload_rails, :reload_paths, :reload_factory_girl] - reloader_procs = reloader_methods.map { |name| method(name) } - reloader_procs += options[:custom_reloaders] + reloader_procs = custom_reloaders + reloader_procs += reloader_methods.map { |name| method(name) } reloader_procs.each { |reloader| reloaders.register &reloader } reloaders diff --git a/spec/guard/jruby-rspec_spec.rb b/spec/guard/jruby-rspec_spec.rb index 7f096b7..f16f0ad 100644 --- a/spec/guard/jruby-rspec_spec.rb +++ b/spec/guard/jruby-rspec_spec.rb @@ -11,7 +11,8 @@ :spec_file_suffix => "_spec.rb", :run_all => {}, :monitor_file => ".guard-jruby-rspec", - :custom_reloaders => [] + :custom_reloaders => [], + :custom_reloaders_for_run_all=>[] } end