Read more

How to remove RSpec "old syntax" deprecation warnings

Dominik Schöler
June 03, 2014Software engineer at makandra GmbH

RSpec 3.0 deprecates the :should way of writing specs for expecting things to happen Show archive.org snapshot .

Illustration web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
Read more Show archive.org snapshot

However, if you have tests you cannot change (e.g. because they are inside a gem, spanning multiple versions of Rails and RSpec), you can explicitly allow the deprecated syntax.

Fix

Inside spec/spec_helpber.rb, set rspec-expectations’ and/or rspec-mocks’ syntax as following:

RSpec.configure do |config|
  # ...
  config.mock_with :rspec do |c|
    c.syntax = [:should, :expect]
  end
  config.expect_with :rspec do |c|
    c.syntax = [:should, :expect]
  end
end

Note that you may set it to only one of the syntax options, too. The above code is for maximum compatibility.

Posted by Dominik Schöler to makandra dev (2014-06-03 16:56)