Search code examples
rspec2guard

Can Guard read rspec CLI options from the ~/.rspec file?


I want to avoid having to set the CLI options for each of my guardfiles' rspec sections, like so:

guard 'rspec', :cli => "--color --drb --format documentation", :version => 2 do

I took out those :cli options entirely and restarted Guard but it did not load my custom options from ~/.rspec. I do not have a .rspec dotfile in my project dir either.

Any ideas on how to link up Guard with that dotfile?


Solution

  • rspec_dotfile = File.expand_path("~/.rspec")
    cli_options = File.exists?(rspec_dotfile) ? File.read(rspec_dotfile).chomp : "--some --default-options"
    guard 'rspec', :cli => cli_options, :version => 2 do
      # ...
    end