Sha256: f788f91ffbc89520a26fa0751d201820cbfdac06a6cc105dcc10a27e8c294498

Contents?: true

Size: 802 Bytes

Versions: 6

Compression:

Stored size: 802 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Style::RedundantException do
  subject(:cop) { described_class.new }

  it 'reports an offense for a raise with RuntimeError' do
    inspect_source(cop, ['raise RuntimeError, msg'])
    expect(cop.offenses.size).to eq(1)
  end

  it 'reports an offense for a fail with RuntimeError' do
    inspect_source(cop, ['fail RuntimeError, msg'])
    expect(cop.offenses.size).to eq(1)
  end

  it 'accepts a raise with RuntimeError if it does not have 2 args' do
    inspect_source(cop, ['raise RuntimeError, msg, caller'])
    expect(cop.offenses).to be_empty
  end

  it 'accepts a fail with RuntimeError if it does not have 2 args' do
    inspect_source(cop, ['fail RuntimeError, msg, caller'])
    expect(cop.offenses).to be_empty
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rubocop-0.22.0 spec/rubocop/cop/style/redundant_exception_spec.rb
rubocop-0.21.0 spec/rubocop/cop/style/redundant_exception_spec.rb
rubocop-0.20.1 spec/rubocop/cop/style/redundant_exception_spec.rb
rubocop-0.20.0 spec/rubocop/cop/style/redundant_exception_spec.rb
rubocop-0.19.1 spec/rubocop/cop/style/redundant_exception_spec.rb
rubocop-0.19.0 spec/rubocop/cop/style/redundant_exception_spec.rb