diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-02-18 10:34:06 +0000 |
commit | 859a6fb938bb9ee2a317c46dfa4fcc1af49608f0 (patch) | |
tree | d7f2700abe6b4ffcb2dcfc80631b2d87d0609239 /spec/rubocop/cop/rspec/timecop_travel_spec.rb | |
parent | 446d496a6d000c73a304be52587cd9bbc7493136 (diff) | |
download | gitlab-ce-859a6fb938bb9ee2a317c46dfa4fcc1af49608f0.tar.gz |
Add latest changes from gitlab-org/gitlab@13-9-stable-eev13.9.0-rc42
Diffstat (limited to 'spec/rubocop/cop/rspec/timecop_travel_spec.rb')
-rw-r--r-- | spec/rubocop/cop/rspec/timecop_travel_spec.rb | 47 |
1 files changed, 13 insertions, 34 deletions
diff --git a/spec/rubocop/cop/rspec/timecop_travel_spec.rb b/spec/rubocop/cop/rspec/timecop_travel_spec.rb index 2ee8bfe9ad7..476e45e69a6 100644 --- a/spec/rubocop/cop/rspec/timecop_travel_spec.rb +++ b/spec/rubocop/cop/rspec/timecop_travel_spec.rb @@ -3,50 +3,29 @@ require 'fast_spec_helper' require 'rubocop' -require 'rubocop/rspec/support' - require_relative '../../../../rubocop/cop/rspec/timecop_travel' RSpec.describe RuboCop::Cop::RSpec::TimecopTravel do - include CopHelper - subject(:cop) { described_class.new } context 'when calling Timecop.travel' do - let(:source) do - <<~SRC - Timecop.travel(1.day.ago) { create(:issue) } - SRC - end - - let(:corrected_source) do - <<~SRC - travel_to(1.day.ago) { create(:issue) } - SRC - end - - it 'registers an offence' do - inspect_source(source) - - expect(cop.offenses.size).to eq(1) - end - - it 'can autocorrect the source' do - expect(autocorrect_source(source)).to eq(corrected_source) + it 'registers an offense and corrects', :aggregate_failures do + expect_offense(<<~CODE) + Timecop.travel(1.day.ago) { create(:issue) } + ^^^^^^^^^^^^^^^^^^^^^^^^^ Do not use `Timecop.travel`, use `travel_to` instead. [...] + CODE + + expect_correction(<<~CODE) + travel_to(1.day.ago) { create(:issue) } + CODE end end context 'when calling a different method on Timecop' do - let(:source) do - <<~SRC - Timecop.freeze { create(:issue) } - SRC - end - - it 'does not register an offence' do - inspect_source(source) - - expect(cop.offenses).to be_empty + it 'does not register an offense' do + expect_no_offenses(<<~CODE) + Timecop.freeze { create(:issue) } + CODE end end end |