Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

--pattern does not support "{a,b}" #868

Closed
rkh opened this Issue · 7 comments

2 participants

@rkh

Or: How do I run specs from multiple directories?

@rkh

I think this is due to File.fnmatch and friends not (no longer?) supporting that syntax.

@rkh

FYI, this is how I worked around this (in my Rakefile):

path       = Dir['{,addons/*/}{spec,lib}'].join(':')
spec_files = Dir['{,addons/*/}spec/**/*_spec.rb'].join(' ')
rspec      = "-I #{path} -w -S rspec #{spec_files}"

namespace :spec do
  desc "run enabled specs"
  task :enabled do
    ruby rspec
  end

  desc "run disabled specs"
  task :disabled do
    ENV['RUN_XIT'] = '1'
    ruby "#{rspec} -t focus"
  end

  desc "run all the specs"
  task :all do
    ENV['RUN_XIT'] = '1'
    ruby rspec
  end
end

Strange that Dir[] supports this syntax.

@rkh

Using File::FNM_EXTGLOB would work.

@myronmarston

The normal way I run specs from multiple directories is by passing them as arguments to the rspec command:

$ bin/rspec spec/unit spec/integration

Does that not work for you?

@rkh

Yes, it does, in my case I would need to generate the list of directories, though. Still wanted to let you know about the bug. BTW, this does not seem related to fnmatch, as RSpec is using Dir[], it is actually related to RSpec splitting the pattern on , - which fixes it for me, too, but it wasn't obvious from the docs, and breaks curly brackets matching. Feel free to close this issue.

@myronmarston

Hmm...I haven't looked into the way we do the patterns thing much as I've never used the option. The comma splitting allows for multiple patterns to be passed, but as you noticed, breaks part of the pattern syntax. Can you think of a way for it to support multiple patterns while still supporting the full pattern syntax? Ideally, it would be nice to maintain backwards compatibility, but if that isn't possible, we're planning to start on 3.0 soon, and that gives us the rare chance to break backwards compatibility (since we try to follow SemVer).

@rkh

I have an idea. Let me wrap up a quick PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.