From the course: Ruby: Testing with RSpec

Unlock the full course today

Join today to access over 22,500 courses taught by industry experts or purchase this course individually.

Basic syntax

Basic syntax - Ruby Tutorial

From the course: Ruby: Testing with RSpec

Start my 1-month free trial

Basic syntax

- In this movie, we'll learn the Basic Syntax of using RSpec. In RSpec, describe is used to define an example group. Describe takes one argument, which can either be a string or a class name. In this case, since we're describing the 'Car' class, we could really use either one. We'll talk more about what benefits you gain when you use a class name later on. For now, let's just use a simple string. The main purpose of this string is for use during the test output. So that you'll know which tests RSpec is referring to. Describe also has a Ruby block that comes after that's everything from do down to end. Everything inside is part of this example group. What goes inside an example group? Examples, of course. It is used to define an example. Specify is also a word you can use as an alias for it, but I think you'll find that most people use it. The it which is being referred to here is 'Car'. It also accepts a string and has a Ruby block. Again, the string is used mostly for output. Notice…

Contents