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.


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


With RSpec::Its you can write

its(:size) { eq(1) }

instead of

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


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