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

ban_catch_throw_spec.rb « cop « rubocop « spec - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: a41868410eb877b5db57fe9f2815314d9bf1c5c6 (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
# frozen_string_literal: true

require 'rubocop_spec_helper'

require_relative '../../../rubocop/cop/ban_catch_throw'

RSpec.describe RuboCop::Cop::BanCatchThrow do
  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