Please can someone explain to me how I should go about deciding whether to use expect or should syntax for my rspec examples.

From my understanding we should no longer be using the 'should' syntax.

The replacement is to use expect().to or is_expected.to

Is this correct?

On some really good references, it seems to be common practice to still use should. And these references are being updated consistently.

Any help in the correct direction would be appreciated.

References (+ others, but excluded)

  • Use whatever is best to read in the particular case. Readability is very important for specs.
    – back2dos
    Sep 11, 2014 at 10:49
  • @back2dos I don't think you read the question....
    – gbjbaanb
    Sep 11, 2014 at 10:58
  • In 2019: 1. bundle open shoulda-matchers 2. checkout the source code 3. judge it your self. and I agree with @back2dos Readability is very important. shoulda-machers help a lot with that. Oct 26, 2019 at 12:15

1 Answer 1


Yes you should use expect().to

.should is the original format but had some issues in certain circumstances

expect().to overcomes these issues

I have worked on several large github open source projects that have made the change over the past couple of years.

You may also find https://stackoverflow.com/a/19570645/631619 helpful

  • So would you say that companies like thoughtbot have just not updated their documentation for all of their repos - e.g. github.com/thoughtbot/shoulda-matchers Would really like to stick to best practices and they really seem to know what they are doing. Just wanted to be thorough. Thanks. Sep 11, 2014 at 11:42
  • 2
    I've taken courses at Thoughtbot and my instructors had made and recommended the switch. Sep 11, 2014 at 12:17
  • Is the is_expected.to syntax excepted? I find my specs to be super clean using is_expected and shoulda matchers e.g. it { is_expected.to validate_uniqueness_of(:start_date).scoped_to(:product_id) } Sep 11, 2014 at 13:21
  • I think that's the one format that didn't transition well (no short format) and we all miss it greatly. Oct 14, 2014 at 19:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.