Guard, how to temporally track specific file?
Actually you can just use focus: true
in the it
statement for instance:
In your Spec file.
it "needs to focus on this!", focus: true do
#test written here.
end
Then in spec/spec_helper you need to add the config option.
RSpec.configure do |config|
config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
end
Then Guard will automatically pick up test that is focused and run it only. Also the config.run_all_when_everything_filtered = true
tells guard to run all of the tests when there is nothing filtered even though the name sounds misleading.
I find Ryan Bate's rails casts to be very helpful on Guard and Spork.
Perhaps groups will work for you?
# In your Guardfile
group :focus do
guard :ruby do
watch('file_to_focus_on.rb')
end
end
# Run it with
guard -g focus
I know you mentioned you don't want to modify the Guardfile, but adding a group would just need to be done once, not every time you switch from watching the project to a focused set and back.
Of course if the set of files you need to focus on changes, you'll need to change the args to watch
(and maybe add more watchers), but I figure you'll have to specify them somewhere and this seems as good a place as any.
Alternately, if you really don't want to list the files to focus on in the Guardfile, you could have the :focus group read in a list of files from a separate file or an environment variable as suggested by David above. The Guardfile is just plain ruby (with access to the guard DSL), so it's easy to read a file or ENV variable.