4

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)
https://github.com/thoughtbot/shoulda-matchers
https://www.railstutorial.org/book

gbjbaanb
  • 48,749
  • 7
  • 106
  • 173

1 Answers1

7

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