How to remove RSpec "old syntax" deprecation warnings

Posted . Visible to the public.

RSpec 3.0 deprecates the :should way of writing specs for expecting things to happen 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.

Dominik Schöler
License
Source code in this card is licensed under the MIT License.
Posted by Dominik Schöler to makandra dev (2014-06-03 14:56)