Understanding test class naming
Unlike Java- or C-based programming languages, Ruby does not require the filename of a class to match the class contained inside. For example, the filename test1.rb
can contain a class named Potato
. Furthermore, a single file can contain multiple classes within it and Ruby compiler will not complain about it. With this setup, it is very easy to loose track of different pieces of code and classes. To reduce the complexity and confusion, there are several basic rules we can follow.
Note
Technically, these rules are more like suggestions, since the compiler will not prevent you from breaking them. Following them is advised, but not 100 percent necessary.
Naming files
It is a good idea to name the files as similar to the class that lives within it as possible. Since different test frameworks use different file naming conventions, we will adhere to the convention while at the same time clearly explaining what is contained inside the file.
For example, if we have a...