Sha256: 80665ae5c4291d4ae28657aed89c8d4aeab0fc7ea53b9e1ce111e21bd9c16858

Contents?: true

Size: 1.3 KB

Versions: 4

Compression:

Stored size: 1.3 KB

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    describe WordArray do
      let(:wa) { WordArray.new }

      it 'registers an offence for arrays of single quoted strings' do
        inspect_source(wa,
                       ["['one', 'two', 'three']"])
        expect(wa.offences.size).to eq(1)
      end

      it 'registers an offence for arrays of double quoted strings' do
        inspect_source(wa,
                       ['["one", "two", "three"]'])
        expect(wa.offences.size).to eq(1)
      end

      it 'does not register an offence for array of non-words' do
        inspect_source(wa,
                       ['["one space", "two", "three"]'])
        expect(wa.offences).to be_empty
      end

      it 'does not register an offence for array starting with %w' do
        inspect_source(wa,
                       ['%w(one two three)'])
        expect(wa.offences).to be_empty
      end

      it 'does not register an offence for array with one element' do
        inspect_source(wa,
                       ['["three"]'])
        expect(wa.offences).to be_empty
      end

      it 'does not register an offence for array with empty strings' do
        inspect_source(wa,
                       ['["", "two", "three"]'])
        expect(wa.offences).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/word_array_spec.rb
rubocop-0.8.2 spec/rubocop/cops/word_array_spec.rb
rubocop-0.8.1 spec/rubocop/cops/word_array_spec.rb
rubocop-0.8.0 spec/rubocop/cops/word_array_spec.rb