blob: f255d27e7c7b5ac1603573b9ffc17ae296618e4d (
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
|
# frozen_string_literal: true
require 'fast_spec_helper'
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
|