Search code examples
ruby-on-railsruby-on-rails-4rspecrspec-railsrubymine

How to override RSpec's filter_run_excluding in RubyMine?


Is it possible to get RubyMine to ignore the spec_helper.rb filters? I usually add config.filter_run_excluding :js => truein my spec_helper file so that when running just rspec it excludes all js tests by default (because the js tests are usually slow).

But when I edit a file in RubyMine I would like to be able to run that single test, and get RubyMine to ignore the config.filter_run_excluding :js => true.

The way I solve it now is to comment out the line in the spec_helper.rb and then run the single test in RubyMine, but it would be nice to get that behaviour by default in RubyMine..

Versions

  • RubyMine 6.3.3
  • rspec-rails (2.14.1)
  • rails 4.0.4

I know I can also just remove the exclude filters in spec_helper and stop using just RSpec for running all the tests, and use rspec -tag ~js, but I would really like to just override the spec_helper filters in RubyMine and not in the terminal.


Solution

  • The easiest way is probably by using an environment variable.

    Surround that configuration line in spec_helper with a check for an environment variable

    unless ENV['INCLUDE_JS']
      config.filter_run_excluding :js => true
    end
    

    and add INCLUDE_JS=1 to the RSpec Run/Debug Configurations that you want to not exclude Javascript specs. If you want to do it for all Run/Debug Configurations, add the environment variable to the RSpec default and it will propagate to new configurations when they are created.