Recursively glob for runtime RSpec test files

I have a set of RSpec tests that I want to group by the following hierarchy:

tests/ featA/ t1.rb t2.rb featB/ t3.rb 

but when i started

 $ rspec tests 

I get the following:

 rspec tests No examples were matched. Perhaps {:unless=>#<Proc: 0x00007f318919cc08@ /usr/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:51>, :if=>#<Proc: 0x00007f318919cdc0@ /usr/lib/ruby/gems/1.8/gems/rspec-core-2.5.1/lib/rspec/core/configuration.rb:50>} is excluding everything? Finished in 0.00003 seconds 0 examples, 0 failures 

I feel like I'm crazy, but there seems to be no way to get RSpec to swallow test files recursively? Does this functionality exist?

EDIT:

I have a workaround:

 $ rspec `find tests -name "*.rb"` 

but I suspect that I will not have to do this. I'm right?

+4
source share
2 answers

You put up supervision on my part! In rspec-1 you can say the following:

 spec test --pattern "**/*.rb" 

But the -pattern option is missing in rspec-2. I just added ( in development ) and it will be included in the rspec-2.6.0 release.

+6
source

Usually I control RSpec according to my specifications through rake . The relevant part of my Rakefile looks something like this:

 require 'rspec/core/rake_task' RSpec::Core::RakeTask.new(:spec) do |t| t.rspec_opts = ['--color', '-f progress', '-r ./spec/spec_helper.rb'] t.pattern = 'spec/**/*_spec.rb' t.fail_on_error = false end 

Now rake spec starts RSpec with the appropriate parameters; you will need to modify t.pattern according to the specifications you want to run.

Be sure to check out the RSpec2 website for more information.

+1
source

All Articles