Sha256: fc67747200ac7f8941e7cdabeae985865df32c33f26acf89576c039e55b063a1

Contents?: true

Size: 1.21 KB

Versions: 2

Compression:

Stored size: 1.21 KB

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      describe SymbolArray do
        subject(:sa) { SymbolArray.new }

        it 'registers an offence for arrays of symbols', { ruby: 2.0 } do
          inspect_source(sa,
                         ['[:one, :two, :three]'])
          expect(sa.offences.size).to eq(1)
        end

        it 'does not reg an offence for array with non-syms', { ruby: 2.0 } do
          inspect_source(sa,
                         ['[:one, :two, "three"]'])
          expect(sa.offences).to be_empty
        end

        it 'does not reg an offence for array starting with %i',
           { ruby: 2.0 } do
          inspect_source(sa,
                         ['%i(one two three)'])
          expect(sa.offences).to be_empty
        end

        it 'does not reg an offence for array with one element',
           { ruby: 2.0 } do
          inspect_source(sa,
                         ['[:three]'])
          expect(sa.offences).to be_empty
        end

        it 'does nothing on Ruby 1.9', { ruby: 1.9 } do
          inspect_source(sa,
                         ['[:one, :two, :three]'])
          expect(sa.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/symbol_array_spec.rb
rubocop-0.13.0 spec/rubocop/cop/style/symbol_array_spec.rb