The goal of this component is to collect and list all the deprecation of the project visually.
Add gem 'deprecations_detector'
to your application's Gemfile and execute bundle
.
Specify DeprecationDetector::Collect class as deprecation class with:
Rails.application.configure do
...
config.active_support.deprecation = DeprecationsDetector::Collect
...
end
Put the following code under you specs configuration:
require 'deprecations_detector'
RSpec.configure do |config|
config.before(:suite) do
DeprecationsDetector::Main.start
end
config.around do |e|
e.run
DeprecationsDetector::Main.add(e)
end
config.after(:suite) do
DeprecationsDetector::Main.save_results
coverage_matrix = DeprecationsDetector::Main.coverage_matrix
DeprecationsDetector::Formatters::HTML::Formatter.new.format(coverage_matrix)
end
end
Sometimes specs are run concurrently on multiple jobs. In order to collect the result on one file this gem provides some helpful task to combine the result in one single file and then format it.
- Remove the formatter from the after(:suite) hook
- Make the task available on your application following the instruction under
Tasks
section. - Save the coverage result on the same directory with different name for any job (e.g. tmp/deps/a.yml, tmp/deps/b.yml etc..)
- Run the task to combine the YAML files
bundle exec rake 'deprecations:combine[tmp/deps/,deprecations_detector.yml]'
- Run the task to format the YAML to HTML
bundle exec rake 'deprecations:format[tmp/deps/,deprecations_detector.yml]'
Add the following lines on your Rakefile to make the DeprecationsDetector tasks available from your application:
spec = Gem::Specification.find_by_name 'deprecations_detector'
load "#{spec.gem_dir}/lib/tasks/deprecations/combine.rake"
load "#{spec.gem_dir}/lib/tasks/deprecations/format.rake"
Execute bundle exec rspec
on the component root path, specs are based on an internal fake project.
Bug reports and pull requests are welcome on GitHub at https://github.com/nebulab/deprecations_detector. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
DeprecationsDetector is copyright © 2023 Nebulab. It is free software, and may be redistributed under the terms specified in the license. Inspired by ReverseCoverage
DeprecationsDetector is funded and maintained by the Nebulab team.
We firmly believe in the power of open-source. Contact us if you like our work and you need help with your project design or development.