File tree Expand file tree Collapse file tree 5 files changed +15
-5
lines changed
spec/rubocop/cop/rspec_rails Expand file tree Collapse file tree 5 files changed +15
-5
lines changed Original file line number Diff line number Diff line change 22
33## Master (Unreleased)
44
5+ - Add a cop that makes ` Timecop ` illegal, in favour of ` ActiveSupport::Testing::TimeHelpers ` . ([ @sambostock ] )
6+
57## 2.30.0 (2024-06-12)
68
79- Fix an runtime error for rubocop-rspec +3.0. ([ @bquorning ] )
7981[ @paydaylight ] : https://github.com/paydaylight
8082[ @pirj ] : https://github.com/pirj
8183[ @r7kamura ] : https://github.com/r7kamura
84+ [ @sambostock ] : https://github.com/sambostock
8285[ @splattael ] : https://github.com/splattael
8386[ @tmaier ] : https://github.com/tmaier
8487[ @ydah ] : https://github.com/ydah
Original file line number Diff line number Diff line change @@ -77,6 +77,13 @@ RSpecRails/NegationBeValid:
7777 VersionChanged : ' 2.29'
7878 Reference : https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/NegationBeValid
7979
80+ RSpecRails/Timecop :
81+ Description : Enforces use of `ActiveSupport::Testing::TimeHelpers` instead of `Timecop`.
82+ Enabled : pending
83+ VersionAdded : " <<next>>"
84+ SafeAutoCorrect : false
85+ Reference : https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/Timecop
86+
8087RSpecRails/TravelAround :
8188 Description : Prefer to travel in `before` rather than `around`.
8289 Enabled : pending
Original file line number Diff line number Diff line change 22
33module RuboCop
44 module Cop
5- module Rails
6- # Disallows all usage of `Timecop`, in favour of
7- # `ActiveSupport::Testing::TimeHelpers`.
5+ module RSpecRails
6+ # Enforces use of `ActiveSupport::Testing::TimeHelpers` instead of `Timecop`.
87 #
98 # ## Migration
109 # `Timecop.freeze` should be replaced with `freeze_time` when used
@@ -93,7 +92,7 @@ module Rails
9392 # travel_to(time)
9493 # travel(duration) { assert true }
9594 # travel_to(time) { assert true }
96- class Timecop < Base
95+ class Timecop < :: RuboCop :: Cop :: Base
9796 extend AutoCorrector
9897
9998 FREEZE_MESSAGE = 'Use `%<replacement>s` instead of `Timecop.freeze`'
Original file line number Diff line number Diff line change 66require_relative 'rspec_rails/inferred_spec_type'
77require_relative 'rspec_rails/minitest_assertions'
88require_relative 'rspec_rails/negation_be_valid'
9+ require_relative 'rspec_rails/timecop'
910require_relative 'rspec_rails/travel_around'
Original file line number Diff line number Diff line change 11# frozen_string_literal: true
22
3- RSpec . describe RuboCop ::Cop ::Rails ::Timecop , :config do
3+ RSpec . describe RuboCop ::Cop ::RSpecRails ::Timecop , :config do
44 shared_examples 'adds an offense to constant, and does not correct' do |usage :|
55 constant = usage . include? ( '::Timecop' ) ? '::Timecop' : 'Timecop'
66
You can’t perform that action at this time.
0 commit comments