Sha256: 4931f4f7e9b7766dedb5ea81a585fd1c8c14a68921c9f139a6b1a7c55ed4369a
Contents?: true
Size: 1.42 KB
Versions: 2
Compression:
Stored size: 1.42 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop module Style describe WhenThen do subject(:cop) { WhenThen.new } it 'registers an offence for when x;' do inspect_source(cop, ['case a', 'when b; c', 'end']) expect(cop.messages).to eq( ['Never use "when x;". Use "when x then" instead.']) end it 'accepts when x then' do inspect_source(cop, ['case a', 'when b then c', 'end']) expect(cop.messages).to be_empty end it 'accepts ; separating statements in the body of when' do inspect_source(cop, ['case a', 'when b then c; d', 'end', '', 'case e', 'when f', ' g; h', 'end']) expect(cop.messages).to be_empty end it 'auto-corrects "when x;" with "when x then"' do new_source = autocorrect_source(cop, ['case a', 'when b; c', 'end']) expect(new_source).to eq("case a\nwhen b then c\nend") end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.13.1 | spec/rubocop/cop/style/when_then_spec.rb |
rubocop-0.13.0 | spec/rubocop/cop/style/when_then_spec.rb |