module QuickShoulda::PathResolver
Private Instance Methods
_model_full_namespace()
click to toggle source
# File lib/quick_shoulda/path_resolver.rb, line 12 def _model_full_namespace eval "::#{_model_full_namespace_in_str}" end
_model_full_namespace_in_str()
click to toggle source
given models/namespace/modelname.rb return Namespace::ModelName
# File lib/quick_shoulda/path_resolver.rb, line 25 def _model_full_namespace_in_str return path if is_a_constant?(path) model_path = path.split(/\/?models\//)[1].gsub('.rb','') model_path.split('/').map { |token| camelize(token) }.join('::') end
_spec_file_path()
click to toggle source
# File lib/quick_shoulda/path_resolver.rb, line 16 def _spec_file_path model_path = is_a_constant?(path) ? path.downcase.gsub('::', '/') : path.split(/\/?models\//)[1] file_name = "#{File.basename(model_path, ".rb")}_spec.rb" dir_name = File.dirname(model_path) == '.' ? spec_folder : "#{spec_folder}#{File.dirname(model_path)}/".gsub('//','/') "#{dir_name}#{file_name}" end
is_a_constant?(path)
click to toggle source
# File lib/quick_shoulda/path_resolver.rb, line 31 def is_a_constant?(path) ( path[0].chr =~ /[A-Z]/ || path[0].chr =~ /:/ ) && File.extname(path).empty? && !path.include?('/') end
spec_file_exist?()
click to toggle source
# File lib/quick_shoulda/path_resolver.rb, line 8 def spec_file_exist? File.file? spec_file_path end