Shopify / deprecation_toolkit

⚒Eliminate deprecations from your codebase ⚒
MIT License
467 stars 40 forks source link

RSpec deprecation warnings not recorded without additional ENV var #84

Closed project-orcon closed 10 months ago

project-orcon commented 1 year ago

README needs to be updated for RSpec.

With the below configuration DeprecationToolkit::Configuration.warnings_treated_as_deprecation = [//]

expected the below code to trigger a deprecation warning, which it didn't

require 'spec_helper'

class MyClass
  def foo(k: 1)
    p k
  end
end

RSpec.describe MyClass do

    it 'calls method' do
      h = { k: 42 }
      MyClass.new.foo(h)
    end
end

expected the following warning "warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call"

Need to run with additional ENV VAR RUBYOPT='-W:deprecated' RUBYOPT='-W:deprecated' DEPRECATION_BEHAVIOR="record" bundle exec rspec spec

etiennebarrie commented 10 months ago

This is something related to Ruby 2.7.2 disabling deprecated warnings, and RSpec not enabling them either. You can read more about it in https://github.com/rspec/rspec-core/issues/2867.

You can add Warning[:deprecated] = true in your spec/spec_helper.rb to enable those.