Sha256: dd7a4fe8966ef50d237a0fded11459a3a6fa9b287aab2dd68381bb470d07a8c2

Contents?: true

Size: 981 Bytes

Versions: 7

Compression:

Stored size: 981 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      describe FavorJoin do
        let(:fj) { FavorJoin.new }

        it 'registers an offence for an array followed by string' do
          inspect_source(fj,
                         ['%w(one two three) * ", "'])
          expect(fj.offences.size).to eq(1)
          expect(fj.offences.map(&:message))
            .to eq([FavorJoin::MSG])
        end

        it 'does not register an offence for numbers' do
          inspect_source(fj,
                         ['%w(one two three) * 4'])
          expect(fj.offences).to be_empty
        end

        it 'does not register an offence for ambiguous cases' do
          inspect_source(fj,
                         ['test * ", "'])
          expect(fj.offences).to be_empty

          inspect_source(fj,
                         ['%w(one two three) * test'])
          expect(fj.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/favor_join_spec.rb
rubocop-0.11.1 spec/rubocop/cop/style/favor_join_spec.rb
rubocop-0.11.0 spec/rubocop/cops/style/favor_join_spec.rb
rubocop-0.10.0 spec/rubocop/cops/style/favor_join_spec.rb
rubocop-0.9.1 spec/rubocop/cops/style/favor_join_spec.rb
sabat-rubocop-0.9.0 spec/rubocop/cops/style/favor_join_spec.rb
rubocop-0.9.0 spec/rubocop/cops/style/favor_join_spec.rb