Search code examples
ruby-on-railsrspecguard

How to configure guard-rspec to ignore a directory when all the test cases are running?


Lets say I have three directors in my spec folder; features, test, integration. When I run bundle exec guard and press enter, is there a way that I can configure my Guardfile to ignore the test cases that are located in the integrations directory?


Solution

  • In your Guardfile, you can specify the command to use when running all specs. You can specify an rSpec command with a file exclude pattern to run everything but the integration specs:

    guard :rspec,
          cmd: 'bundle exec rspec', 
          run_all: { cmd: 'bundle exec rspec --exclude-pattern "**/integrations/*_spec.rb"' } do
      # ...
    end
    

    You might have to tweak this a bit depending on what you need exactly, see the links in the answer for the relevant bits of documentation.