debian-mirror-gitlab/spec/rubocop/cop/ban_catch_throw_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

26 lines
654 B
Ruby
Raw Normal View History

2020-04-08 14:13:33 +05:30
# frozen_string_literal: true
2022-10-11 01:57:18 +05:30
require 'rubocop_spec_helper'
2020-04-08 14:13:33 +05:30
require_relative '../../../rubocop/cop/ban_catch_throw'
2021-03-08 18:12:59 +05:30
RSpec.describe RuboCop::Cop::BanCatchThrow do
2020-04-08 14:13:33 +05:30
it 'registers an offense when `catch` or `throw` are used' do
2021-03-11 19:13:27 +05:30
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
2020-04-08 14:13:33 +05:30
end
it 'does not register an offense for a method called catch or throw' do
2021-03-11 19:13:27 +05:30
expect_no_offenses(<<~CODE)
foo.catch(:foo) {
foo.throw(:foo)
}
CODE
2020-04-08 14:13:33 +05:30
end
end