Skip to content

Ability to add custom reloaders to run before running all specs. #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .bundle/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
BUNDLE_PATH: "./vendor"
BUNDLE_DISABLE_SHARED_GEMS: '1'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why you chose to start vendoring the gems? Is this necessary for your setup?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this was for my setup. I prefer to store project specific gems in ./vendor gem dir.

4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
*.gem
.guard-jruby-spec
Gemfile.lock
Gemfile.lock
.idea/
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd rather not see .idea in the project .gitignore, as it's specific to your editor. Instead, this belongs in your global gitignore file. See https://help.github.com/articles/ignoring-files/ for setting this up.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

vendor/
14 changes: 8 additions & 6 deletions lib/guard/jruby-rspec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand All @@ -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
Expand All @@ -54,6 +56,7 @@ def start

def run_all
unload_previous_examples
@runall_reloaders.reload
super
end

Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion spec/guard/jruby-rspec_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down