I am in the middle of porting part of a ruby on rails project into a gem. I have used bundle gem to create the new gem directory. For the lib and spec directories, the gem's project layout looks like this:
|- lib
| |- mylib
| | |- MYCLASS.rb
| | |- version.rb
| |
| |- mylib.rb
|
|- spec
|- spec_helper.rb
|- mylib
|- test_MYCLASS.rb
The contents of spec/spec_helper.rb:
require "mylib"
RSpec.configure do |config|
end
The relevant parts of mylib.gemspec, as generated by the bundle gem command:
spec.files = `git ls-files`.split($/)
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
spec.require_paths = ["lib"]
When I run bundle exec rspec spec, I get
No examples found.
Finished in 0.00004 seconds
0 examples, 0 failures
Two questions.
- Is my directory layout for this gem "correct"? (Assuming there is an official layout)
- Why are my tests not running? When I do
bundle exec rspec spec/mylib/*, the tests inspec/mylib/test_MYCLASS.rbrun, whereas if I dobundle exec rspec spec/mylib/, it says no examples found.
I've looked at similar questions and googled around, but none of them solves my problem.