Sha256: ed6a3bf9bd357ab8f26c4e00a659c843fa67cacdc94e57dba7d1c8faa3a762c0

Contents?: true

Size: 1.79 KB

Versions: 7

Compression:

Stored size: 1.79 KB

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      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 'registers an offence for arrays with character constants' do
          inspect_source(wa,
                         ['["one", ?\n]'])
          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 containing non-string' do
          inspect_source(wa,
                         ['["one", "two", 3]'])
          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
end

Version data entries

7 entries across 7 versions & 2 rubygems

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