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 2
2
3
3
## Master (Unreleased)
4
4
5
+ - Add a cop that makes ` Timecop ` illegal, in favour of ` ActiveSupport::Testing::TimeHelpers ` . ([ @sambostock ] )
6
+
5
7
## 2.30.0 (2024-06-12)
6
8
7
9
- Fix an runtime error for rubocop-rspec +3.0. ([ @bquorning ] )
79
81
[ @paydaylight ] : https://github.com/paydaylight
80
82
[ @pirj ] : https://github.com/pirj
81
83
[ @r7kamura ] : https://github.com/r7kamura
84
+ [ @sambostock ] : https://github.com/sambostock
82
85
[ @splattael ] : https://github.com/splattael
83
86
[ @tmaier ] : https://github.com/tmaier
84
87
[ @ydah ] : https://github.com/ydah
Original file line number Diff line number Diff line change @@ -77,6 +77,13 @@ RSpecRails/NegationBeValid:
77
77
VersionChanged : ' 2.29'
78
78
Reference : https://www.rubydoc.info/gems/rubocop-rspec_rails/RuboCop/Cop/RSpecRails/NegationBeValid
79
79
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
+
80
87
RSpecRails/TravelAround :
81
88
Description : Prefer to travel in `before` rather than `around`.
82
89
Enabled : pending
Original file line number Diff line number Diff line change 2
2
3
3
module RuboCop
4
4
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`.
8
7
#
9
8
# ## Migration
10
9
# `Timecop.freeze` should be replaced with `freeze_time` when used
@@ -93,7 +92,7 @@ module Rails
93
92
# travel_to(time)
94
93
# travel(duration) { assert true }
95
94
# travel_to(time) { assert true }
96
- class Timecop < Base
95
+ class Timecop < :: RuboCop :: Cop :: Base
97
96
extend AutoCorrector
98
97
99
98
FREEZE_MESSAGE = 'Use `%<replacement>s` instead of `Timecop.freeze`'
Original file line number Diff line number Diff line change 6
6
require_relative 'rspec_rails/inferred_spec_type'
7
7
require_relative 'rspec_rails/minitest_assertions'
8
8
require_relative 'rspec_rails/negation_be_valid'
9
+ require_relative 'rspec_rails/timecop'
9
10
require_relative 'rspec_rails/travel_around'
Original file line number Diff line number Diff line change 1
1
# frozen_string_literal: true
2
2
3
- RSpec . describe RuboCop ::Cop ::Rails ::Timecop , :config do
3
+ RSpec . describe RuboCop ::Cop ::RSpecRails ::Timecop , :config do
4
4
shared_examples 'adds an offense to constant, and does not correct' do |usage :|
5
5
constant = usage . include? ( '::Timecop' ) ? '::Timecop' : 'Timecop'
6
6
You can’t perform that action at this time.
0 commit comments