Ability to add custom reloaders to run before running all specs. #43
Ability to add custom reloaders to run before running all specs. #43sumitmah wants to merge 5 commits into
Conversation
|
Hi @sumitmah, thanks for this! Before we get this ready to merge, could you help us understand the scenario in which you want to have special reloaders associated with run_all but not normal runs? |
| .guard-jruby-spec | ||
| Gemfile.lock No newline at end of file | ||
| Gemfile.lock | ||
| .idea/ |
There was a problem hiding this comment.
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.
|
@nilbus As it is mentioned in readme,
I was also facing similar issues with my Rails project. e.g. for shared specs(I saw similar issue already posted for this gem) "context not found". This was happening because of following code. def unload_previous_examples
::RSpec.configuration.reset
::RSpec.world.reset
end
def reset
example_groups.clear
@shared_example_group_registry = nil
endHere is example from my guardfile reload_shared_specs = lambda do
if Object.const_defined?('Rails')
$LOADED_FEATURES.reject! { |path| path =~ /\/spec\/support\//}
ActiveSupport::Dependencies.loaded.reject! { |path| path =~ /\/spec\/support\//}.inspect
ActiveSupport::Dependencies.autoloaded_constants.each {|c| ActiveSupport::Dependencies.loaded.reject! { |path| path =~ /#{c.to_s.underscore}/} }
ActiveSupport::Dependencies.autoloaded_constants.each {|c| $LOADED_FEATURES.reject! { |path| path =~ /#{c.to_s.underscore}/} }
ActiveSupport::Dependencies.explicitly_unloadable_constants.each {|c| ActiveSupport::Dependencies.loaded.reject! { |path| path =~ /#{c.to_s.underscore}/} }
ActiveSupport::Dependencies.explicitly_unloadable_constants.each {|c| $LOADED_FEATURES.reject! { |path| path =~ /#{c.to_s.underscore}/} }
Dir[::Rails.root.join('spec/support/**/*.rb')].each { |f| ::RSpec.world.shared_example_group_registry.require_or_load(f) }
end
end |
|
Thanks for the background information, and sorry for the delay @sumitmah. I'm trying to connect the code changes with that background story. Is the Guardfile code you provided what you're running inside a |
|
@nilbus Yes |
This ability will give us resolve issues related to missing constants, loading/requiring files.