Sha256: 33bb3b2529217ee0962bf9cd041c132ac53677494c34e07b7ea932a84b6c35e7
Contents?: true
Size: 1.72 KB
Versions: 3
Compression:
Stored size: 1.72 KB
Contents
# encoding: utf-8 require 'spec_helper' describe Rubocop::Cop::Style::RaiseArgs, :config do subject(:cop) { described_class.new(config) } context 'when enforced style is compact' do let(:cop_config) { { 'EnforcedStyle' => 'compact' } } it 'reports an offence for a raise with 2 args' do inspect_source(cop, ['raise RuntimeError, msg']) expect(cop.offences.size).to eq(1) end it 'reports an offence for a raise with 3 args' do inspect_source(cop, ['raise RuntimeError, msg, caller']) expect(cop.offences.size).to eq(1) end it 'accepts a raise with msg argument' do inspect_source(cop, ['raise msg']) expect(cop.offences).to be_empty end it 'accepts a raise with an exception argument' do inspect_source(cop, ['raise Ex.new(msg)']) expect(cop.offences).to be_empty end end context 'when enforced style is exploded' do let(:cop_config) { { 'EnforcedStyle' => 'exploded' } } it 'reports an offence for a raise with exception object' do inspect_source(cop, ['raise Ex.new(msg)']) expect(cop.offences.size).to eq(1) end it 'accepts exception constructor with more than 1 argument' do inspect_source(cop, ['raise RuntimeError.new(a1, a2, a3)']) expect(cop.offences).to be_empty end it 'accepts a raise with 3 args' do inspect_source(cop, ['raise RuntimeError, msg, caller']) expect(cop.offences).to be_empty end it 'accepts a raise with 2 args' do inspect_source(cop, ['raise RuntimeError, msg']) expect(cop.offences).to be_empty end it 'accepts a raise with msg argument' do inspect_source(cop, ['raise msg']) expect(cop.offences).to be_empty end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.16.0 | spec/rubocop/cop/style/raise_args_spec.rb |
rubocop-0.15.0 | spec/rubocop/cop/style/raise_args_spec.rb |
rubocop-0.14.1 | spec/rubocop/cop/style/raise_args_spec.rb |