From the course: Ruby: Testing with RSpec
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Solution: StringExtend - Ruby Tutorial
From the course: Ruby: Testing with RSpec
Solution: StringExtend
- In this movie, I'll show you the solution that I came up with to the StringExtend challenge. First, let's take a look at the titleize method. Notice here that I'm using this # syntax in front of the titleize, that let's me know that it's an instance method that we can call, I think it's a good practice to do that, and I usually just start out describe with only that, I'm describing titleize, I'm describing the instance method titleize. Now, for each one, I'm just going to try a sample, I'm just going to use a sample string. Here I have some title words, I'm going to call titleize on it, and what should I get back? I should expect it to titleize them, that is, to make each word a capital. Some Title Words. It should also work with single word strings, so if I have ruby, it should capitalize it to Ruby. It should capitalize all uppercase strings, so here I've got something that says ALL UPPERCASE WORDS, titleize should downcase the necessary letters so that it does still read as title…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.