Shopify / deprecation_toolkit

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

Add rspec support #37

Closed andrewmarkle closed 5 years ago

andrewmarkle commented 5 years ago

This is a first pass at closing #17 by adding support for RSpec.

Setup

For Rspec users the setup is slightly different than minitest.

(In rails_helper.rb or spec_helper.rb)

# Add Deprecation Toolkit library
require 'deprecation_toolkit/rspec'

RSpec.configure do |config|
  config.deprecation_behavior = :raise
end

Also it's worth noting that RSpec doesn't support adding custom flags when running tests. So you won't be able to add --record-deprecations when running your specs, but instead recording / raising would have to be changed at the config level (like above).

For that I've made a small DSL so you can pass in a symbol of (:raise, :record, or :disabled).

Still to do

I mostly want to open this PR to get some early feedback and see if this approach makes sense. I still need to write some tests for this!

andrewmarkle commented 5 years ago

@Edouard-chin should be good for another look when you have a chance!

andrewmarkle commented 5 years ago

@Edouard-chin It seems like there's some issue with using that latest version of rubocop in CI with the shopify style guide. Otherwise tests all seem to be passing.

.rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml: Performance/Sample has the wrong namespace - should be Style

Error: The `Performance/LstripRstrip` cop has been moved to `Style/Strip`
(obsolete configuration found in .rubocop-https---shopify-github-io-ruby-style-guide-rubocop-yml, please update it)

The command "bundle exec rubocop --config .rubocop.yml" exited with 2.
Edouard-chin commented 5 years ago

Thanks for your patience on this! Great work 🍻 !

Edouard-chin commented 5 years ago

I released 1.4.0 https://rubygems.org/gems/deprecation_toolkit/versions/1.4.0

andrewmarkle commented 5 years ago

Woohoo! Thank you!! 👌

aergonaut commented 5 years ago

Awesome! Thank you for merging this!