Sha256: 97312e1cf5457ede9f266f711631689f93091252269e3385b8d5483adf7405ca

Contents?: true

Size: 970 Bytes

Versions: 2

Compression:

Stored size: 970 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      describe FavorJoin do
        subject(: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.messages)
            .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

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.13.1 spec/rubocop/cop/style/favor_join_spec.rb
rubocop-0.13.0 spec/rubocop/cop/style/favor_join_spec.rb