Sha256: 4704363c3a6711b08006ff878568edf8046efeee1537bef35d5c0bcb5d5f1a53
Contents?: true
Size: 1.92 KB
Versions: 2
Compression:
Stored size: 1.92 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop module Style describe SpaceBeforeModifierKeyword do subject(:cop) { described_class.new } it 'registers an offence for missing space before if/unless' do inspect_source(cop, ['(a = 3)if a == 2', 'a = "test"if a == 2', 'a = 42unless a == 2', 'a = [1,2,3]unless a == 2', 'a = {:a => "b"}if a == 2']) expect(cop.highlights).to eq([')', '"', '2', ']', '}']) end it 'registers an offence for missing space before while/until' do inspect_source(cop, ['(a = 3)while b', 'a = "test"until b', 'a = 42while b', 'a = [1,2,3]until b', 'a = {:a => "b"}while b']) expect(cop.highlights).to eq([')', '"', '2', ']', '}']) end it 'accepts modifiers with preceding space' do inspect_source(cop, ['(a = 3) if b', 'a = "test" unless b', 'a = 42 while b', 'a = [1,2,3] until b']) expect(cop.offences).to be_empty end it 'accepts elsif at beginning of line' do inspect_source(cop, ["if RUBY_VERSION.between?('1.9.2', '2.0.0')", " require 'testing/performance/ruby/yarv'", 'elsif RUBY_VERSION.between?("1.8.6", "1.9")', " require 'testing/performance/ruby/mri'", 'end']) expect(cop.highlights).to eq([]) end it 'does not crash on ternary conditionals' do inspect_source(cop, 'a ? b : c') expect(cop.offences).to be_empty 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/space_before_modifier_keyword_spec.rb |
rubocop-0.13.0 | spec/rubocop/cop/style/space_before_modifier_keyword_spec.rb |