Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubocop/cop/rspec/timecop_freeze_spec.rb')
-rw-r--r--spec/rubocop/cop/rspec/timecop_freeze_spec.rb47
1 files changed, 13 insertions, 34 deletions
diff --git a/spec/rubocop/cop/rspec/timecop_freeze_spec.rb b/spec/rubocop/cop/rspec/timecop_freeze_spec.rb
index b1cf82492e4..939623f8299 100644
--- a/spec/rubocop/cop/rspec/timecop_freeze_spec.rb
+++ b/spec/rubocop/cop/rspec/timecop_freeze_spec.rb
@@ -3,50 +3,29 @@
require 'fast_spec_helper'
require 'rubocop'
-require 'rubocop/rspec/support'
-
require_relative '../../../../rubocop/cop/rspec/timecop_freeze'
RSpec.describe RuboCop::Cop::RSpec::TimecopFreeze do
- include CopHelper
-
subject(:cop) { described_class.new }
context 'when calling Timecop.freeze' do
- let(:source) do
- <<~SRC
- Timecop.freeze(Time.current) { example.run }
- SRC
- end
-
- let(:corrected_source) do
- <<~SRC
- freeze_time(Time.current) { example.run }
- 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.freeze(Time.current) { example.run }
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Do not use `Timecop.freeze`, use `freeze_time` instead. [...]
+ CODE
+
+ expect_correction(<<~CODE)
+ freeze_time(Time.current) { example.run }
+ CODE
end
end
context 'when calling a different method on Timecop' do
- let(:source) do
- <<~SRC
- Timecop.travel(Time.current)
- 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.travel(Time.current)
+ CODE
end
end
end