Sha256: 32c87acefbc6b8d6ff459476cd7ab777d0e1542620b0a19a94fb4117f5633313

Contents?: true

Size: 1.29 KB

Versions: 3

Compression:

Stored size: 1.29 KB

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      describe WhileUntilDo do
        let(:cop) { WhileUntilDo.new }

        it 'registers an offence for do in multiline while' do
          inspect_source(cop, ['while cond do',
                               'end'])
          expect(cop.offences.size).to eq(1)
        end

        it 'registers an offence for do in multiline until' do
          inspect_source(cop, ['until cond do',
                               'end'])
          expect(cop.offences.size).to eq(1)
        end

        it 'accepts do in single-line while' do
          inspect_source(cop, ['while cond do something end'])
          expect(cop.offences).to be_empty
        end

        it 'accepts do in single-line until' do
          inspect_source(cop, ['until cond do something end'])
          expect(cop.offences).to be_empty
        end

        it 'it accepts multi-line while without do' do
          inspect_source(cop, ['while cond',
                               'end'])
          expect(cop.offences).to be_empty
        end

        it 'it accepts multi-line until without do' do
          inspect_source(cop, ['until cond',
                               'end'])
          expect(cop.offences).to be_empty
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
rubocop-0.9.1 spec/rubocop/cops/style/while_until_do_spec.rb
sabat-rubocop-0.9.0 spec/rubocop/cops/style/while_until_do_spec.rb
rubocop-0.9.0 spec/rubocop/cops/style/while_until_do_spec.rb