Class: Ree::SpecRunner::SpecFilenameMatcher
- Defined in:
- lib/ree/spec_runner/spec_filename_matcher.rb
Class Method Summary collapse
Instance Method Summary collapse
- #find_matches ⇒ Object
-
#initialize(package_path, spec_matcher) ⇒ SpecFilenameMatcher
constructor
A new instance of SpecFilenameMatcher.
Constructor Details
#initialize(package_path, spec_matcher) ⇒ SpecFilenameMatcher
Returns a new instance of SpecFilenameMatcher.
10 11 12 13 |
# File 'lib/ree/spec_runner/spec_filename_matcher.rb', line 10 def initialize(package_path, spec_matcher) @package_path = File.(package_path) @spec_matcher = spec_matcher end |
Class Method Details
.find_matches(package_path:, spec_matcher:) ⇒ Object
5 6 7 |
# File 'lib/ree/spec_runner/spec_filename_matcher.rb', line 5 def find_matches(package_path:, spec_matcher:) Ree::SpecRunner::SpecFilenameMatcher.new(package_path, spec_matcher).find_matches end |
Instance Method Details
#find_matches ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/ree/spec_runner/spec_filename_matcher.rb', line 15 def find_matches expected_filename = File.join(@package_path, @spec_matcher) if File.exist?(expected_filename) return Pathname.new(expected_filename).relative_path_from(Pathname.new(@package_path)).to_s.split end Dir.glob(File.join(@package_path, '**/*_spec.rb')) .select { |fn| File.file?(fn) } .map {|file| Pathname.new(file).relative_path_from(Pathname.new(@package_path)).to_s } .grep(/#{@spec_matcher.split('').join('.*')}/) end |