RSpec – Expectations
When you learn RSpec, you may read a lot about expectations and it can be a bit confusing at first. There are two main details you should keep in mind…
When you learn RSpec, you may read a lot about expectations and it can be a bit confusing at first. There are two main details you should keep in mind…
You may want to read the section on RSpec Metadata before reading this section because, as it turns out, RSpec filtering is based on RSpec Metadata. Imagine that you have…
RSpec is a flexible and powerful tool. The Metadata functionality in RSpec is no exception. Metadata generally refers to âdata about dataâ. In RSpec, this means data about your describe, context and it blocks.…
Sometimes your RSpec examples need an easy way to share reusable code. The best way to accomplish this is with Helpers. Helpers are basically regular Ruby methods which you share…
One of RSpecâs strengths is that it provides many ways to write tests, clean tests. When your tests are short and uncluttered, it becomes easier to focus on the expected…
RSpec Tags provide an easy way to run specific tests in your spec files. By default, RSpec will run all tests in the spec files that it runs, but you…
When you are writing unit tests, it is often convenient to run setup and teardown code before and after your tests. Setup code is the code that configures or âsets…
If youâve already read the section on RSpec Doubles (aka Mocks), then you have already seen RSpec Stubs. In RSpec, a stub is often called a Method Stub, itâs a…
In this chapter, we will discuss RSpec Doubles, also known as RSpec Mocks. A Double is an object which can âstand inâ for another object. Youâre probably wondering what that…
If you recall our original Hello World example, it contained a line that looked like this â expect(message).to eq "Hello World!" The keyword eql is an RSpec âmatcherâ. Here, we will introduce…