There should be another test for is_valid_name(str) where it guards against a false positive answer. It is discussed in the explanation video but there should be a test for it. In the following code, there is an early return that passes all the given tests but when given a name such as "“Robert DOWNEY JR” then it passes rather than fails.
def is_valid_name(str)
nameComponents = str.split(" ")
if !fullName(nameComponents)
return false
else
nameComponents.each do |name|
if isProperCased(name)
return true
else
return false
end
end
end
return something
end
def fullName(parts)
return parts.length > 1
end
def isProperCased(name)
properCase = name.capitalize
return name == properCase
end
puts is_valid_name("Kush Patel") # => true
puts is_valid_name("ROBERT DOWNEY JR") # => false
puts is_valid_name("Robert DOWNEY JR") # => should be false but actually returns true