Sha256: 4d64b9b29f3048d388e0d296bf119f2f738e8f97a0b9b83aacde609105098924

Contents?: true

Size: 960 Bytes

Versions: 7

Compression:

Stored size: 960 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      describe AvoidFor do
        let(:af) { AvoidFor.new }

        it 'registers an offence for for' do
          inspect_source(af,
                         ['def func',
                          '  for n in [1, 2, 3] do',
                          '    puts n',
                          '  end',
                          'end'])
          expect(af.offences.size).to eq(1)
          expect(af.offences.map(&:message))
            .to eq([AvoidFor::MSG])
        end

        it 'does not register an offence for :for' do
          inspect_source(af,
                         ['[:for, :ala, :bala]'])
          expect(af.offences).to be_empty
        end

        it 'does not register an offence for def for' do
          inspect_source(af,
                         ['def for; end'])
          expect(af.offences).to be_empty
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
rubocop-0.12.0 spec/rubocop/cop/style/avoid_for_spec.rb
rubocop-0.11.1 spec/rubocop/cop/style/avoid_for_spec.rb
rubocop-0.11.0 spec/rubocop/cops/style/avoid_for_spec.rb
rubocop-0.10.0 spec/rubocop/cops/style/avoid_for_spec.rb
rubocop-0.9.1 spec/rubocop/cops/style/avoid_for_spec.rb
sabat-rubocop-0.9.0 spec/rubocop/cops/style/avoid_for_spec.rb
rubocop-0.9.0 spec/rubocop/cops/style/avoid_for_spec.rb