Sha256: 8fad616996ff41e20eb04876bc2aa1fc04f76a0bfffb52d28c1a7459e574442e

Contents?: true

Size: 1.06 KB

Versions: 4

Compression:

Stored size: 1.06 KB

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    describe WhenThen do
      let(:wt) { WhenThen.new }

      it 'registers an offence for when x;' do
        inspect_source(wt, ['case a',
                            'when b; c',
                            'end'])
        expect(wt.offences.map(&:message)).to eq(
          ['Never use "when x;". Use "when x then" instead.'])
      end

      it 'accepts when x then' do
        inspect_source(wt, ['case a',
                            'when b then c',
                            'end'])
        expect(wt.offences.map(&:message)).to be_empty
      end

      it 'accepts ; separating statements in the body of when' do
        inspect_source(wt, ['case a',
                            'when b then c; d',
                            'end',
                            '',
                            'case e',
                            'when f',
                            '  g; h',
                            'end'])
        expect(wt.offences.map(&:message)).to be_empty
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.8.3 spec/rubocop/cops/when_then_spec.rb
rubocop-0.8.2 spec/rubocop/cops/when_then_spec.rb
rubocop-0.8.1 spec/rubocop/cops/when_then_spec.rb
rubocop-0.8.0 spec/rubocop/cops/when_then_spec.rb