diff --git a/README.md b/README.md index 552c8cc..dcbf986 100644 --- a/README.md +++ b/README.md @@ -102,6 +102,18 @@ if ENV["DEPRECATION_TRACKER"] end ``` +If using cucumber, create new file `features/support/deprecation_tracker.rb` with following content: + +```ruby +if ENV["DEPRECATION_TRACKER"] + DeprecationTracker.track_cucumber( + shitlist_path: "features/support/deprecation_warning.shitlist.json", + mode: ENV["DEPRECATION_TRACKER"], + transform_message: -> (message) { message.gsub("#{Rails.root}/", "") } + ) +end +``` + > Keep in mind this is currently not compatible with the `minitest/parallel_fork` gem! Once you have that, you can start using deprecation tracking in your tests: diff --git a/lib/deprecation_tracker.rb b/lib/deprecation_tracker.rb index 47700c8..363e640 100644 --- a/lib/deprecation_tracker.rb +++ b/lib/deprecation_tracker.rb @@ -116,6 +116,25 @@ def self.track_rspec(rspec_config, opts = {}) end end + def self.track_cucumber(opts = {}) + tracker = init_tracker(opts) + + Around do |scenario, block| + feature_file = scenario.location.file + tracker.bucket = feature_file.gsub(Rails.root.to_s, ".") + + begin + block.call + ensure + tracker.bucket = nil + end + end + + at_exit do + tracker.after_run + end + end + def self.track_minitest(opts = {}) tracker = init_tracker(opts)