RSpec 2 not finding specs from subdirectories when trying to run specs from there

Hi!

When having a file structure like this:
project
-spec
-subdir
-my_spec.rb

and then being in directory “project” and running command rspec spec
everything works as expected. If running rspec spec/subdir to run
only specs under spec/subdir then it doesn’t work - it finds 0
examples. It works as expected in RSpec 1. What do we do wrong?

Jarmo

On Jun 1, 2011, at 9:14 AM, Jarmo P. wrote:

only specs under spec/subdir then it doesn’t work - it finds 0
examples. It works as expected in RSpec 1. What do we do wrong?

I run subdirectories quite often and haven’t seen this issue. What’s in
your .rspec and spec/spec_helper.rb files? Also, which version of
rspec-2 are you using?

Try this in your spec helper file:

Dir[Rails.root.join(“spec/factories/**/*.rb”)].each {|f| require f}

I created a really simple example as shown above and this doesn’t work
for me - e.g. no spec_helper or .rspec files in use. I’m on Windows,
could that be the culprit (it happens on two machines)? Here is some
additional output:

C:\Users\jarmo\Desktop\minu\projects\Ruby\myproject>tree
Folder PATH listing
Volume serial number is E4DF-948C
C:.
└───spec
└───subdir

C:\Users\jarmo\Desktop\minu\projects\Ruby\myproject>ls -laR
total 0
drwxrwxrwx 1 user group 0 Jun 1 17:01 .
drwxrwxrwx 1 user group 0 Jun 1 06:15 …
drwxrwxrwx 1 user group 0 Jun 1 17:47 spec

spec=:
total 0
drwxrwxrwx 1 user group 0 Jun 1 17:47 .
drwxrwxrwx 1 user group 0 Jun 1 17:01 …
drwxrwxrwx 1 user group 0 Jun 1 17:46 subdir

spec\subdir=:
total 1
drwxrwxrwx 1 user group 0 Jun 1 17:46 .
drwxrwxrwx 1 user group 0 Jun 1 17:47 …
-rw-rw-rw- 1 user group 49 Jun 1 17:46 my_spec.rb

C:\Users\jarmo\Desktop\minu\projects\Ruby\myproject>cat spec\subdir
\my_spec.rb
describe “my” do
it “example” do
end
end

C:\Users\jarmo\Desktop\minu\projects\Ruby\myproject>rspec spec
.

Finished in 0.001 seconds
1 example, 0 failures

C:\Users\jarmo\Desktop\minu\projects\Ruby\myproject>spec spec
.

Finished in 0.037002 seconds

1 example, 0 failures

C:\Users\jarmo\Desktop\minu\projects\Ruby\myproject>rspec spec\subdir
No examples found.

Finished in 0 seconds
0 examples, 0 failures

C:\Users\jarmo\Desktop\minu\projects\Ruby\myproject>spec spec
.

Finished in 0.037003 seconds

1 example, 0 failures

C:\Users\jarmo\Desktop\minu\projects\Ruby\myproject>gem list | grep
rspec
rspec (2.6.0, 2.5.0, 2.3.0, 2.1.0, 1.3.1, 1.3.0)
rspec-core (2.6.3, 2.5.1, 2.3.1, 2.3.0, 2.2.1, 2.1.0)
rspec-expectations (2.6.0, 2.5.0, 2.3.0, 2.2.0, 2.1.0)
rspec-mocks (2.6.0, 2.5.0, 2.3.0, 2.2.0, 2.1.0)
rspec-rails (2.3.1, 2.1.0)

Jarmo

It is indeed related with Windows!

C:\Users\jarmo\Desktop\minu\projects\Ruby\myproject>rspec spec/subdir
.

Finished in 0.0045 seconds
1 example, 0 failures

C:\Users\jarmo\Desktop\minu\projects\Ruby\myproject>rspec spec\subdir
No examples found.

Finished in 0 seconds
0 examples, 0 failures

C:\Users\jarmo\Desktop\minu\projects\Ruby\myproject>spec spec\subdir
.

Finished in 0.040505 seconds

1 example, 0 failures

C:\Users\jarmo\Desktop\minu\projects\Ruby\myproject>spec spec/subdir
.

Finished in 0.040505 seconds

1 example, 0 failures

It needs path to be specified with unix-slashes…

Jarmo

On Jun 1, 2011, at 9:57 AM, Jarmo P. wrote:

C:\Users\jarmo\Desktop\minu\projects\Ruby\myproject>spec spec/subdir
.

Finished in 0.040505 seconds

1 example, 0 failures

It needs path to be specified with unix-slashes…

Please do me a favor and report this to
Issues · rspec/rspec-core · GitHub.

Thx