blob: b3c4ad8688cb2c26820d541d008c43eb822666a0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
# frozen_string_literal: true
require 'fast_spec_helper'
require 'rubocop'
require_relative '../../../rubocop/cop/ban_catch_throw'
RSpec.describe RuboCop::Cop::BanCatchThrow do
subject(:cop) { described_class.new }
it 'registers an offense when `catch` or `throw` are used' do
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
expect_no_offenses(<<~CODE)
foo.catch(:foo) {
foo.throw(:foo)
}
CODE
end
end
|