Permalink
Browse files

Write spec

  • Loading branch information...
pocke committed Jun 7, 2016
1 parent d1d5e2a commit 257355d504f241ca45ec2c7da765911fff3635ef
Showing with 69 additions and 0 deletions.
  1. +69 −0 spec/rubocop/cop/lint/exception_call_spec.rb
@@ -0,0 +1,69 @@
# encoding: utf-8
# frozen_string_literal: true
require 'spec_helper'
describe RuboCop::Cop::Lint::ExceptionCall do
subject(:cop) { described_class.new }
context 'raise' do
let(:source){'raise StandardError "foo"'}
it '' do
inspect_source(cop, source)
expect(cop.messages)
.to eq(['カンマ(,)を忘れていませんか?'])
expect(cop.offenses.size).to eq(1)
expect(cop.highlights).to eq([' '])
end
it 'auto-correct comma' do
new_source = autocorrect_source(cop, source)
expect(new_source)
.to eq('raise StandardError, "foo"')
end
end
context 'fail' do
let(:source){'fail ArgumentError "bar"'}
it '' do
inspect_source(cop, source)
expect(cop.messages)
.to eq(['カンマ(,)を忘れていませんか?'])
expect(cop.offenses.size).to eq(1)
expect(cop.highlights).to eq([' '])
end
it 'auto-correct comma' do
new_source = autocorrect_source(cop, source)
expect(new_source)
.to eq('fail ArgumentError, "bar"')
end
end
context 'Kernel.raise' do
let(:source){'Kernel.raise IOError "baz"'}
it '' do
inspect_source(cop, source)
expect(cop.messages)
.to eq(['カンマ(,)を忘れていませんか?'])
expect(cop.offenses.size).to eq(1)
expect(cop.highlights).to eq([' '])
end
it 'auto-correct comma' do
new_source = autocorrect_source(cop, source)
expect(new_source)
.to eq('Kernel.raise IOError, "baz"')
end
end
context 'success' do
let(:source){'raise StandardError, "foobar"'}
it do
inspect_source(cop, source)
expect(cop.messages)
expect(cop.offenses).to be_empty
end
end
end

0 comments on commit 257355d

Please sign in to comment.