Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

Closed
rkh opened this Issue Apr 10, 2013 · 7 comments

Comments

Projects
None yet
2 participants
Contributor

rkh commented Apr 10, 2013

Or: How do I run specs from multiple directories?

Contributor

rkh commented Apr 10, 2013

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

Contributor

rkh commented Apr 10, 2013

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.

Contributor

rkh commented Apr 10, 2013

Using File::FNM_EXTGLOB would work.

Owner

myronmarston commented Apr 10, 2013

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?

Contributor

rkh commented Apr 10, 2013

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.

Owner

myronmarston commented Apr 10, 2013

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).

Contributor

rkh commented Apr 10, 2013

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

@rkh rkh added a commit to rkh/rspec-core that referenced this issue Apr 10, 2013

@rkh rkh add support for curly brackets with the --pattern option, fixes #868 4a0f1f1

@myronmarston myronmarston added a commit that referenced this issue Apr 11, 2013

@myronmarston myronmarston Merge pull request #869 from rkh/curly-pattern
add support for curly brackets with the --pattern option, fixes #868
d5f5702
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment