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/ban_catch_throw_spec.rb')
-rw-r--r--spec/rubocop/cop/ban_catch_throw_spec.rb26
1 files changed, 12 insertions, 14 deletions
diff --git a/spec/rubocop/cop/ban_catch_throw_spec.rb b/spec/rubocop/cop/ban_catch_throw_spec.rb
index 4f669bad4af..b3c4ad8688c 100644
--- a/spec/rubocop/cop/ban_catch_throw_spec.rb
+++ b/spec/rubocop/cop/ban_catch_throw_spec.rb
@@ -1,30 +1,28 @@
# frozen_string_literal: true
require 'fast_spec_helper'
-
require 'rubocop'
-require 'rubocop/rspec/support'
require_relative '../../../rubocop/cop/ban_catch_throw'
RSpec.describe RuboCop::Cop::BanCatchThrow do
- include CopHelper
-
subject(:cop) { described_class.new }
it 'registers an offense when `catch` or `throw` are used' do
- inspect_source("catch(:foo) {\n throw(:foo)\n}")
-
- aggregate_failures do
- expect(cop.offenses.size).to eq(2)
- expect(cop.offenses.map(&:line)).to eq([1, 2])
- expect(cop.highlights).to eq(['catch(:foo)', 'throw(:foo)'])
- end
+ expect_offense(<<~CODE)
+ catch(:foo) {
+ ^^^^^^^^^^^ Do not use catch or throw unless a gem's API demands it.
+ throw(:foo)
+ ^^^^^^^^^^^ Do not use catch or throw unless a gem's API demands it.
+ }
+ CODE
end
it 'does not register an offense for a method called catch or throw' do
- inspect_source("foo.catch(:foo) {\n foo.throw(:foo)\n}")
-
- expect(cop.offenses).to be_empty
+ expect_no_offenses(<<~CODE)
+ foo.catch(:foo) {
+ foo.throw(:foo)
+ }
+ CODE
end
end