Skip to main content

Add RSpec::Its

Published: Oct 27th, 2020

This is part of Joyful Rails, a list of recommendations to make developing your Rails app more productive and joyful.

In this article, we are talking about adding RSpec::Its.

When

Add Rspec::Its when you want to make it easier to test the attributes of an object.

Why

With RSpec::Its you can write

its(:size) { is_expected.to eq(1) }

instead of

specify { expect(subject.size).to eq(1) }

How

Add rspec-its to the Gemfile in the test group and run bundle.