class FindMatchingSpecs
Constants
- RUBY_FILE_EXTENSION
- SPEC_PREFIX_AND_EXTENSION
Attributes
directory[R]
files[R]
Public Class Methods
new(files)
click to toggle source
# File lib/find_matching_specs.rb, line 7 def initialize(files) @files = files @directory = directory end
Public Instance Methods
call()
click to toggle source
# File lib/find_matching_specs.rb, line 12 def call ruby_files = files.select { |filename| ruby_file?(filename) } spec_files = ruby_files.map { |filename| specs_for(filename) } spec_files.uniq end
Private Instance Methods
ruby_file?(filename)
click to toggle source
# File lib/find_matching_specs.rb, line 25 def ruby_file?(filename) filename.end_with?(RUBY_FILE_EXTENSION) end
spec_file?(filename)
click to toggle source
# File lib/find_matching_specs.rb, line 29 def spec_file?(filename) filename.end_with?(SPEC_PREFIX_AND_EXTENSION) end
spec_file_listing()
click to toggle source
# File lib/find_matching_specs.rb, line 21 def spec_file_listing @spec_file_listing ||= Dir.glob("**/spec/**/*#{SPEC_PREFIX_AND_EXTENSION}") end
specs_for(filename)
click to toggle source
# File lib/find_matching_specs.rb, line 33 def specs_for(filename) return [filename, filename] if spec_file?(filename) spec_match = spec_file_listing.detect do |spec_file| file_for_spec = spec_file.gsub(/\/?spec\//, '/') file_for_spec.sub!(SPEC_PREFIX_AND_EXTENSION, RUBY_FILE_EXTENSION) file_for_spec.sub!(/^\//, '') file_for_spec == filename end [filename, spec_match] end